| OLD | NEW |
| 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 String toString(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 value = begin + (end - begin) * curve.transform(adjustedTime); | 47 value = begin + (end - begin) * curve.transform(adjustedTime); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 String toString() => 'AnimatedType(begin=$begin, end=$end, value=$value)'; | 52 String toString() => 'AnimatedType(begin=$begin, end=$end, value=$value)'; |
| 53 } | 53 } |
| 54 | 54 |
| 55 class AnimatedList extends AnimatedVariable { | 55 class AnimatedList extends AnimatedVariable { |
| 56 List<AnimatedVariable> variables; | 56 List<AnimatedVariable> variables; |
| 57 AnimatedList(this.variables); | 57 Interval interval; |
| 58 |
| 59 AnimatedList(this.variables, { this.interval }); |
| 60 |
| 58 void setFraction(double t) { | 61 void setFraction(double t) { |
| 62 double adjustedTime = interval == null ? t : interval.adjustTime(t); |
| 59 for (AnimatedVariable variable in variables) | 63 for (AnimatedVariable variable in variables) |
| 60 variable.setFraction(t); | 64 variable.setFraction(adjustedTime); |
| 61 } | 65 } |
| 66 |
| 62 String toString() => 'AnimatedList([$variables])'; | 67 String toString() => 'AnimatedList([$variables])'; |
| 63 } | 68 } |
| 64 | 69 |
| 65 // This class manages a "performance" - a collection of values that change | 70 // This class manages a "performance" - a collection of values that change |
| 66 // based on a timeline. For example, a performance may handle an animation | 71 // based on a timeline. For example, a performance may handle an animation |
| 67 // of a menu opening by sliding and fading in (changing Y value and opacity) | 72 // of a menu opening by sliding and fading in (changing Y value and opacity) |
| 68 // over .5 seconds. The performance can move forwards (present) or backwards | 73 // over .5 seconds. The performance can move forwards (present) or backwards |
| 69 // (dismiss). A consumer may also take direct control of the timeline by | 74 // (dismiss). A consumer may also take direct control of the timeline by |
| 70 // manipulating |progress|, or |fling| the timeline causing a physics-based | 75 // manipulating |progress|, or |fling| the timeline causing a physics-based |
| 71 // simulation to take over the progression. | 76 // simulation to take over the progression. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 timeline.stop(); | 142 timeline.stop(); |
| 138 if (remainingDistance != 0.0) | 143 if (remainingDistance != 0.0) |
| 139 timeline.animateTo(target, duration: remainingDistance * duration.inMillis
econds); | 144 timeline.animateTo(target, duration: remainingDistance * duration.inMillis
econds); |
| 140 } | 145 } |
| 141 | 146 |
| 142 void _tick(double t) { | 147 void _tick(double t) { |
| 143 variable.setFraction(t); | 148 variable.setFraction(t); |
| 144 _notifyListeners(); | 149 _notifyListeners(); |
| 145 } | 150 } |
| 146 } | 151 } |
| OLD | NEW |