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

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

Issue 999423004: Drive overscroll animations with a physics simulation (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: More comments 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 | « no previous file | sky/framework/animation/kinematics.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/generator.dart
diff --git a/sky/framework/animation/generator.dart b/sky/framework/animation/generator.dart
index 065d1e5f65601bc8ebb36364f4b27f99529569fb..7530f04a4ad3ae4af94d2219d400f9cec38cc9e5 100644
--- a/sky/framework/animation/generator.dart
+++ b/sky/framework/animation/generator.dart
@@ -51,13 +51,15 @@ class FrameGenerator {
}
}
-class AnimationGenerator extends FrameGenerator {
+class AnimationGenerator {
Stream<double> get onTick => _stream;
final double initialDelay;
final double duration;
final double begin;
final double end;
final Curve curve;
+
+ FrameGenerator _generator;
Stream<double> _stream;
bool _done = false;
@@ -68,21 +70,27 @@ class AnimationGenerator extends FrameGenerator {
this.end: 1.0,
this.curve: linear,
Function onDone
- }):super(onDone: onDone) {
+ }) {
assert(duration != null && duration > 0.0);
+ _generator = new FrameGenerator(onDone: onDone);
+
double startTime = 0.0;
- _stream = super.onTick.map((timeStamp) {
+ _stream = _generator.onTick.map((timeStamp) {
if (startTime == 0.0)
startTime = timeStamp;
double t = (timeStamp - (startTime + initialDelay)) / duration;
return math.max(0.0, math.min(t, 1.0));
})
- .takeWhile(_checkForCompletion) //
+ .takeWhile(_checkForCompletion)
.where((t) => t >= 0.0)
.map(_transform);
}
+ void cancel() {
+ _generator.cancel();
+ }
+
double _transform(double t) {
if (_done)
return end;
« no previous file with comments | « no previous file | sky/framework/animation/kinematics.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698