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

Side by Side Diff: sky/sdk/lib/animation/animation_performance.dart

Issue 1231933006: Use AnimatedContainer for card_collection.dart. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'timeline.dart'; 5 import 'timeline.dart';
6 import 'curves.dart'; 6 import 'curves.dart';
7 7
8 // TODO(mpcomplete): merge this stuff with AnimatedValue somehow. We shouldn't 8 // TODO(mpcomplete): merge this stuff with AnimatedValue somehow. We shouldn't
9 // have 2 different ways to animate values. 9 // have 2 different ways to animate values.
10 abstract class AnimatedVariable { 10 abstract class AnimatedVariable {
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 void setFraction(double t) { 23 void setFraction(double t) {
24 if (end != null) { 24 if (end != null) {
25 // TODO(mpcomplete): Reverse the timeline and curve. 25 // TODO(mpcomplete): Reverse the timeline and curve.
26 value = begin + (end - begin) * curve.transform(t); 26 value = begin + (end - begin) * curve.transform(t);
27 } 27 }
28 } 28 }
29 } 29 }
30 30
31 class AnimatedList extends AnimatedVariable {
32 List<AnimatedVariable> variables;
33 AnimatedList(this.variables);
34 void setFraction(double t) {
35 for (AnimatedVariable variable in variables)
36 variable.setFraction(t);
37 }
38 }
39
31 // This class manages a "performance" - a collection of values that change 40 // This class manages a "performance" - a collection of values that change
32 // based on a timeline. For example, a performance may handle an animation 41 // based on a timeline. For example, a performance may handle an animation
33 // of a menu opening by sliding and fading in (changing Y value and opacity) 42 // of a menu opening by sliding and fading in (changing Y value and opacity)
34 // over .5 seconds. The performance can move forwards (present) or backwards 43 // over .5 seconds. The performance can move forwards (present) or backwards
35 // (dismiss). A consumer may also take direct control of the timeline by 44 // (dismiss). A consumer may also take direct control of the timeline by
36 // manipulating |progress|, or |fling| the timeline causing a physics-based 45 // manipulating |progress|, or |fling| the timeline causing a physics-based
37 // simulation to take over the progression. 46 // simulation to take over the progression.
38 class AnimationPerformance { 47 class AnimationPerformance {
39 AnimationPerformance() { 48 AnimationPerformance() {
40 _timeline = new Timeline(_tick); 49 _timeline = new Timeline(_tick);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 timeline.stop(); 112 timeline.stop();
104 if (remainingDistance != 0.0) 113 if (remainingDistance != 0.0)
105 timeline.animateTo(target, duration: remainingDistance * duration.inMillis econds); 114 timeline.animateTo(target, duration: remainingDistance * duration.inMillis econds);
106 } 115 }
107 116
108 void _tick(double t) { 117 void _tick(double t) {
109 variable.setFraction(t); 118 variable.setFraction(t);
110 _notifyListeners(); 119 _notifyListeners();
111 } 120 }
112 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698