Commit 25d25db4 by Alexander Bazo

Use page offset to calculate target coordinates

parent 9064e309
......@@ -9,14 +9,19 @@ class GazePoint {
linkTo(node) {
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;
if (this.screenX >= bb.left && this.screenX <= bb.right && this.screenY >=
bb.top && this.screenY <= bb.bottom) {
this.hasLink = true;
this.link = node;
this.targetX = this.screenX - bb.left;
this.targetY = this.screenY - bb.top;
}
if (this.screenX >= elementLeft && this.screenX <= elementRight && this
.screenY >=
elementTop && this.screenY <= elementBottom) {
this.hasLink = true;
this.link = node;
this.targetX = this.screenX - elementLeft;
this.targetY = this.screenY - elementTop;
}
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