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

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

Issue 1232403004: Trivial code style changes in animation code. (Closed) Base URL: https://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 'package:sky/animation/timeline.dart'; 5 import 'package:sky/animation/timeline.dart';
6 import 'package:sky/animation/curves.dart'; 6 import 'package:sky/animation/curves.dart';
7 7
8 abstract class AnimatedVariable { 8 abstract class AnimatedVariable {
9 void setFraction(double t); 9 void setFraction(double t);
10 String toString();
10 } 11 }
11 12
12 class AnimatedType<T extends dynamic> extends AnimatedVariable { 13 class AnimatedType<T extends dynamic> extends AnimatedVariable {
13 AnimatedType(this.begin, {this.end, this.curve: linear}) { 14 AnimatedType(this.begin, { this.end, this.curve: linear }) {
14 value = begin; 15 value = begin;
15 } 16 }
16 17
17 T value; 18 T value;
18 T begin; 19 T begin;
19 T end; 20 T end;
20 Curve curve; 21 Curve curve;
21 22
22 void setFraction(double t) { 23 void setFraction(double t) {
23 if (end != null) { 24 if (end != null) {
24 // TODO(mpcomplete): Reverse the timeline and curve. 25 // TODO(mpcomplete): Reverse the timeline and curve.
25 value = begin + (end - begin) * curve.transform(t); 26 value = begin + (end - begin) * curve.transform(t);
26 } 27 }
27 } 28 }
29
30 String toString() => 'AnimatedType(begin=$begin, end=$end, value=$value)';
28 } 31 }
29 32
30 class AnimatedList extends AnimatedVariable { 33 class AnimatedList extends AnimatedVariable {
31 List<AnimatedVariable> variables; 34 List<AnimatedVariable> variables;
32 AnimatedList(this.variables); 35 AnimatedList(this.variables);
33 void setFraction(double t) { 36 void setFraction(double t) {
34 for (AnimatedVariable variable in variables) 37 for (AnimatedVariable variable in variables)
35 variable.setFraction(t); 38 variable.setFraction(t);
36 } 39 }
40 String toString() => 'AnimatedList([$variables])';
37 } 41 }
38 42
39 // This class manages a "performance" - a collection of values that change 43 // This class manages a "performance" - a collection of values that change
40 // based on a timeline. For example, a performance may handle an animation 44 // based on a timeline. For example, a performance may handle an animation
41 // of a menu opening by sliding and fading in (changing Y value and opacity) 45 // of a menu opening by sliding and fading in (changing Y value and opacity)
42 // over .5 seconds. The performance can move forwards (present) or backwards 46 // over .5 seconds. The performance can move forwards (present) or backwards
43 // (dismiss). A consumer may also take direct control of the timeline by 47 // (dismiss). A consumer may also take direct control of the timeline by
44 // manipulating |progress|, or |fling| the timeline causing a physics-based 48 // manipulating |progress|, or |fling| the timeline causing a physics-based
45 // simulation to take over the progression. 49 // simulation to take over the progression.
46 class AnimationPerformance { 50 class AnimationPerformance {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 timeline.stop(); 115 timeline.stop();
112 if (remainingDistance != 0.0) 116 if (remainingDistance != 0.0)
113 timeline.animateTo(target, duration: remainingDistance * duration.inMillis econds); 117 timeline.animateTo(target, duration: remainingDistance * duration.inMillis econds);
114 } 118 }
115 119
116 void _tick(double t) { 120 void _tick(double t) {
117 variable.setFraction(t); 121 variable.setFraction(t);
118 _notifyListeners(); 122 _notifyListeners();
119 } 123 }
120 } 124 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/animation_builder.dart » ('j') | sky/sdk/lib/widgets/animation_builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698