| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 6 $!MEMBERS |
| 7 |
| 8 int get offsetX() { |
| 9 if (JS('bool', '!!this.offsetX')) { |
| 10 return this._offsetX; |
| 11 } else { |
| 12 // Firefox does not support offsetX. |
| 13 var target = this.target; |
| 14 if (!(target is Element)) { |
| 15 throw const UnsupportedOperationException( |
| 16 'offsetX is only supported on elements'); |
| 17 } |
| 18 return this.clientX - this.target.$dom_getBoundingClientRect().left; |
| 19 } |
| 20 } |
| 21 |
| 22 int get offsetY() { |
| 23 if (JS('bool', '!!this.offsetY')) { |
| 24 return this._offsetY; |
| 25 } else { |
| 26 // Firefox does not support offsetY. |
| 27 var target = this.target; |
| 28 if (!(target is Element)) { |
| 29 throw const UnsupportedOperationException( |
| 30 'offsetX is only supported on elements'); |
| 31 } |
| 32 return this.clientY - this.target.$dom_getBoundingClientRect().top; |
| 33 } |
| 34 } |
| 35 |
| 36 int get _offsetX() native 'return this.offsetX'; |
| 37 int get _offsetY() native 'return this.offsetY'; |
| 38 } |
| OLD | NEW |