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

Side by Side Diff: sky/sdk/lib/animation/animation_performance.dart

Issue 1231893006: Update ink splash to new animation system (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: less final 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 unified diff | Download patch
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/ink_well.dart » ('j') | sky/sdk/lib/widgets/ink_well.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'timeline.dart'; 5 import 'timeline.dart';
6 import 'curves.dart'; 6 import 'curves.dart';
7 7
8 // TODO(mpcomplete): merge this stuff with AnimatedValue somehow. We shouldn't 8 // TODO(mpcomplete): merge this stuff with AnimatedValue somehow. We shouldn't
9 // have 2 different ways to animate values. 9 // have 2 different ways to animate values.
10 abstract class AnimatedVariable { 10 abstract class AnimatedVariable {
11 void setFraction(double t); 11 void setFraction(double t);
12 } 12 }
13 13
14 class AnimatedType<T extends dynamic> extends AnimatedVariable { 14 class AnimatedType<T extends dynamic> extends AnimatedVariable {
15 T value; 15 AnimatedType(this.begin, {this.end, this.curve: linear}) {
16 T begin, end; 16 _value = begin;
17 final Curve curve; 17 }
18 18
19 AnimatedType(this.begin, {this.end, this.curve: linear}) { 19 T begin;
20 value = begin; 20 T end;
21 } 21 Curve curve;
22
23 T _value;
24 T get value => _value;
22 25
23 void setFraction(double t) { 26 void setFraction(double t) {
24 if (end != null) { 27 if (end != null) {
25 // TODO(mpcomplete): Reverse the timeline and curve. 28 // TODO(mpcomplete): Reverse the timeline and curve.
26 value = begin + (end - begin) * curve.transform(t); 29 _value = begin + (end - begin) * curve.transform(t);
27 } 30 }
28 } 31 }
29 } 32 }
30 33
31 // This class manages a "performance" - a collection of values that change 34 // This class manages a "performance" - a collection of values that change
32 // based on a timeline. For example, a performance may handle an animation 35 // based on a timeline. For example, a performance may handle an animation
33 // of a menu opening by sliding and fading in (changing Y value and opacity) 36 // of a menu opening by sliding and fading in (changing Y value and opacity)
34 // over .5 seconds. The performance can move forwards (present) or backwards 37 // over .5 seconds. The performance can move forwards (present) or backwards
35 // (dismiss). A consumer may also take direct control of the timeline by 38 // (dismiss). A consumer may also take direct control of the timeline by
36 // manipulating |progress|, or |fling| the timeline causing a physics-based 39 // manipulating |progress|, or |fling| the timeline causing a physics-based
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 timeline.stop(); 106 timeline.stop();
104 if (remainingDistance != 0.0) 107 if (remainingDistance != 0.0)
105 timeline.animateTo(target, duration: remainingDistance * duration.inMillis econds); 108 timeline.animateTo(target, duration: remainingDistance * duration.inMillis econds);
106 } 109 }
107 110
108 void _tick(double t) { 111 void _tick(double t) {
109 variable.setFraction(t); 112 variable.setFraction(t);
110 _notifyListeners(); 113 _notifyListeners();
111 } 114 }
112 } 115 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/ink_well.dart » ('j') | sky/sdk/lib/widgets/ink_well.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698