From 6d1e4b4e8b0607a22729d919fca65352fcb399e5 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 7 Apr 2019 19:12:41 +0200 Subject: [PATCH] switch: fix traversing + touch (#503) --- CHANGELOG.md | 1 + src/client/app/widgets/buttons/switch.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 495b1e3a..cd513228 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - sessions not added to history when opened + - switch: traversing mode issue - widgets - **removed** deprecated widgets `multifader`, `multitoggle`, `multipush` and `formula` - new `JS{{}}` property syntax, allows writing formulas using javascript diff --git a/src/client/app/widgets/buttons/switch.js b/src/client/app/widgets/buttons/switch.js index ae4fabe5..17b57556 100644 --- a/src/client/app/widgets/buttons/switch.js +++ b/src/client/app/widgets/buttons/switch.js @@ -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}) }