Added click handler to avoid double calls of click event handler.

This commit is contained in:
Uwe Oestermeier 2019-07-05 15:03:22 +02:00
parent 6392e4b13a
commit 84ea33f029
3 changed files with 62 additions and 29 deletions

23
dist/iwmlib.js vendored
View File

@ -5262,6 +5262,17 @@
}); });
this.resizeButton = button; this.resizeButton = button;
} }
if (clickOnTap) {
/* Since the tap triggers a synthetic click event
we must prevent the original trusted click event which
is also dispatched by the system.
*/
element.addEventListener('click', event => {
if (event.isTrusted) {
Events.stop(event);
}
}, true);
}
container.add(this); container.add(this);
} }
@ -5425,7 +5436,7 @@
if (this.clickOnTap) { if (this.clickOnTap) {
let directNode = document.elementFromPoint(event.clientX, event.clientY); let directNode = document.elementFromPoint(event.clientX, event.clientY);
console.log("onTap", directNode, this.isClickable(directNode)); console.log("onTap", event);
if (this.isClickable(directNode)) { if (this.isClickable(directNode)) {
directNode.click(); directNode.click();
} }
@ -5434,11 +5445,12 @@
if (this.isClickable(nearestNode)) { if (this.isClickable(nearestNode)) {
if (nearestNode.tagName == 'svg') { if (nearestNode.tagName == 'svg') {
let handler = this.tapNodes.get(nearestNode); let handler = this.tapNodes.get(nearestNode);
console.log("Clicking beneath SVG: to be done", handler); console.log("Clicking beneath SVG: to be done", handler);
Events.stop(event); Events.stop(event);
return return
} }
console.log("nearestNode clicked");
nearestNode.click(); nearestNode.click();
} }
} }
@ -5516,7 +5528,6 @@
let closestClickIndex = distances.indexOf(Math.min(...distances)); let closestClickIndex = distances.indexOf(Math.min(...distances));
let closestClickable = clickables[closestClickIndex]; let closestClickable = clickables[closestClickIndex];
if (distances[closestClickIndex] < this.allowClickDistance) { if (distances[closestClickIndex] < this.allowClickDistance) {
console.log("found closest clickables", closestClickable);
return closestClickable return closestClickable
} }
return null return null

27
dist/iwmlib.pixi.js vendored
View File

@ -7027,6 +7027,17 @@
}); });
this.resizeButton = button; this.resizeButton = button;
} }
if (clickOnTap) {
/* Since the tap triggers a synthetic click event
we must prevent the original trusted click event which
is also dispatched by the system.
*/
element.addEventListener('click', event => {
if (event.isTrusted) {
Events$1.stop(event);
}
}, true);
}
container.add(this); container.add(this);
} }
@ -7190,7 +7201,7 @@
if (this.clickOnTap) { if (this.clickOnTap) {
let directNode = document.elementFromPoint(event.clientX, event.clientY); let directNode = document.elementFromPoint(event.clientX, event.clientY);
console.log("onTap", directNode, this.isClickable(directNode)); console.log("onTap", event);
if (this.isClickable(directNode)) { if (this.isClickable(directNode)) {
directNode.click(); directNode.click();
} }
@ -7199,11 +7210,12 @@
if (this.isClickable(nearestNode)) { if (this.isClickable(nearestNode)) {
if (nearestNode.tagName == 'svg') { if (nearestNode.tagName == 'svg') {
let handler = this.tapNodes.get(nearestNode); let handler = this.tapNodes.get(nearestNode);
console.log("Clicking beneath SVG: to be done", handler); console.log("Clicking beneath SVG: to be done", handler);
Events$1.stop(event); Events$1.stop(event);
return return
} }
console.log("nearestNode clicked");
nearestNode.click(); nearestNode.click();
} }
} }
@ -7281,7 +7293,6 @@
let closestClickIndex = distances.indexOf(Math.min(...distances)); let closestClickIndex = distances.indexOf(Math.min(...distances));
let closestClickable = clickables[closestClickIndex]; let closestClickable = clickables[closestClickIndex];
if (distances[closestClickIndex] < this.allowClickDistance) { if (distances[closestClickIndex] < this.allowClickDistance) {
console.log("found closest clickables", closestClickable);
return closestClickable return closestClickable
} }
return null return null
@ -14840,7 +14851,7 @@
* @extends Popup * @extends Popup
* @see {@link https://www.iwm-tuebingen.de/iwmbrowser/lib/pixi/popupmenu.html|DocTest} * @see {@link https://www.iwm-tuebingen.de/iwmbrowser/lib/pixi/popupmenu.html|DocTest}
*/ */
class PopupMenu extends Popup { class PopupMenu$1 extends Popup {
/** /**
* Creates an instance of a PopupMenu. * Creates an instance of a PopupMenu.
@ -15489,7 +15500,7 @@
window.Stylus = Stylus; window.Stylus = Stylus;
window.Switch = Switch; window.Switch = Switch;
window.Popup = Popup; window.Popup = Popup;
window.PopupMenu = PopupMenu; window.PopupMenu = PopupMenu$1;
window.Modal = Modal; window.Modal = Modal;
window.Volatile = Volatile; window.Volatile = Volatile;
window.Message = Message; window.Message = Message;

View File

@ -1142,6 +1142,17 @@ export class DOMScatter extends AbstractScatter {
}) })
this.resizeButton = button this.resizeButton = button
} }
if (clickOnTap) {
/* Since the tap triggers a synthetic click event
we must prevent the original trusted click event which
is also dispatched by the system.
*/
element.addEventListener('click', event => {
if (event.isTrusted) {
Events.stop(event)
}
}, true)
}
container.add(this) container.add(this)
} }
@ -1305,7 +1316,7 @@ export class DOMScatter extends AbstractScatter {
if (this.clickOnTap) { if (this.clickOnTap) {
let directNode = document.elementFromPoint(event.clientX, event.clientY) let directNode = document.elementFromPoint(event.clientX, event.clientY)
console.log("onTap", directNode, this.isClickable(directNode)) console.log("onTap", event)
if (this.isClickable(directNode)) { if (this.isClickable(directNode)) {
directNode.click() directNode.click()
} }
@ -1314,11 +1325,12 @@ export class DOMScatter extends AbstractScatter {
if (this.isClickable(nearestNode)) { if (this.isClickable(nearestNode)) {
if (nearestNode.tagName == 'svg') { if (nearestNode.tagName == 'svg') {
let handler = this.tapNodes.get(nearestNode) let handler = this.tapNodes.get(nearestNode)
console.log("Clicking beneath SVG: to be done", handler) console.log("Clicking beneath SVG: to be done", handler)
Events.stop(event) Events.stop(event)
return return
} }
console.log("nearestNode clicked")
nearestNode.click() nearestNode.click()
} }
} }
@ -1396,7 +1408,6 @@ export class DOMScatter extends AbstractScatter {
let closestClickIndex = distances.indexOf(Math.min(...distances)) let closestClickIndex = distances.indexOf(Math.min(...distances))
let closestClickable = clickables[closestClickIndex] let closestClickable = clickables[closestClickIndex]
if (distances[closestClickIndex] < this.allowClickDistance) { if (distances[closestClickIndex] < this.allowClickDistance) {
console.log("found closest clickables", closestClickable)
return closestClickable return closestClickable
} }
return null return null