knob: add horizontal mode
This commit is contained in:
parent
51e33c0230
commit
3407568b5f
2 changed files with 7 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue