Chromium Code Reviews| Index: chrome/browser/resources/settings/animation/transition.js |
| diff --git a/chrome/browser/resources/settings/animation/transition.js b/chrome/browser/resources/settings/animation/transition.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2c7f6cf79471d2e160051be401b99be47c242965 |
| --- /dev/null |
| +++ b/chrome/browser/resources/settings/animation/transition.js |
| @@ -0,0 +1,76 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @fileoverview |
| + * Transitions are cancellable asynchronous state changes. A transition may |
| + * compose web animations and other Transitions to manage a set of animations. |
| + * Similar to Promises, they can initiate tasks after completion or |
| + * cancellation. |
| + */ |
| +cr.define('settings.animation', function() { |
| + 'use strict'; |
| + |
| + /** |
| + * Base class for modular implementations of asynchronous transitions using |
| + * web animations. |
| + * @constructor |
| + */ |
| + function Transition() {} |
| + |
| + Transition.prototype = { |
| + /** |
| + * If the transition is still playing, immediately finishes it and resolves |
| + * |finished|. |
| + */ |
| + finish: assertNotReached, |
| + |
| + /** |
| + * If the transition is still playing, immediately cancels it and rejects |
| + * |finished|. |
| + */ |
| + cancel: assertNotReached, |
| + |
| + /** |
| + * Sets up the transition. |
| + * @protected |
| + */ |
| + setUp: function() { |
| + var cleanUp = this.cleanUp.bind(this); |
| + this.finished.then(cleanUp, cleanUp); |
| + }, |
| + |
| + /** |
| + * Clears any temporary effects of the transition. |
| + * @protected |
| + */ |
| + cleanUp: function() {}, |
| + |
| + /** @type {Promise} */ |
| + finished: null, |
| + }; |
| + |
| + /** |
| + * Base class for instantaneous (non-animated) transitions. |
| + * @constructor |
| + * @extends {settings.animation.Transition} |
| + */ |
| + 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.
|
| + |
| + // ImmediateTransitions do no work outside the constructor. |
| + ImmediateTransition.prototype = { |
| + __proto__: Transition.prototype, |
| + |
| + /** @final */ finish: function() {}, |
| + /** @final */ cancel: function() {}, |
| + |
| + /** @final */ |
| + finished: Promise.resolve(), |
| + }; |
| + |
| + return { |
| + Transition: Transition, |
| + ImmediateTransition: ImmediateTransition, |
| + }; |
| +}); |