offset property

Point<num> offset

The coordinates of the mouse pointer in target node coordinates.

This value may vary between platforms if the target node moves after the event has fired or if the element has CSS transforms affecting it.

Implementation

Point get offset {
  if (JS('bool', '!!#.offsetX', this)) {
    var x = JS('int', '#.offsetX', this);
    var y = JS('int', '#.offsetY', this);
    return new Point(x, y);
  } else {
    // Firefox does not support offsetX.
    if (!(this.target is Element)) {
      throw new UnsupportedError('offsetX is only supported on elements');
    }
    Element target = this.target;
    var point = (this.client - target.getBoundingClientRect().topLeft);
    return new Point(point.x.toInt(), point.y.toInt());
  }
}