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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import 'curves.dart';
6 import 'dart:async';
7 import 'generators.dart';
8
9 class Animation {
10 Stream<double> get onValueChanged => _controller.stream;
11
12 double get value => _value;
13
14 void set value(double value) {
15 stop();
16 _setValue(value);
17 }
18
19 bool get isAnimating => _animation != null;
20
21 StreamController _controller = new StreamController(sync: true);
22
23 AnimationGenerator _animation;
24
25 double _value;
26
27 void _setValue(double value) {
28 _value = value;
29 _controller.add(_value);
30 }
31
32 void stop() {
33 if (_animation != null) {
34 _animation.cancel();
35 _animation = null;
36 }
37 }
38
39 void animateTo(double newValue, double duration,
40 { Curve curve: linear, double initialDelay: 0.0 }) {
41 stop();
42
43 _animation = new AnimationGenerator(
44 duration: duration,
45 begin: _value,
46 end: newValue,
47 curve: curve,
48 initialDelay: initialDelay);
49
50 _animation.onTick.listen(_setValue, onDone: () {
51 _animation = null;
52 });
53 }
54 }
OLDNEW
« 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