Fixed a problem with clicking transformed rects in card wrappers.

This commit is contained in:
2020-08-27 07:38:35 +02:00
parent 4211548b8b
commit 116058ba77
2 changed files with 42 additions and 20 deletions
+14 -6
View File
@@ -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,16 +101,24 @@ 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
let bottomRight = Points.fromPageToNode(element, {
x: rect.x + rect.width,
y: rect.y + rect.height
})
let topLeft = Points.fromPageToNode(element, rect)
let width = Math.abs(bottomRight.x - topLeft.x)
let height = Math.abs(bottomRight.y - topLeft.y)
let center = Points.fromPageToNode(element, {
x: rect.x + rect.width / 2,
y: rect.y + rect.height / 2
x: rect.x + width / 2,
y: rect.y + height / 2
})
return {
x: topLeft.x,
y: topLeft.y,
width: rect.width,
height: rect.height,
width,
height,
center,
link
}
@@ -192,4 +200,4 @@ export default class CardWrapper extends Object {
this.tapNodes.set(objOrSelector, handler)
}
}
}
}