button: add click option & add missing move events to onTouch
This commit is contained in:
parent
b016724d04
commit
6b37c4521e
1 changed files with 8 additions and 5 deletions
|
|
@ -45,6 +45,7 @@ class Button extends Widget {
|
|||
'- `tap` (no release, sends `on` as value)',
|
||||
]},
|
||||
doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the button require a double tap to be pushed instead of a single tap'},
|
||||
click: {type: 'boolean', value: false, help: 'Set to `true` to activate upon click event instead of tap'},
|
||||
decoupled: {type: 'boolean', value: false, help: [
|
||||
'Set to `true` make the local feedback update only when it receives a value from an osc/midi message that matches the `on` or `off` property.',
|
||||
'When `decoupled`, the button\'s value is ambiguous: when interacted with, it will send the value that\'s requested (`on` or `off` for `toggle` and `push` modes, `on` for `tap` mode, `null` for `momentary`), otherwise it will return the value received from the feedback message (`on` or `off` property).',
|
||||
|
|
@ -93,7 +94,8 @@ class Button extends Widget {
|
|||
|
||||
var mode = this.getProp('mode'),
|
||||
tap = mode === 'momentary' || mode === 'tap',
|
||||
push = mode === 'push' || tap
|
||||
push = mode === 'push' || tap,
|
||||
click = this.getProp('click') && mode !== 'push'
|
||||
|
||||
if (push) {
|
||||
|
||||
|
|
@ -111,11 +113,11 @@ class Button extends Widget {
|
|||
|
||||
if (tap) this.container.classList.add('active')
|
||||
|
||||
}, {element: this.container})
|
||||
}, {element: this.container, click: click})
|
||||
|
||||
} else {
|
||||
|
||||
this.on('draginit',(e)=>{
|
||||
this.on(click ? 'click': 'draginit',(e)=>{
|
||||
|
||||
if (this.touchActive) return
|
||||
|
||||
|
|
@ -167,11 +169,11 @@ class Button extends Widget {
|
|||
this.touchActive = true
|
||||
this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true, y: e.offsetY, x: e.offsetX, local:true})
|
||||
|
||||
}, {element: this.container})
|
||||
}, {element: this.container, click: click})
|
||||
|
||||
} else {
|
||||
|
||||
this.on('draginit',(e)=>{
|
||||
this.on(click ? 'click': 'draginit',(e)=>{
|
||||
|
||||
if (this.touchActive) return
|
||||
|
||||
|
|
@ -227,6 +229,7 @@ class Button extends Widget {
|
|||
}
|
||||
|
||||
if (this.getProp('onTouch')) {
|
||||
this.on('drag',(e)=>this.onTouch(e, 'move'), {element: this.container})
|
||||
this.on('dragend',(e)=>this.onTouch(e, 'stop'), {element: this.container})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue