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

Side by Side Diff: sky/framework/animation/generator.dart

Issue 980043005: fix the hang when clicking the drawer in the stocks app (Closed) Base URL: https://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/fn/widgets/drawer.dart ('k') | no next file » | no next file with comments »
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 'curves.dart'; 5 import 'curves.dart';
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
9 9
10 class FrameGenerator { 10 class FrameGenerator {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 final Curve curve; 59 final Curve curve;
60 Stream<double> _stream; 60 Stream<double> _stream;
61 bool _done = false; 61 bool _done = false;
62 62
63 AnimationGenerator(this.duration, { 63 AnimationGenerator(this.duration, {
64 this.begin: 0.0, 64 this.begin: 0.0,
65 this.end: 1.0, 65 this.end: 1.0,
66 this.curve: linear, 66 this.curve: linear,
67 Function onDone 67 Function onDone
68 }):super(onDone: onDone) { 68 }):super(onDone: onDone) {
69 assert(duration > 0);
69 double startTime = 0.0; 70 double startTime = 0.0;
70 _stream = super.onTick.map((timeStamp) { 71 _stream = super.onTick.map((timeStamp) {
71 if (startTime == 0.0) 72 if (startTime == 0.0)
72 startTime = timeStamp; 73 startTime = timeStamp;
73 return math.min((timeStamp - startTime) / duration, 1.0); 74 return math.min((timeStamp - startTime) / duration, 1.0);
74 }) 75 })
75 .takeWhile(_checkForCompletion) 76 .takeWhile(_checkForCompletion)
76 .map((t) => begin + (end - begin) * curve.transform(t)); 77 .map((t) => begin + (end - begin) * curve.transform(t));
77 } 78 }
78 79
79 bool _checkForCompletion(double t) { 80 bool _checkForCompletion(double t) {
80 if (_done) 81 if (_done)
81 return false; 82 return false;
82 _done = t >= 1; 83 _done = t >= 1;
83 return true; 84 return true;
84 } 85 }
85 } 86 }
OLDNEW
« no previous file with comments | « sky/examples/fn/widgets/drawer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698