Using original click events for SVG elements. Must be checked for taps on touch devices.

This commit is contained in:
2019-07-05 16:11:23 +02:00
parent 84ea33f029
commit f68d8b53a3
4 changed files with 70 additions and 16 deletions
+11 -2
View File
@@ -1148,6 +1148,12 @@ export class DOMScatter extends AbstractScatter {
is also dispatched by the system.
*/
element.addEventListener('click', event => {
/* Currently we cannot send synthesized click events to SVG elements without unwanted side effects.
Therefore we make an exception and let the original click event through.
*/
if (event.target.ownerSVGElement) {
return
}
if (event.isTrusted) {
Events.stop(event)
}
@@ -1323,11 +1329,14 @@ export class DOMScatter extends AbstractScatter {
else {
let nearestNode = this.nearestClickable(event)
if (this.isClickable(nearestNode)) {
/* 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 (nearestNode.tagName == 'svg') {
let handler = this.tapNodes.get(nearestNode)
console.log("Clicking beneath SVG: to be done", handler)
Events.stop(event)
// nearestNode.dispatchEvent(new Event('click'))
return
}
console.log("nearestNode clicked")