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

Unified Diff: sky/sdk/lib/animation/timeline.dart

Issue 1228233004: Port PopupMenu to the new animation system (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 side-by-side diff with in-line comments
Download patch
Index: sky/sdk/lib/animation/timeline.dart
diff --git a/sky/sdk/lib/animation/timeline.dart b/sky/sdk/lib/animation/timeline.dart
index 0d5f3682bf3fa59af5caf6b54e056749a039add2..8b0b43f1dfcaa55cf947e6ece0fe891dd6ac2640 100644
--- a/sky/sdk/lib/animation/timeline.dart
+++ b/sky/sdk/lib/animation/timeline.dart
@@ -80,23 +80,27 @@ class Timeline {
double _duration;
double _begin;
double _end;
+ double _delay;
double _startTime;
Future start({
double duration,
double begin: 0.0,
- double end: 1.0
+ double end: 1.0,
+ double delay: 0.0
}) {
assert(duration != null && duration > 0.0);
assert(begin != null && begin >= 0.0 && begin <= 1.0);
assert(end != null && end >= 0.0 && end <= 1.0);
+ assert(delay != null && delay >= 0.0);
assert(!_ticker.isTicking);
_duration = duration;
_begin = begin;
_end = end;
+ _delay = delay;
_startTime = null;
_value = begin;
@@ -104,14 +108,15 @@ class Timeline {
return _ticker.start();
}
- Future animateTo(double target, { double duration }) {
- return start(duration: duration, begin: _value, end: target);
+ Future animateTo(double target, { double duration, double delay }) {
+ return start(duration: duration, begin: _value, end: target, delay: delay);
}
void stop() {
_duration = null;
_begin = null;
_end = null;
+ _delay = null;
_startTime = null;
_ticker.stop();
}
@@ -122,7 +127,7 @@ class Timeline {
if (_startTime == null)
_startTime = timeStamp;
- final double t = ((timeStamp - _startTime) / _duration).clamp(0.0, 1.0);
+ final double t = ((timeStamp - (_startTime + _delay)) / _duration).clamp(0.0, 1.0);
final bool isLastTick = t >= 1.0;
_value = isLastTick ? _end : _begin + (_end - _begin) * t;

Powered by Google App Engine
This is Rietveld 408576698