From 0f60d212fa218c12fd746f63d5bf67197bd4cb88 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 10 Mar 2025 09:00:45 +0100 Subject: [PATCH] xy/multixy: add `auto` choice to to `axisLock` (locks on the first moved axis) --- CHANGELOG.md | 3 ++- src/client/widgets/pads/multixy.js | 2 +- src/client/widgets/pads/xy.js | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af1810e..b5a69c06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ - fader: add `touchZone` property to allow restricting interaction to a part of the widget - eq: add support for n-poles lowpass and highpass filters with the filter's `poles` property - eq: adapt sampling frequency to the x-axis range - + - xy/multixy: add `auto` choice to to `axisLock` (locks on the first moved axis) + ## 1.27.5 - bug fixes diff --git a/src/client/widgets/pads/multixy.js b/src/client/widgets/pads/multixy.js index 3e2345f2..9ccd18a6 100644 --- a/src/client/widgets/pads/multixy.js +++ b/src/client/widgets/pads/multixy.js @@ -40,7 +40,7 @@ module.exports = class MultiXy extends Pad { rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'}, logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'}, - axisLock: {type: 'string', value: '', choices: ['', 'x', 'y'], help: [ + axisLock: {type: 'string', value: '', choices: ['', 'auto', 'x', 'y'], help: [ 'Restrict movements to one of the axes only.', 'When left to the default value, holding `Shift` while dragging will lock the pad according the first movement.' ]}, diff --git a/src/client/widgets/pads/xy.js b/src/client/widgets/pads/xy.js index 42609df2..7a689f08 100644 --- a/src/client/widgets/pads/xy.js +++ b/src/client/widgets/pads/xy.js @@ -32,7 +32,7 @@ module.exports = class Xy extends Pad { rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'}, logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'}, - axisLock: {type: 'string', value: '', choices: ['', 'x', 'y'], help: [ + axisLock: {type: 'string', value: '', choices: ['', 'auto', 'x', 'y'], help: [ 'Restrict movements to one of the axes only unless `Shift` is held.', 'When left to the default value, holding `Shift` while dragging will lock the pad according the first movement.' ]}, @@ -107,7 +107,7 @@ module.exports = class Xy extends Pad { this.on('drag',(e)=>{ var axis = this.getProp('axisLock') if (axis !== '' && e.shiftKey) axis = '' - else if (e.shiftKey && axis === '') { + else if (e.shiftKey && axis === '' || !e.shiftKey && axis === 'auto') { if (this.autoAxisLock === '') { if (Math.abs(e.movementX) > Math.abs(e.movementY)) { this.autoAxisLock = 'x'