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

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

Issue 1001373002: Organize sky/framework/animation (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/stocksapp.dart ('k') | sky/framework/animation/controller.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/animation.dart
diff --git a/sky/framework/animation/animation.dart b/sky/framework/animation/animation.dart
new file mode 100644
index 0000000000000000000000000000000000000000..62b93f676388819dabbb3c8079d9851942e010ff
--- /dev/null
+++ b/sky/framework/animation/animation.dart
@@ -0,0 +1,54 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'curves.dart';
+import 'dart:async';
+import 'generators.dart';
+
+class Animation {
+ Stream<double> get onValueChanged => _controller.stream;
+
+ double get value => _value;
+
+ void set value(double value) {
+ stop();
+ _setValue(value);
+ }
+
+ bool get isAnimating => _animation != null;
+
+ StreamController _controller = new StreamController(sync: true);
+
+ AnimationGenerator _animation;
+
+ double _value;
+
+ void _setValue(double value) {
+ _value = value;
+ _controller.add(_value);
+ }
+
+ void stop() {
+ if (_animation != null) {
+ _animation.cancel();
+ _animation = null;
+ }
+ }
+
+ void animateTo(double newValue, double duration,
+ { Curve curve: linear, double initialDelay: 0.0 }) {
+ stop();
+
+ _animation = new AnimationGenerator(
+ duration: duration,
+ begin: _value,
+ end: newValue,
+ curve: curve,
+ initialDelay: initialDelay);
+
+ _animation.onTick.listen(_setValue, onDone: () {
+ _animation = null;
+ });
+ }
+}
« no previous file with comments | « sky/examples/stocks-fn/stocksapp.dart ('k') | sky/framework/animation/controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698