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

Unified Diff: chrome/browser/resources/settings/animation/transition.js

Issue 2072643002: MD Settings: animation interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
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,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698