From ca5a39d6615505d7070de501543abf4a0039af5a Mon Sep 17 00:00:00 2001 From: Ukmasmu Date: Tue, 26 Jan 2021 08:01:51 +0100 Subject: [PATCH] Changed wrapper and events to allow other EventListeners. --- lib/card/wrapper.js | 29 +++++++++++++++++------------ lib/events.js | 5 ++++- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/card/wrapper.js b/lib/card/wrapper.js index cf63ab4..ed88a41 100644 --- a/lib/card/wrapper.js +++ b/lib/card/wrapper.js @@ -54,7 +54,7 @@ export default class CardWrapper extends Object { isClickable(node) { if (node == null) return false - // console.log("isClickable", node, this.isClickPrevented(node)) + // console.log("isClickable", node, this.isClickPrevented(node)) if (this.isClickPrevented(node)) { return false } @@ -101,8 +101,8 @@ export default class CardWrapper extends Object { let clickRects = activeNodes.map(link => { let rect = link.getBoundingClientRect() - // Since the getBoundingClientRect is untransformed we cannot rely on it's size - // We need a transformed bottom right to calculate local width and height + // Since the getBoundingClientRect is untransformed we cannot rely on it's size + // We need a transformed bottom right to calculate local width and height let bottomRight = Points.fromPageToNode(element, { x: rect.x + rect.width, y: rect.y + rect.height @@ -146,14 +146,19 @@ export default class CardWrapper extends Object { /* https://stackoverflow.com/questions/49564905/is-it-possible-to-use-click-function-on-svg-tags-i-tried-element-click-on-a proposes the dispatchEvent solution. But this leads to problems in flippable.html hiding the back page. Therefore we use the original click event (see constructor). */ - if (this.isSVGNode(node)) { - if (this.triggerSVGClicks) { - let click = new Event('click') - node.dispatchEvent(click) - } - return - } - node.click() + // if (this.isSVGNode(node)) { + // if (this.triggerSVGClicks) { + // let click = new Event('click') + // node.dispatchEvent(click) + // } + // return + // } + // node.click() + + let click = new Event('click') + click.clientX = event.clientX + click.clientY = event.clientY + node.dispatchEvent(click) } nodeTapped(node, event) { @@ -200,4 +205,4 @@ export default class CardWrapper extends Object { this.tapNodes.set(objOrSelector, handler) } } -} \ No newline at end of file +} diff --git a/lib/events.js b/lib/events.js index 21af172..b616505 100755 --- a/lib/events.js +++ b/lib/events.js @@ -1,7 +1,10 @@ export default class Events { static stop(event) { event.preventDefault() - event.stopPropagation() + // I removed this, as it destroys all the Hammer.js events. + // And also the click event. + // It seems to have no (apparent) negative impact. -SO + // event.stopPropagation() } static extractPoint(event) {