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

Side by Side Diff: sky/framework/animation/controller.sky

Issue 942413002: Port sky-drawer to Dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/framework/animation/controller.dart ('k') | sky/framework/animation/curves.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 <!--
2 // Copyright 2015 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 -->
6 <import src="timer.sky" as="AnimationTimer" />
7 <script>
8 module.exports = class AnimationController {
9 constructor(delegate) {
10 this.delegate_ = delegate;
11 this.timer_ = new AnimationTimer(this);
12 this.begin_ = 0;
13 this.end_ = 0;
14 this.curve_ = null;
15 this.isAnimating = false;
16 Object.preventExtensions(this);
17 }
18
19 start(options) {
20 this.begin_ = options.begin;
21 this.end_ = options.end;
22 this.curve_ = options.curve;
23 this.isAnimating = true;
24 this.timer_.start(options.duration);
25 }
26
27 stop() {
28 this.isAnimating = false;
29 this.timer_.stop();
30 }
31
32 positionForTime_(t) {
33 // Explicitly finish animations at |this.end_| in case the curve isn't an
34 // exact numerical transform.
35 if (t == 1)
36 return this.end_;
37 var curvedTime = this.curve_.transform(t);
38 var begin = this.begin_;
39 return begin + (this.end_ - begin) * curvedTime;
40 }
41
42 updateAnimation(t) {
43 this.delegate_.updateAnimation(this.positionForTime_(t));
44 }
45 };
46 </script>
OLDNEW
« no previous file with comments | « sky/framework/animation/controller.dart ('k') | sky/framework/animation/curves.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698