GazePoint.js 603 Bytes
Newer Older
Alexander Bazo committed
1 2
class GazePoint {

3
  constructor(screenX, screenY, createdAt, id) {
Alexander Bazo committed
4 5
    this.screenX = screenX;
    this.screenY = screenY;
6
    this.createdAt = createdAt;
Alexander Bazo committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
    this.id = id || this.createdAt;
  }

  linkTo(node) {
    let bb = node.getBoundingClientRect(),
      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;
    }
    return coordinates;
  }

}

export default GazePoint;