| Index: samples/swarm/swarm_ui_lib/touch/FxUtil.dart
|
| ===================================================================
|
| --- samples/swarm/swarm_ui_lib/touch/FxUtil.dart (revision 16245)
|
| +++ samples/swarm/swarm_ui_lib/touch/FxUtil.dart (working copy)
|
| @@ -67,24 +67,14 @@
|
| * changed.
|
| */
|
| static Coordinate computeRelativePosition(Element element, Element target) {
|
| - final elementPoint = computePagePosition(element);
|
| - final targetPoint = computePagePosition(target);
|
| - return new Coordinate(elementPoint.x - targetPoint.x,
|
| - elementPoint.y - targetPoint.y);
|
| + final testPoint = new Point(0, 0);
|
| + final pagePoint =
|
| + window.webkitConvertPointFromNodeToPage(element, testPoint);
|
| + final pointRelativeToTarget =
|
| + window.webkitConvertPointFromPageToNode(target, pagePoint);
|
| + return new Coordinate(pointRelativeToTarget.x, pointRelativeToTarget.y);
|
| }
|
|
|
| - /** Computes the position of an element on the page. */
|
| - static Coordinate computePagePosition(Element element) {
|
| - num left = 0;
|
| - num top = 0;
|
| - do {
|
| - left += element.offsetLeft;
|
| - top += element.offsetTop;
|
| - element = element.offsetParent;
|
| - } while (element != null);
|
| - return new Coordinate(left, top);
|
| - }
|
| -
|
| /** Clear a -webkit-transform from an element. */
|
| static void clearWebkitTransform(Element el) {
|
| el.style.transform = '';
|
|
|