Commit 25d25db4 by Alexander Bazo

Use page offset to calculate target coordinates

parent 9064e309
...@@ -9,14 +9,19 @@ class GazePoint { ...@@ -9,14 +9,19 @@ class GazePoint {
linkTo(node) { linkTo(node) {
let bb = node.getBoundingClientRect(), let bb = node.getBoundingClientRect(),
elementLeft = window.pageXOffset + bb.left,
elementTop = window.pageYOffset + bb.top,
elementRight = window.pageXOffset + bb.right,
elementBottom = window.pageYOffset + bb.bottom,
coordinates; coordinates;
if (this.screenX >= bb.left && this.screenX <= bb.right && this.screenY >= if (this.screenX >= elementLeft && this.screenX <= elementRight && this
bb.top && this.screenY <= bb.bottom) { .screenY >=
this.hasLink = true; elementTop && this.screenY <= elementBottom) {
this.link = node; this.hasLink = true;
this.targetX = this.screenX - bb.left; this.link = node;
this.targetY = this.screenY - bb.top; this.targetX = this.screenX - elementLeft;
} this.targetY = this.screenY - elementTop;
}
return coordinates; return coordinates;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment