Chromium Code Reviews| 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 typedef void AnimationCallback(num currentTime); | 5 typedef void AnimationCallback(num currentTime); |
| 6 | 6 |
| 7 class CallbackData { | 7 class CallbackData { |
| 8 final AnimationCallback callback; | 8 final AnimationCallback callback; |
| 9 final num minTime; | 9 final num minTime; |
| 10 int id; | 10 int id; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 _safariHackStyle.position = 'absolute'; | 56 _safariHackStyle.position = 'absolute'; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Cancel the pending callback matching the specified [id]. | 61 * Cancel the pending callback matching the specified [id]. |
| 62 * This is not heavily optimized as typically users don't cancel animation | 62 * This is not heavily optimized as typically users don't cancel animation |
| 63 * frames. | 63 * frames. |
| 64 */ | 64 */ |
| 65 void cancelRequestAnimationFrame(int id) { | 65 void cancelRequestAnimationFrame(int id) { |
| 66 _callbacks = _callbacks.where((CallbackData e) => e.id != id); | 66 _callbacks = _callbacks.where((CallbackData e) => e.id != id).toList(); |
|
Lasse Reichstein Nielsen
2012/11/20 11:44:57
We want a mutating method on Collection: removeAll
floitsch
2012/11/28 13:49:38
Agreed. Not sure where, but it is a common task.
| |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Schedule [callback] to execute at the next animation frame that occurs | 70 * Schedule [callback] to execute at the next animation frame that occurs |
| 71 * at or after [minTime]. If [minTime] is not specified, the first available | 71 * at or after [minTime]. If [minTime] is not specified, the first available |
| 72 * animation frame is used. Returns an id that can be used to cancel the | 72 * animation frame is used. Returns an id that can be used to cancel the |
| 73 * pending callback. | 73 * pending callback. |
| 74 */ | 74 */ |
| 75 int requestAnimationFrame(AnimationCallback callback, | 75 int requestAnimationFrame(AnimationCallback callback, |
| 76 [Element element = null, | 76 [Element element = null, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 _frameCount++; | 157 _frameCount++; |
| 158 if (_isMobileSafari) { | 158 if (_isMobileSafari) { |
| 159 // Hack to work around an iOS bug where sometimes animations do not | 159 // Hack to work around an iOS bug where sometimes animations do not |
| 160 // render if only webkit transforms were modified. | 160 // render if only webkit transforms were modified. |
| 161 // TODO(jacobr): find a cleaner workaround. | 161 // TODO(jacobr): find a cleaner workaround. |
| 162 int offset = _frameCount % 2; | 162 int offset = _frameCount % 2; |
| 163 _safariHackStyle.left = '${offset}px'; | 163 _safariHackStyle.left = '${offset}px'; |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 } | 166 } |
| OLD | NEW |