| 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 base; | 5 part of base; |
| 6 | 6 |
| 7 typedef void AnimationCallback(num currentTime); | 7 typedef void AnimationCallback(num currentTime); |
| 8 | 8 |
| 9 class CallbackData { | 9 class CallbackData { |
| 10 final AnimationCallback callback; | 10 final AnimationCallback callback; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 _safariHackStyle.position = 'absolute'; | 58 _safariHackStyle.position = 'absolute'; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Cancel the pending callback matching the specified [id]. | 63 * Cancel the pending callback matching the specified [id]. |
| 64 * This is not heavily optimized as typically users don't cancel animation | 64 * This is not heavily optimized as typically users don't cancel animation |
| 65 * frames. | 65 * frames. |
| 66 */ | 66 */ |
| 67 void cancelRequestAnimationFrame(int id) { | 67 void cancelRequestAnimationFrame(int id) { |
| 68 _callbacks = _callbacks.filter((CallbackData e) => e.id != id); | 68 _callbacks = _callbacks.where((CallbackData e) => e.id != id).toList(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * Schedule [callback] to execute at the next animation frame that occurs | 72 * Schedule [callback] to execute at the next animation frame that occurs |
| 73 * at or after [minTime]. If [minTime] is not specified, the first available | 73 * at or after [minTime]. If [minTime] is not specified, the first available |
| 74 * animation frame is used. Returns an id that can be used to cancel the | 74 * animation frame is used. Returns an id that can be used to cancel the |
| 75 * pending callback. | 75 * pending callback. |
| 76 */ | 76 */ |
| 77 int requestAnimationFrame(AnimationCallback callback, | 77 int requestAnimationFrame(AnimationCallback callback, |
| 78 [Element element = null, | 78 [Element element = null, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 _frameCount++; | 159 _frameCount++; |
| 160 if (_isMobileSafari) { | 160 if (_isMobileSafari) { |
| 161 // Hack to work around an iOS bug where sometimes animations do not | 161 // Hack to work around an iOS bug where sometimes animations do not |
| 162 // render if only webkit transforms were modified. | 162 // render if only webkit transforms were modified. |
| 163 // TODO(jacobr): find a cleaner workaround. | 163 // TODO(jacobr): find a cleaner workaround. |
| 164 int offset = _frameCount % 2; | 164 int offset = _frameCount % 2; |
| 165 _safariHackStyle.left = '${offset}px'; | 165 _safariHackStyle.left = '${offset}px'; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 } | 168 } |
| OLD | NEW |