events/drag: make init and end events bubble, send drag events after init in traversing mode
This commit is contained in:
parent
2df088d5fc
commit
7bc93922d8
7 changed files with 19 additions and 12 deletions
|
|
@ -25,6 +25,8 @@ function pointerMoveHandler(event) {
|
|||
|
||||
normalizeDragEvent(event, previousPointers[event.pointerId])
|
||||
|
||||
event.stopPropagation = true
|
||||
|
||||
if (event.traversing) {
|
||||
|
||||
var previousTarget = targets[event.pointerId],
|
||||
|
|
@ -38,18 +40,19 @@ function pointerMoveHandler(event) {
|
|||
resetEventOffset(event, target)
|
||||
}
|
||||
|
||||
if (previousTarget !== -1 && previousTarget !== target) {
|
||||
if (previousTarget !== target) {
|
||||
triggerWidgetEvent(previousTarget, 'dragend', event)
|
||||
}
|
||||
|
||||
targets[event.pointerId] = target
|
||||
|
||||
if (target) {
|
||||
if (event.traversingContainer.contains(target)) {
|
||||
triggerWidgetEvent(targets[event.pointerId], 'draginit', event)
|
||||
triggerWidgetEvent(target, previousTarget !== target ? 'draginit' : 'drag', event)
|
||||
}
|
||||
}
|
||||
|
||||
targets[event.pointerId] = target
|
||||
|
||||
|
||||
} else {
|
||||
triggerWidgetEvent(targets[event.pointerId], 'drag', event)
|
||||
|
|
|
|||
|
|
@ -56,8 +56,6 @@ module.exports = {
|
|||
|
||||
}
|
||||
|
||||
event.stopPropagation = true
|
||||
|
||||
},
|
||||
|
||||
resetEventOffset: function(event, target) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ module.exports = (self, options)=>{
|
|||
|
||||
} else if (self.touched > 1){
|
||||
self.touched -= 1
|
||||
if (e.traversing) self.touched = 1
|
||||
}
|
||||
}, options)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var _pads_base = require('./_pads_base'),
|
|||
Xy = require('./xy'),
|
||||
{clip} = require('../utils'),
|
||||
touchstate = require('../mixins/touch_state')
|
||||
|
||||
|
||||
|
||||
var xyDefaults = Xy.defaults()
|
||||
|
||||
|
|
@ -130,14 +130,12 @@ module.exports = class MultiXy extends _pads_base {
|
|||
this.touchMap[e.pointerId] = id
|
||||
|
||||
|
||||
} else if (e.traversing) {
|
||||
|
||||
id = this.touchMap[e.pointerId]
|
||||
|
||||
}
|
||||
|
||||
if (!id) return
|
||||
|
||||
e.stopPropagation = true
|
||||
|
||||
this.pads[id].trigger('draginit', [e])
|
||||
|
||||
}, {element: this.wrapper, multitouch: true})
|
||||
|
|
@ -145,6 +143,7 @@ module.exports = class MultiXy extends _pads_base {
|
|||
this.on('drag',(e)=>{
|
||||
|
||||
var i = this.touchMap[e.pointerId]
|
||||
|
||||
this.pads[i].trigger('drag', [e])
|
||||
|
||||
}, {element: this.wrapper[0], multitouch: true})
|
||||
|
|
@ -152,7 +151,11 @@ module.exports = class MultiXy extends _pads_base {
|
|||
this.on('dragend',(e)=>{
|
||||
|
||||
var i = this.touchMap[e.pointerId]
|
||||
|
||||
e.stopPropagation = true
|
||||
|
||||
this.pads[i].trigger('dragend', [e])
|
||||
|
||||
delete this.touchMap[e.pointerId]
|
||||
|
||||
}, {element: this.wrapper, multitouch: true})
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
this.dragHandle()
|
||||
})
|
||||
|
||||
touchstate(this, {element: this.wrapper, multitouch: true})
|
||||
touchstate(this)
|
||||
|
||||
if (this.getProp('input')) {
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ module.exports = class Xy extends _pads_base {
|
|||
})
|
||||
|
||||
this.on('draginit',(e)=>{
|
||||
e.stopPropagation = true
|
||||
this.faders.x.trigger('draginit', [e])
|
||||
this.faders.y.trigger('draginit', [e])
|
||||
this.dragHandle()
|
||||
|
|
@ -128,6 +129,7 @@ module.exports = class Xy extends _pads_base {
|
|||
}, {element: this.wrapper})
|
||||
|
||||
this.on('dragend', (e)=>{
|
||||
e.stopPropagation = true
|
||||
this.faders.x.trigger('dragend', [e])
|
||||
this.faders.y.trigger('dragend', [e])
|
||||
if (this.getProp('spring')) {
|
||||
|
|
|
|||
|
|
@ -329,6 +329,7 @@ module.exports = class Range extends _widgets_base {
|
|||
|
||||
if (!id) return
|
||||
|
||||
e.stopPropagation = true
|
||||
this.faders[id].trigger('draginit', [e])
|
||||
|
||||
}, {element: this.wrapper, multitouch: true})
|
||||
|
|
@ -343,6 +344,7 @@ module.exports = class Range extends _widgets_base {
|
|||
this.on('dragend',(e)=>{
|
||||
|
||||
var i = this.touchMap[e.pointerId]
|
||||
e.stopPropagation = true
|
||||
this.faders[i].trigger('dragend', [e])
|
||||
delete this.touchMap[e.pointerId]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue