| 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 'curves.dart'; | 5 import 'curves.dart'; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
| 9 import 'mechanics.dart'; | 9 import 'mechanics.dart'; |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 bool _done = false; | 70 bool _done = false; |
| 71 | 71 |
| 72 AnimationGenerator({ | 72 AnimationGenerator({ |
| 73 this.initialDelay: 0.0, | 73 this.initialDelay: 0.0, |
| 74 this.duration, | 74 this.duration, |
| 75 this.begin: 0.0, | 75 this.begin: 0.0, |
| 76 this.end: 1.0, | 76 this.end: 1.0, |
| 77 this.curve: linear, | 77 this.curve: linear, |
| 78 Function onDone | 78 Function onDone |
| 79 }) { | 79 }) { |
| 80 assert(curve != null); |
| 80 assert(duration != null && duration > 0.0); | 81 assert(duration != null && duration > 0.0); |
| 81 _generator = new FrameGenerator(onDone: onDone); | 82 _generator = new FrameGenerator(onDone: onDone); |
| 82 | 83 |
| 83 double startTime = 0.0; | 84 double startTime = 0.0; |
| 84 _stream = _generator.onTick.map((timeStamp) { | 85 _stream = _generator.onTick.map((timeStamp) { |
| 85 if (startTime == 0.0) | 86 if (startTime == 0.0) |
| 86 startTime = timeStamp; | 87 startTime = timeStamp; |
| 87 | 88 |
| 88 double t = (timeStamp - (startTime + initialDelay)) / duration; | 89 double t = (timeStamp - (startTime + initialDelay)) / duration; |
| 89 return math.max(0.0, math.min(t, 1.0)); | 90 return math.max(0.0, math.min(t, 1.0)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 double _update(double timeStamp) { | 144 double _update(double timeStamp) { |
| 144 double previousTime = _previousTime; | 145 double previousTime = _previousTime; |
| 145 _previousTime = timeStamp; | 146 _previousTime = timeStamp; |
| 146 if (previousTime == 0.0) | 147 if (previousTime == 0.0) |
| 147 return timeStamp; | 148 return timeStamp; |
| 148 double deltaT = timeStamp - previousTime; | 149 double deltaT = timeStamp - previousTime; |
| 149 system.update(deltaT); | 150 system.update(deltaT); |
| 150 return timeStamp; | 151 return timeStamp; |
| 151 } | 152 } |
| 152 } | 153 } |
| OLD | NEW |