Improved click handling
This commit is contained in:
parent
e32ee93e7a
commit
ef4267e926
@ -1,6 +1,7 @@
|
|||||||
circle {
|
circle {
|
||||||
stroke: white;
|
stroke: white;
|
||||||
fill: transparent;
|
fill: transparent;
|
||||||
|
stroke-width: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
mask circle {
|
mask circle {
|
||||||
|
@ -215,6 +215,9 @@ export default class Highlight extends Object {
|
|||||||
this._bringToFront(target)
|
this._bringToFront(target)
|
||||||
|
|
||||||
let svgRoot = target.closest('svg')
|
let svgRoot = target.closest('svg')
|
||||||
|
if (svgRoot == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let image = svgRoot.querySelector('image')
|
let image = svgRoot.querySelector('image')
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
@ -45,8 +45,22 @@ export default class CardWrapper extends Object {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isClickPrevented(node) {
|
||||||
|
if (node == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (node.style && node.style.pointerEvents == 'none') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return this.isClickPrevented(node.parentNode)
|
||||||
|
}
|
||||||
|
|
||||||
isClickable(node) {
|
isClickable(node) {
|
||||||
if (node == null) return false
|
if (node == null) return false
|
||||||
|
// console.log("isClickable", node, this.isClickPrevented(node))
|
||||||
|
if (this.isClickPrevented(node)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (node.tagName == 'A' && node.hasAttribute('href')) return true
|
if (node.tagName == 'A' && node.hasAttribute('href')) return true
|
||||||
if (node.hasAttribute('onclick')) return true
|
if (node.hasAttribute('onclick')) return true
|
||||||
return false
|
return false
|
||||||
@ -140,6 +154,7 @@ export default class CardWrapper extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodeTapped(node, event) {
|
nodeTapped(node, event) {
|
||||||
|
console.log("nodeTapped", node, this.isClickable(node))
|
||||||
if (this.isClickable(node)) {
|
if (this.isClickable(node)) {
|
||||||
this.simulateClick(node, event)
|
this.simulateClick(node, event)
|
||||||
return true
|
return true
|
||||||
@ -150,6 +165,7 @@ export default class CardWrapper extends Object {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
for (let [selector, handler] of this.tapHandler.entries()) {
|
for (let [selector, handler] of this.tapHandler.entries()) {
|
||||||
|
console.log("nodeTapped", selector)
|
||||||
for (let obj of this.domNode.querySelectorAll(selector)) {
|
for (let obj of this.domNode.querySelectorAll(selector)) {
|
||||||
if (node == obj) {
|
if (node == obj) {
|
||||||
handler(event)
|
handler(event)
|
||||||
@ -161,8 +177,10 @@ export default class CardWrapper extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tap(event, calledBy = 'unknown') {
|
tap(event, calledBy = 'unknown') {
|
||||||
|
|
||||||
if (event.isTrusted) {
|
if (event.isTrusted) {
|
||||||
let node = this.nearestActive(event)
|
let node = this.nearestActive(event)
|
||||||
|
console.log("tap", node)
|
||||||
this.nodeTapped(node, event)
|
this.nodeTapped(node, event)
|
||||||
|
|
||||||
/* let node = document.elementFromPoint(event.clientX, event.clientY)
|
/* let node = document.elementFromPoint(event.clientX, event.clientY)
|
||||||
|
Loading…
Reference in New Issue
Block a user