From fe1ae44e6045b878ea116d4d3f0bc313aaeb90c1 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 22 Sep 2025 12:04:18 +0200 Subject: [PATCH] scrollbar: simplify thumbsize code --- src/client/widgets/sliders/scrollbar.mjs | 26 ++++++------------------ 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/client/widgets/sliders/scrollbar.mjs b/src/client/widgets/sliders/scrollbar.mjs index 4de495c6..14f0a73a 100644 --- a/src/client/widgets/sliders/scrollbar.mjs +++ b/src/client/widgets/sliders/scrollbar.mjs @@ -115,17 +115,6 @@ 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 @@ -153,9 +142,6 @@ 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}) @@ -190,15 +176,15 @@ export default class Scrollbar extends StaticProperties(Fader, { draw() { - 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, + 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, d = Math.round(this.percentToCoord(percent)), o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))), - m = this.getProp('horizontal') ? this.height / 2 : this.width / 2, + m = horizontal ? this.height / 2 : this.width / 2, dashed = this.dashed, - knobHeight = this.cssVars.knobSize + knobHeight = Math.max(this.scrollTarget.scrollThumb[horizontal ? 0 : 1] * height, 30) this.clear()