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

Unified Diff: sky/framework/animation/animated_value.dart

Issue 1033913002: Menu in StocksApp should animate out (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/examples/stocks-fn/lib/stock_app.dart ('k') | sky/framework/components/popup_menu.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/animated_value.dart
diff --git a/sky/framework/animation/animated_value.dart b/sky/framework/animation/animated_value.dart
index 0db6f90da0302976452fb51998199bffef52f332..11f1dea27197fb3892ee5d9319478a5c3ab8d247 100644
--- a/sky/framework/animation/animated_value.dart
+++ b/sky/framework/animation/animated_value.dart
@@ -10,6 +10,7 @@ import 'generators.dart';
class AnimatedValue {
StreamController _controller = new StreamController(sync: true);
AnimationGenerator _animation;
+ Completer _completer;
double _value;
AnimatedValue(double initial) {
@@ -35,14 +36,23 @@ class AnimatedValue {
_controller.add(_value);
}
+ void _done() {
+ _animation = null;
+ if (_completer == null)
+ return;
+ Completer completer = _completer;
+ _completer = null;
+ completer.complete(_value);
+ }
+
void stop() {
if (_animation != null) {
_animation.cancel();
- _animation = null;
+ _done();
}
}
- void animateTo(double newValue, double duration,
+ Future<double> animateTo(double newValue, double duration,
{ Curve curve: linear, double initialDelay: 0.0 }) {
stop();
@@ -51,10 +61,10 @@ class AnimatedValue {
begin: _value,
end: newValue,
curve: curve,
- initialDelay: initialDelay);
+ initialDelay: initialDelay)
+ ..onTick.listen(_setValue, onDone: _done);
- _animation.onTick.listen(_setValue, onDone: () {
- _animation = null;
- });
+ _completer = new Completer();
+ return _completer.future;
}
}
« no previous file with comments | « sky/examples/stocks-fn/lib/stock_app.dart ('k') | sky/framework/components/popup_menu.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698