encoder: add horizontal mode

This commit is contained in:
jean-emmanuel 2026-06-20 19:08:43 +02:00
parent d22f850598
commit c40d30aa2b
2 changed files with 10 additions and 2 deletions

View file

@ -6,6 +6,9 @@
- bug fixes
- remote control: add support for icon transform suffixes
- widgets
- encoder: add `horizontal` mode
## 1.30.3
- bug fixes

View file

@ -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