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 /** | 7 /** |
8 * This class has static fields that hold objects that this isolate | 8 * This class has static fields that hold objects that this isolate |
9 * uses to interact with the environment. Which objects are available | 9 * uses to interact with the environment. Which objects are available |
10 * depend on how the isolate was started. In the UI isolate | 10 * depend on how the isolate was started. In the UI isolate |
11 * of the browser, the window object is available. | 11 * of the browser, the window object is available. |
12 */ | 12 */ |
13 class Env { | 13 class Env { |
14 static AnimationScheduler _animationScheduler; | 14 static AnimationScheduler _animationScheduler; |
15 | 15 |
16 /** | 16 /** |
17 * Provides functionality similar to [:window.requestAnimationFrame:] for | 17 * Provides functionality similar to [:window.requestAnimationFrame:] for |
18 * all platforms. [callback] is executed on the next animation frame that | 18 * all platforms. [callback] is executed on the next animation frame that |
19 * occurs at or after [minTime]. If [minTime] is not specified, the first | 19 * occurs at or after [minTime]. If [minTime] is not specified, the first |
20 * available animation frame is used. Returns an id that can be used to | 20 * available animation frame is used. Returns an id that can be used to |
21 * cancel the pending callback. | 21 * cancel the pending callback. |
22 */ | 22 */ |
23 static int requestAnimationFrame(AnimationCallback callback, | 23 static int requestAnimationFrame(AnimationCallback callback, |
24 [Element element = null, | 24 [Element element = null, num minTime = null]) { |
25 num minTime = null]) { | |
26 if (_animationScheduler == null) { | 25 if (_animationScheduler == null) { |
27 _animationScheduler = new AnimationScheduler(); | 26 _animationScheduler = new AnimationScheduler(); |
28 } | 27 } |
29 return _animationScheduler.requestAnimationFrame( | 28 return _animationScheduler.requestAnimationFrame( |
30 callback, element, minTime); | 29 callback, element, minTime); |
31 } | 30 } |
32 | 31 |
33 /** | 32 /** |
34 * Cancel the pending callback callback matching the specified [id]. | 33 * Cancel the pending callback callback matching the specified [id]. |
35 */ | 34 */ |
36 static void cancelRequestAnimationFrame(int id) { | 35 static void cancelRequestAnimationFrame(int id) { |
37 _animationScheduler.cancelRequestAnimationFrame(id); | 36 _animationScheduler.cancelRequestAnimationFrame(id); |
38 } | 37 } |
39 } | 38 } |
40 | 39 |
41 typedef void XMLHttpRequestCompleted(HttpRequest req); | 40 typedef void XMLHttpRequestCompleted(HttpRequest req); |
OLD | NEW |