diff --git a/resources/js/game/GazePoint.js b/resources/js/game/GazePoint.js index 9ec880c..ec5a239 100644 --- a/resources/js/game/GazePoint.js +++ b/resources/js/game/GazePoint.js @@ -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; }