W3cubDocs

/Dart 2

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());
  }
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-html/MouseEvent/offset.html