diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cd3bbf0..1544cefc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ - bug fixes - editor: changes applied to wrong widget when clicking on a widget while editing another widget's property - - push: allow setting `value` property + - push: allow setting `value` property +- widgets + - sliders: when `steps` is set, scrolling on the widget makes it go directly from one step to another ## 0.41.4 diff --git a/src/client/app/widgets/sliders/slider.js b/src/client/app/widgets/sliders/slider.js index ef49fd0e..6375667d 100644 --- a/src/client/app/widgets/sliders/slider.js +++ b/src/client/app/widgets/sliders/slider.js @@ -140,9 +140,15 @@ class Slider extends Canvas { var direction = e.wheelDelta / Math.abs(e.wheelDelta), increment = e.ctrlKey?0.25:1 - this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.precision + 1)) * direction, [0,100]) - - this.setValue(this.percentToValue(this.percent), {sync:true,send:true,dragged:true}) + if (this.getProp('steps')) { + var i = this.steps.indexOf(this.value) + if (i > -1 && i < this.steps.length) { + this.setValue(this.steps[i + direction], {sync: true, send: true, fromLocal: true}) + } + } else { + this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.precision + 1)) * direction, [0,100]) + this.setValue(this.percentToValue(this.percent), {sync: true, send: true, dragged: true}) + } }