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

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

Issue 1132063007: Rationalize Dart mojo and sky package structure (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 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/framework/README.md ('k') | sky/framework/animation/curves.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
deleted file mode 100644
index daba4c70c350dd902c1e5a53e3ea1d37e184ebe2..0000000000000000000000000000000000000000
--- a/sky/framework/animation/animated_value.dart
+++ /dev/null
@@ -1,82 +0,0 @@
-// 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';
-
-typedef void Callback ();
-
-class AnimatedValue {
- StreamController _controller = new StreamController.broadcast(sync: true);
- AnimationGenerator _animation;
- Completer _completer;
- double _value;
-
- AnimatedValue(double initial, { Callback onChange }) {
- _value = initial;
- _onChange = onChange;
- }
- Callback _onChange;
-
- // A stream of change in value from |initial|. The stream does not
- // contain the initial value. Consumers should check the initial value via
- // the |value| accessor.
- Stream<double> get onValueChanged => _controller.stream;
-
- double get value => _value;
-
- void set value(double value) {
- stop();
- _setValue(value);
- }
-
- bool get isAnimating => _animation != null;
-
- void _setValue(double value) {
- _value = value;
- _controller.add(_value);
- if (_onChange != null)
- _onChange();
- }
-
- void _done() {
- _animation = null;
- if (_completer == null)
- return;
- Completer completer = _completer;
- _completer = null;
- completer.complete(_value);
- }
-
- void stop() {
- if (_animation != null) {
- _animation.cancel(); // will call _done() if it isn't already finished
- _done();
- }
- }
-
- Future<double> 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)
- ..onTick.listen(_setValue, onDone: _done);
-
- _completer = new Completer();
- return _completer.future;
- }
-
- double get remainingTime {
- if (_animation == null)
- return 0.0;
- return _animation.remainingTime;
- }
-
-}
« no previous file with comments | « sky/framework/README.md ('k') | sky/framework/animation/curves.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698