From 6392e4b13a5330286a15e56737a15027e5424646 Mon Sep 17 00:00:00 2001 From: uoestermeier Date: Fri, 5 Jul 2019 14:40:35 +0200 Subject: [PATCH] Improved click behavior --- dist/iwmlib.js | 21 ++++++++++++++------- dist/iwmlib.pixi.js | 25 ++++++++++++++++--------- lib/scatter.js | 21 ++++++++++++++------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/dist/iwmlib.js b/dist/iwmlib.js index 5a17a14..8954532 100644 --- a/dist/iwmlib.js +++ b/dist/iwmlib.js @@ -5424,19 +5424,22 @@ onTap(event, interaction, point) { if (this.clickOnTap) { - let directNode = document.elementFromPoint(point.x, point.y); - let nearestNode = this.nearestClickable(event); - - console.log("onTap", directNode, nearestNode.tagName); - if (directNode != null && this.isClickable(directNode)) { + let directNode = document.elementFromPoint(event.clientX, event.clientY); + console.log("onTap", directNode, this.isClickable(directNode)); + if (this.isClickable(directNode)) { directNode.click(); } else { - if (nearestNode.tagName == 'svg' && this.isClickable(nearestNode)) { + let nearestNode = this.nearestClickable(event); + if (this.isClickable(nearestNode)) { + + if (nearestNode.tagName == 'svg') { let handler = this.tapNodes.get(nearestNode); console.log("Clicking beneath SVG: to be done", handler); Events.stop(event); - //nearestNode.click() + return + } + nearestNode.click(); } } } @@ -5463,8 +5466,12 @@ } isClickable(node) { + if (node == null) + return false if (node.tagName == 'A') return true + if (node.hasAttribute("onclick")) + return true if (this.tapNodes.has(node)) return true return false diff --git a/dist/iwmlib.pixi.js b/dist/iwmlib.pixi.js index ef8ed40..0044dd1 100644 --- a/dist/iwmlib.pixi.js +++ b/dist/iwmlib.pixi.js @@ -7189,19 +7189,22 @@ onTap(event, interaction, point) { if (this.clickOnTap) { - let directNode = document.elementFromPoint(point.x, point.y); - let nearestNode = this.nearestClickable(event); - - console.log("onTap", directNode, nearestNode.tagName); - if (directNode != null && this.isClickable(directNode)) { + let directNode = document.elementFromPoint(event.clientX, event.clientY); + console.log("onTap", directNode, this.isClickable(directNode)); + if (this.isClickable(directNode)) { directNode.click(); } else { - if (nearestNode.tagName == 'svg' && this.isClickable(nearestNode)) { + let nearestNode = this.nearestClickable(event); + if (this.isClickable(nearestNode)) { + + if (nearestNode.tagName == 'svg') { let handler = this.tapNodes.get(nearestNode); console.log("Clicking beneath SVG: to be done", handler); Events$1.stop(event); - //nearestNode.click() + return + } + nearestNode.click(); } } } @@ -7228,8 +7231,12 @@ } isClickable(node) { + if (node == null) + return false if (node.tagName == 'A') return true + if (node.hasAttribute("onclick")) + return true if (this.tapNodes.has(node)) return true return false @@ -14833,7 +14840,7 @@ * @extends Popup * @see {@link https://www.iwm-tuebingen.de/iwmbrowser/lib/pixi/popupmenu.html|DocTest} */ - class PopupMenu$1 extends Popup { + class PopupMenu extends Popup { /** * Creates an instance of a PopupMenu. @@ -15482,7 +15489,7 @@ window.Stylus = Stylus; window.Switch = Switch; window.Popup = Popup; - window.PopupMenu = PopupMenu$1; + window.PopupMenu = PopupMenu; window.Modal = Modal; window.Volatile = Volatile; window.Message = Message; diff --git a/lib/scatter.js b/lib/scatter.js index c0942cd..8c09ba1 100644 --- a/lib/scatter.js +++ b/lib/scatter.js @@ -1304,19 +1304,22 @@ export class DOMScatter extends AbstractScatter { onTap(event, interaction, point) { if (this.clickOnTap) { - let directNode = document.elementFromPoint(point.x, point.y) - let nearestNode = this.nearestClickable(event) - - console.log("onTap", directNode, nearestNode.tagName) - if (directNode != null && this.isClickable(directNode)) { + let directNode = document.elementFromPoint(event.clientX, event.clientY) + console.log("onTap", directNode, this.isClickable(directNode)) + if (this.isClickable(directNode)) { directNode.click() } else { - if (nearestNode.tagName == 'svg' && this.isClickable(nearestNode)) { + let nearestNode = this.nearestClickable(event) + if (this.isClickable(nearestNode)) { + + if (nearestNode.tagName == 'svg') { let handler = this.tapNodes.get(nearestNode) console.log("Clicking beneath SVG: to be done", handler) Events.stop(event) - //nearestNode.click() + return + } + nearestNode.click() } } } @@ -1343,8 +1346,12 @@ export class DOMScatter extends AbstractScatter { } isClickable(node) { + if (node == null) + return false if (node.tagName == 'A') return true + if (node.hasAttribute("onclick")) + return true if (this.tapNodes.has(node)) return true return false