OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of touch; | 5 part of touch; |
6 | 6 |
7 /** | 7 /** |
8 * Common effects related helpers. | 8 * Common effects related helpers. |
9 */ | 9 */ |
10 class FxUtil { | 10 class FxUtil { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 /** | 62 /** |
63 * Determine the position of an [element] relative to a [target] element. | 63 * Determine the position of an [element] relative to a [target] element. |
64 * Moving the [element] to be a child of [target] and setting the | 64 * Moving the [element] to be a child of [target] and setting the |
65 * [element]'s top and left values to the returned coordinate should result | 65 * [element]'s top and left values to the returned coordinate should result |
66 * in the [element]'s position remaining unchanged while its parent is | 66 * in the [element]'s position remaining unchanged while its parent is |
67 * changed. | 67 * changed. |
68 */ | 68 */ |
69 static Coordinate computeRelativePosition(Element element, Element target) { | 69 static Coordinate computeRelativePosition(Element element, Element target) { |
70 final testPoint = new Point(0, 0); | 70 final testPoint = new Point(0, 0); |
| 71 /* |
71 final pagePoint = | 72 final pagePoint = |
72 window.convertPointFromNodeToPage(element, testPoint); | 73 window.convertPointFromNodeToPage(element, testPoint); |
73 final pointRelativeToTarget = | 74 final pointRelativeToTarget = |
74 window.convertPointFromPageToNode(target, pagePoint); | 75 window.convertPointFromPageToNode(target, pagePoint); |
75 return new Coordinate(pointRelativeToTarget.x, pointRelativeToTarget.y); | 76 return new Coordinate(pointRelativeToTarget.x, pointRelativeToTarget.y); |
| 77 */ |
| 78 // TODO(sra): Test this version that avoids the nonstandard |
| 79 // `convertPointFromPageToNode`. |
| 80 var eRect = element.getBoundingClientRect(); |
| 81 var tRect = target.getBoundingClientRect(); |
| 82 return new Coordinate(eRect.left - tRect.left, eRect.top - tRect.top); |
76 } | 83 } |
77 | 84 |
78 /** Clear a -webkit-transform from an element. */ | 85 /** Clear a -webkit-transform from an element. */ |
79 static void clearWebkitTransform(Element el) { | 86 static void clearWebkitTransform(Element el) { |
80 el.style.transform = ''; | 87 el.style.transform = ''; |
81 } | 88 } |
82 | 89 |
83 /** | 90 /** |
84 * Checks whether an element has a translate3d webkit transform applied. | 91 * Checks whether an element has a translate3d webkit transform applied. |
85 */ | 92 */ |
(...skipping 10 matching lines...) Expand all Loading... |
96 style.left = '${x}px'; | 103 style.left = '${x}px'; |
97 style.top = '${y}px'; | 104 style.top = '${y}px'; |
98 } | 105 } |
99 } | 106 } |
100 | 107 |
101 class TransitionTimingFunction { | 108 class TransitionTimingFunction { |
102 static const EASE_IN = 'ease-in'; | 109 static const EASE_IN = 'ease-in'; |
103 static const EASE_OUT = 'ease-out'; | 110 static const EASE_OUT = 'ease-out'; |
104 static const EASE_IN_OUT = 'ease-in-out'; | 111 static const EASE_IN_OUT = 'ease-in-out'; |
105 } | 112 } |
OLD | NEW |