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

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

Issue 886723002: Add sky-drawer to the framework (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: nit 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
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="Timer" />
7 <script>
8 module.exports = class Controller {
esprehn 2015/01/29 19:03:57 AnimationController ? It'll print nicer in the con
abarth-chromium 2015/01/29 19:16:45 Sure!
9 constructor(delegate) {
10 this.delegate_ = delegate;
11 this.timer_ = new Timer(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

Powered by Google App Engine
This is Rietveld 408576698