button: locals.touchCoords not updated upon release and incorrect when doubleTap is set
This commit is contained in:
parent
1a564f8458
commit
f31cc2091c
2 changed files with 26 additions and 9 deletions
|
|
@ -94,7 +94,12 @@ class Button extends Widget {
|
|||
doubleTap(this, (e)=>{
|
||||
|
||||
this.touchActive = true
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true, y: e.offsetY, x: e.offsetX, local:true})
|
||||
|
||||
if (this.exposeTouchCoords) {
|
||||
this.parsersLocalScope.touchCoords = [e.offsetX / this.buttonSize[0], 1 - e.offsetY / this.buttonSize[1]]
|
||||
}
|
||||
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true, local:true})
|
||||
|
||||
if (tap) this.container.classList.add('active')
|
||||
|
||||
|
|
@ -107,7 +112,12 @@ class Button extends Widget {
|
|||
if (this.touchActive) return
|
||||
|
||||
this.touchActive = true
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true, y: e.offsetY, x: e.offsetX, local:true})
|
||||
|
||||
if (this.exposeTouchCoords) {
|
||||
this.parsersLocalScope.touchCoords = [e.offsetX / this.buttonSize[0], 1 - e.offsetY / this.buttonSize[1]]
|
||||
}
|
||||
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true, local:true})
|
||||
|
||||
if (tap) this.container.classList.add('active')
|
||||
|
||||
|
|
@ -116,6 +126,17 @@ class Button extends Widget {
|
|||
|
||||
}
|
||||
|
||||
if (this.exposeTouchCoords) {
|
||||
this.on('drag',(e)=>{
|
||||
|
||||
if (!this.touchActive) return
|
||||
|
||||
this.parsersLocalScope.touchCoords[0] += e.movementX / this.buttonSize[0]
|
||||
this.parsersLocalScope.touchCoords[1] += e.movementY / this.buttonSize[1]
|
||||
|
||||
}, {element: this.container})
|
||||
}
|
||||
|
||||
this.on('dragend',()=>{
|
||||
|
||||
if (!this.touchActive) return
|
||||
|
|
@ -298,12 +319,6 @@ class Button extends Widget {
|
|||
}
|
||||
|
||||
|
||||
if (this.exposeTouchCoords) {
|
||||
if (options.y !== undefined) {
|
||||
this.parsersLocalScope.touchCoords = [options.x / this.buttonSize[0], 1 - options.y / this.buttonSize[1]]
|
||||
}
|
||||
}
|
||||
|
||||
if (options.local || !options.fromExternal) this.localSet = true
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
|
|
|
|||
|
|
@ -24,8 +24,10 @@ module.exports = (self, callback, options={})=>{
|
|||
) {
|
||||
|
||||
// execute callback at next cycle to ensure draginit events are resolved first
|
||||
// normalize event now or offset gets lost
|
||||
var e = normalizeDragEvent(event.detail)
|
||||
setTimeout(()=>{
|
||||
callback(normalizeDragEvent(event.detail))
|
||||
callback(e)
|
||||
}, 0)
|
||||
lastTapTime = 0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue