diff --git a/src/client/widgets/sliders/scrollbar.mjs b/src/client/widgets/sliders/scrollbar.mjs index 14f0a73a..4de495c6 100644 --- a/src/client/widgets/sliders/scrollbar.mjs +++ b/src/client/widgets/sliders/scrollbar.mjs @@ -115,6 +115,17 @@ export default class Scrollbar extends StaticProperties(Fader, { } + cacheCanvasStyle(style){ + + super.cacheCanvasStyle(style) + + var size = this.getProp('horizontal') ? this.width : this.height + this.cssVars.knobSize = Math.max(this.thumbSize * size, 30) + this.cssVars.alphaKnob = 0.25 + + } + + unbindTarget() { if (!this.scrollTarget) return @@ -142,6 +153,9 @@ export default class Scrollbar extends StaticProperties(Fader, { var index = this.getProp('horizontal') ? 0 : 1, size = this.getProp('horizontal') ? this.width : this.height + this.thumbSize = this.scrollTarget.scrollThumb[index] + this.cssVars.knobSize = Math.max(this.thumbSize * size, 30) + if (init && this.value) { // panel (re)createed: restore scroll state this.setValue(this.value, {fromScrollEvent: false, send: false, sync: false}) @@ -176,15 +190,15 @@ export default class Scrollbar extends StaticProperties(Fader, { draw() { - var horizontal = this.getProp('horizontal'), - width = horizontal ? this.height : this.width, - height = !horizontal ? this.height : this.width, - percent = this.steps ? this.valueToPercent(this.value) : this.percent, + var width = this.getProp('horizontal') ? this.height : this.width, + height = !this.getProp('horizontal') ? this.height : this.width + + var percent = this.steps ? this.valueToPercent(this.value) : this.percent, d = Math.round(this.percentToCoord(percent)), o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))), - m = horizontal ? this.height / 2 : this.width / 2, + m = this.getProp('horizontal') ? this.height / 2 : this.width / 2, dashed = this.dashed, - knobHeight = Math.max(this.scrollTarget.scrollThumb[horizontal ? 0 : 1] * height, 30) + knobHeight = this.cssVars.knobSize this.clear()