From 3407568b5f41f8a0a427231bdbfb990876436611 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 30 Mar 2026 19:11:10 +0200 Subject: [PATCH] knob: add horizontal mode --- CHANGELOG.md | 1 + src/client/widgets/sliders/knob.mjs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da9751bd..55d824e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ -widgets - file: remember last visited directy per widget if `directory` property is not set + - knob: add `horizontal` mode ## 1.30.2 diff --git a/src/client/widgets/sliders/knob.mjs b/src/client/widgets/sliders/knob.mjs index 05aa44f0..0e4355e2 100644 --- a/src/client/widgets/sliders/knob.mjs +++ b/src/client/widgets/sliders/knob.mjs @@ -25,8 +25,9 @@ class Knob extends Slider { angle: {type: 'number', value: 270, help: 'Defines the angle\'s width of the knob, in degrees'}, }, class_specific: { - mode: {type: 'string', value: 'vertical', choices: ['vertical', 'circular', 'snap', 'snap-alt'], help: [ + mode: {type: 'string', value: 'vertical', choices: ['vertical', 'horizontal', 'circular', 'snap', 'snap-alt'], help: [ '- `vertical`: relative move in vertical motion', + '- `horizontal`: relative move in horizontal motion', '- `circular`: relative move in circular motion', '- `snap`: snap to touch position', '- `snap-alt`: alternative snap mode that allow jumping from `range.min` to `range.max`. `sensitivity` is ignored with this mode.', @@ -109,6 +110,10 @@ class Knob extends Slider { // vertical this.percent = -100 * (e.movementY / inertia * this.getProp('sensitivity')) / this.minDimension + this.percent + } else if ((this.getProp('mode') === 'horizontal' && !e.traversing)) { + // horizontal + this.percent = 100 * (e.movementX / inertia * this.getProp('sensitivity')) / this.minDimension + this.percent + } else { // snap or circular var offsetX = this.lastOffsetX + e.movementX,