OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @fileoverview | |
7 * Transitions are cancellable asynchronous state changes. A transition may | |
8 * compose web animations and other Transitions to manage a set of animations. | |
9 * Similar to Promises, they can initiate tasks after completion or | |
10 * cancellation. | |
11 */ | |
12 cr.define('settings.animation', function() { | |
13 'use strict'; | |
14 | |
15 /** | |
16 * Base class for modular implementations of asynchronous transitions using | |
17 * web animations. | |
18 * @constructor | |
19 */ | |
20 function Transition() {} | |
21 | |
22 Transition.prototype = { | |
23 /** | |
24 * If the transition is still playing, immediately finishes it and resolves | |
25 * |finished|. | |
26 */ | |
27 finish: assertNotReached, | |
28 | |
29 /** | |
30 * If the transition is still playing, immediately cancels it and rejects | |
31 * |finished|. | |
32 */ | |
33 cancel: assertNotReached, | |
34 | |
35 /** | |
36 * Sets up the transition. | |
37 * @protected | |
38 */ | |
39 setUp: function() { | |
40 var cleanUp = this.cleanUp.bind(this); | |
41 this.finished.then(cleanUp, cleanUp); | |
42 }, | |
43 | |
44 /** | |
45 * Clears any temporary effects of the transition. | |
46 * @protected | |
47 */ | |
48 cleanUp: function() {}, | |
49 | |
50 /** @type {Promise} */ | |
51 finished: null, | |
52 }; | |
53 | |
54 /** | |
55 * Base class for instantaneous (non-animated) transitions. | |
56 * @constructor | |
57 * @extends {settings.animation.Transition} | |
58 */ | |
59 function ImmediateTransition() {} | |
Dan Beam
2016/06/17 19:22:42
i don't like this design.
the name seems like an
Dan Beam
2016/06/20 23:28:03
if you want to talk about this in a more active me
michaelpg
2016/06/28 23:17:23
I've removed this, it hasn't been useful yet.
| |
60 | |
61 // ImmediateTransitions do no work outside the constructor. | |
62 ImmediateTransition.prototype = { | |
63 __proto__: Transition.prototype, | |
64 | |
65 /** @final */ finish: function() {}, | |
66 /** @final */ cancel: function() {}, | |
67 | |
68 /** @final */ | |
69 finished: Promise.resolve(), | |
70 }; | |
71 | |
72 return { | |
73 Transition: Transition, | |
74 ImmediateTransition: ImmediateTransition, | |
75 }; | |
76 }); | |
OLD | NEW |