From c40d30aa2b02948f0dd9faadd227b17082eda2b0 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 20 Jun 2026 19:08:43 +0200 Subject: [PATCH] encoder: add horizontal mode --- CHANGELOG.md | 3 +++ src/client/widgets/sliders/encoder.mjs | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05408995..73e58ba5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ - bug fixes - remote control: add support for icon transform suffixes +- widgets + - encoder: add `horizontal` mode + ## 1.30.3 - bug fixes diff --git a/src/client/widgets/sliders/encoder.mjs b/src/client/widgets/sliders/encoder.mjs index 0a5cf186..1e94c58f 100644 --- a/src/client/widgets/sliders/encoder.mjs +++ b/src/client/widgets/sliders/encoder.mjs @@ -33,10 +33,11 @@ export default class Encoder extends StaticProperties(Knob, {angle: 360, range: '- Set to `null` to send send no argument in the osc message', '- Can be an `object` if the type needs to be specified' ]}, - mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical'], help: [ + mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical', 'horizontal'], help: [ '- `circular`: relative move in circular motion', '- `snap`: snap to touch position and move in vertical motion', '- `vertical`: relative move in vertical motion', + '- `horizontal`: relative move in horizontal motion', ]}, doubleTap: {type: 'boolean', value: false, help: [ 'Set to `true` to make the fader reset to its `default` value when receiving a double tap.', @@ -116,7 +117,11 @@ export default class Encoder extends StaticProperties(Knob, {angle: 360, range: if ((this.getProp('mode') === 'vertical' && !e.traversing)) { // vertical - this.setPercent(this.percent + (-100 * e.movementY / this.height) * this.getProp('sensitivity') / inertia) + this.setPercent(this.percent - 100 * (e.movementY / inertia * this.getProp('sensitivity')) / this.minDimension) + + } else if ((this.getProp('mode') === 'horizontal' && !e.traversing)) { + // horizontal + this.setPercent(this.percent + 100 * (e.movementX / inertia * this.getProp('sensitivity')) / this.minDimension) } else { // snap or circular