From 5eae65a0aa441dd04271d18ee202f153fff955f9 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 21 Sep 2025 18:21:46 +0200 Subject: [PATCH] scrollbar: set a min size for the scrollthumb and continue implimentatiob --- src/client/widgets/containers/panel.mjs | 3 ++- src/client/widgets/sliders/scrollbar.mjs | 21 ++++++++++++++------- src/scss/widgets/containers.scss | 4 ++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/client/widgets/containers/panel.mjs b/src/client/widgets/containers/panel.mjs index 9d5b099b..04f02e93 100644 --- a/src/client/widgets/containers/panel.mjs +++ b/src/client/widgets/containers/panel.mjs @@ -31,7 +31,7 @@ class Panel extends Container() { justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'}, gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns or a valid value for the css property "grid-template".'}, contain: {type: 'boolean', value: true, help:'If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel.'}, - scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, + scroll: {type: 'boolean|string', value: true, choices: [true, false, 'hidden'], help: 'Set to `false` to disable scrollbars, set to `hidden` to hide scrollbars while allowing to scroll (may not work on old browsers).'}, innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'}, tabsPosition: {type: 'string', value: 'top', choices: ['top', 'bottom', 'left', 'right', 'hidden'], help: 'Defines the position of the navigation bar if the panel contains tabs'}, }, @@ -72,6 +72,7 @@ class Panel extends Container() { this.container.classList.toggle('no-inner-padding', !this.getProp('innerPadding')) this.container.classList.toggle('no-scroll', !this.getProp('scroll')) + this.container.classList.toggle('hidden-scroll', this.getProp('scroll') == 'hidden') this.container.classList.add('layout-' + this.getProp('layout')) this.container.classList.toggle('layout-contain', this.getProp('contain')) diff --git a/src/client/widgets/sliders/scrollbar.mjs b/src/client/widgets/sliders/scrollbar.mjs index 4b1b9e4f..8b6d7759 100644 --- a/src/client/widgets/sliders/scrollbar.mjs +++ b/src/client/widgets/sliders/scrollbar.mjs @@ -62,6 +62,15 @@ export default class Scrollbar extends StaticProperties(Fader, { } }, {context: this}) + + var widgets = widgetManager.getWidgetById(this.getProp('widgetId')) + for (var widget of widgets) { + if (widget.getProp('scroll')) { + this.unbindTarget() + this.bindTarget(widget) + break + } + } } @@ -110,7 +119,7 @@ export default class Scrollbar extends StaticProperties(Fader, { super.cacheCanvasStyle(style) var size = this.getProp('horizontal') ? this.width : this.height - this.cssVars.knobSize = this.thumbSize * size + this.cssVars.knobSize = Math.max(this.thumbSize * size, 30) this.cssVars.alphaKnob = 0.25 } @@ -132,8 +141,6 @@ export default class Scrollbar extends StaticProperties(Fader, { this.scrollTarget = target - // listen for cloneTarget's deletion - // if it is just edited, its recreation will be caught by the global 'widget-created' event handler this.scrollTarget.on('widget-removed', (e)=>{ if (this.scrollTarget === e.widget) { this.unbindTarget() @@ -147,8 +154,8 @@ export default class Scrollbar extends StaticProperties(Fader, { size = this.getProp('horizontal') ? this.width : this.height this.thumbSize = this.scrollTarget.scrollThumb[index] - this.cssVars.knobSize = this.thumbSize * size - this.setValue(this.scrollTarget.scroll[index], {fromPanel:true, script:true}) + this.cssVars.knobSize = Math.max(this.thumbSize * size, 30) + this.setValue(this.scrollTarget.scroll[index], {fromPanel:true, send:true, sync:true}) } this.scrollTarget.on('scroll', onScroll) @@ -166,9 +173,9 @@ export default class Scrollbar extends StaticProperties(Fader, { if (!options.fromPanel && this.scrollTarget) { if (this.getProp('horizontal')) { - this.scrollTarget.setScroll(this.value, undefined, true) + this.scrollTarget.setScroll(this.value, undefined, !options.fromPanel) } else { - this.scrollTarget.setScroll(undefined, this.value, true) + this.scrollTarget.setScroll(undefined, this.value, !options.fromPanel) } } diff --git a/src/scss/widgets/containers.scss b/src/scss/widgets/containers.scss index 2cb50f9a..5d40fee9 100644 --- a/src/scss/widgets/containers.scss +++ b/src/scss/widgets/containers.scss @@ -29,6 +29,10 @@ + &.hidden-scroll > inner { + scrollbar-width: none; + } + &.no-scroll > inner { overflow: hidden; }