Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: third_party/pkg/angular/lib/animate/animations.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 part of angular.animate;
2
3 /**
4 * A [LoopedAnimation] is used with the [AnimationLoop] to drive window
5 * animation frame animations. This provides hooks for dom reads and updates so
6 * that they can be batched together to prevent excessive dom recalculations
7 * when running multiple animations.
8 */
9 abstract class LoopedAnimation implements Animation {
10
11 /**
12 * This is used to batch dom read operations to prevent excessive
13 * recalculations when dom is modified.
14 *
15 * [timeInMs] is the time since the last animation frame.
16 */
17 void read(num timeInMs) { }
18
19 /**
20 * Occurs every animation frame. Return false to stop receiving animation
21 * frame updates. Detach will be called after [update] returns false.
22 *
23 * [timeInMs] is the time since the last animation frame.
24 */
25 bool update(num timeInMs) { return false; }
26 }
27
28 /**
29 * This is a proxy class for dealing with a set of elements where the 'same'
30 * or similar animations are being run on them and it's more convenient to have
31 * a merged animation to control and listen to a set of animations.
32 */
33 class AnimationList extends Animation {
34 final List<Animation> _animations;
35 Future<AnimationResult> _onCompleted;
36
37 /**
38 * [OnCompleted] executes once all the OnCompleted futures for each of the
39 * animations completes.
40 *
41 * if every animation returns [AnimationResult.COMPLETED],
42 * [AnimationResult.COMPLETED] will be returned.
43 * if any animation was [AnimationResult.COMPLETED_IGNORED] instead, even if
44 * some animations were completed, [AnimationResult.COMPLETED_IGNORED] will
45 * be returned.
46 * if any animation was [AnimationResult.CANCELED], the result will be
47 * [AnimationResult.CANCELED].
48 */
49 Future<AnimationResult> get onCompleted {
50 if (_onCompleted == null) {
51 _onCompleted = Future.wait(_animations.map((x) => x.onCompleted))
52 .then((results) {
53 var rtrn = AnimationResult.COMPLETED;
54 for (var result in results) {
55 if (result == AnimationResult.CANCELED)
56 return AnimationResult.CANCELED;
57 if (result == AnimationResult.COMPLETED_IGNORED)
58 rtrn = result;
59 }
60 return rtrn;
61 });
62 }
63
64 return _onCompleted;
65 }
66
67 /// track and create a new [Animation] that acts as a proxy to a list of
68 /// existing [Animation]s.
69 AnimationList(this._animations);
70
71 /// For each of the tracked [Animation]s, call complete().
72 void complete() {
73 for (var animation in _animations) {
74 animation.complete();
75 }
76 }
77
78 /// For each of the tracked [Animation]s, call cancel().
79 void cancel() {
80 for (var animation in _animations) {
81 animation.cancel();
82 }
83 }
84 }
85
86 Animation _animationFromList(Iterable<Animation> animations) {
87 if (animations == null) {
88 return new NoOpAnimation();
89 }
90
91 List<Animation> list = animations.toList();
92
93 if (list.length == 0) {
94 return new NoOpAnimation();
95 }
96 if (list.length == 1) {
97 return list.first;
98 }
99 return new AnimationList(list);
100 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/animate/animation_optimizer.dart ('k') | third_party/pkg/angular/lib/animate/css_animate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698