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

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

Issue 1228233004: Port PopupMenu to the new animation system (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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/animation/timeline.dart » ('j') | sky/sdk/lib/widgets/popup_menu.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 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 double get progress => timeline.value; 53 double get progress => timeline.value;
54 void set progress(double t) { 54 void set progress(double t) {
55 stop(); 55 stop();
56 timeline.value = t.clamp(0.0, 1.0); 56 timeline.value = t.clamp(0.0, 1.0);
57 } 57 }
58 58
59 bool get isDismissed => progress == 0.0; 59 bool get isDismissed => progress == 0.0;
60 bool get isCompleted => progress == 1.0; 60 bool get isCompleted => progress == 1.0;
61 bool get isAnimating => timeline.isAnimating; 61 bool get isAnimating => timeline.isAnimating;
62 62
63 void play() { 63 void play({ Duration delay: Duration.ZERO }) {
64 _animateTo(1.0); 64 _animateTo(1.0, delay: delay);
65 } 65 }
66 void reverse() { 66 void reverse({ Duration delay: Duration.ZERO }) {
67 _animateTo(0.0); 67 _animateTo(0.0, delay: delay);
68 } 68 }
69 69
70 void stop() { 70 void stop() {
71 timeline.stop(); 71 timeline.stop();
72 } 72 }
73 73
74 // Resume animating in a direction, with the given velocity. 74 // Resume animating in a direction, with the given velocity.
75 // TODO(mpcomplete): this should be a force with friction so it slows over 75 // TODO(mpcomplete): this should be a force with friction so it slows over
76 // time. 76 // time.
77 void fling({double velocity: 1.0}) { 77 void fling({double velocity: 1.0}) {
(...skipping 14 matching lines...) Expand all
92 void removeListener(Function listener) { 92 void removeListener(Function listener) {
93 _listeners.remove(listener); 93 _listeners.remove(listener);
94 } 94 }
95 95
96 void _notifyListeners() { 96 void _notifyListeners() {
97 List<Function> localListeners = new List<Function>.from(_listeners); 97 List<Function> localListeners = new List<Function>.from(_listeners);
98 for (Function listener in localListeners) 98 for (Function listener in localListeners)
99 listener(); 99 listener();
100 } 100 }
101 101
102 void _animateTo(double target) { 102 void _animateTo(double target, { Duration delay }) {
103 assert(delay != null);
103 double remainingDistance = (target - timeline.value).abs(); 104 double remainingDistance = (target - timeline.value).abs();
104 timeline.stop(); 105 timeline.stop();
105 if (remainingDistance != 0.0) 106 if (remainingDistance != 0.0) {
106 timeline.animateTo(target, duration: remainingDistance * duration.inMillis econds); 107 timeline.animateTo(target, duration: remainingDistance * duration.inMillis econds,
108 delay: delay.inMilliseconds.toDouble());
109 }
107 } 110 }
108 111
109 void _tick(double t) { 112 void _tick(double t) {
110 variable.setFraction(t); 113 variable.setFraction(t);
111 _notifyListeners(); 114 _notifyListeners();
112 } 115 }
113 } 116 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/animation/timeline.dart » ('j') | sky/sdk/lib/widgets/popup_menu.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698