switch: fix traversing + touch (#503)
This commit is contained in:
parent
d657665210
commit
1328fba53f
2 changed files with 10 additions and 2 deletions
|
|
@ -62,11 +62,16 @@ module.exports = class Switch extends Widget {
|
|||
|
||||
this.value = undefined
|
||||
|
||||
var dragCallback = (e)=>{
|
||||
var dragCallback = (e, touchFix)=>{
|
||||
|
||||
var index = 0,
|
||||
node = e.target
|
||||
|
||||
if (touchFix && e.isTouch) {
|
||||
// special traversing touch fix
|
||||
node = document.elementFromPoint(e.clientX, e.clientY)
|
||||
}
|
||||
|
||||
if (node === this.widget || !this.widget.contains(node)) return
|
||||
|
||||
while ( (node = node.previousSibling) ) {
|
||||
|
|
@ -82,7 +87,9 @@ module.exports = class Switch extends Widget {
|
|||
}
|
||||
|
||||
this.on('draginit', dragCallback , {element: this.widget})
|
||||
if (this.getProp('traversing')) this.on('drag', dragCallback , {element: this.widget})
|
||||
this.on('drag', (e)=>{
|
||||
if (this.getProp('traversing') || e.traversing) dragCallback(e, true)
|
||||
} , {element: this.widget})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue