Improved click behavior

This commit is contained in:
2019-07-05 14:40:35 +02:00
parent 14f2c2fbe6
commit 6392e4b13a
3 changed files with 44 additions and 23 deletions
+14 -7
View File
@@ -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