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

Unified Diff: chrome/browser/resources/vr_shell/vr_shell_ui_api.js

Issue 2696273002: Can more conveniently set easing from JS. (Closed)
Patch Set: Added defaults, added @abstract, removed animation Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/vr_shell/vr_shell_ui_api.js
diff --git a/chrome/browser/resources/vr_shell/vr_shell_ui_api.js b/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
index 4bbb4830b5fba55947d6a859c79fb71feb8ade7b..91a6bea3d7ce3be482a1ab043729f93ebc2cdac2 100644
--- a/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
+++ b/chrome/browser/resources/vr_shell/vr_shell_ui_api.js
@@ -128,6 +128,10 @@ api.FillType = {
'CONTENT': 4
};
+/**
+ * Abstract fill base class.
+ * @abstract
+ */
api.Fill = class {
constructor(type) {
this.properties = {};
@@ -333,13 +337,63 @@ api.Property = {
* @enum {number}
* @const
*/
-api.Easing = {
+api.EasingType = {
'LINEAR': 0,
'CUBICBEZIER': 1,
'EASEIN': 2,
'EASEOUT': 3
};
+/** @const */ var DEFAULT_EASING_POW = 2;
+/** @const */ var DEFAULT_CUBIC_BEZIER_P1X = 0.25;
+/** @const */ var DEFAULT_CUBIC_BEZIER_P1Y = 0;
+/** @const */ var DEFAULT_CUBIC_BEZIER_P2X = 0.75;
+/** @const */ var DEFAULT_CUBIC_BEZIER_P2Y = 1;
+
+/**
+ * Abstract easing base class.
+ * @abstract
+ */
+api.Easing = class {
+ constructor(type) {
+ this.type = type;
+ }
+}
+
+api.LinearEasing = class extends api.Easing {
+ constructor() {
+ super(api.EasingType.LINEAR);
+ }
+}
+
+api.CubicBezierEasing = class extends api.Easing {
+ constructor(
+ p1x = DEFAULT_CUBIC_BEZIER_P1X,
+ p1y = DEFAULT_CUBIC_BEZIER_P1Y,
+ p2x = DEFAULT_CUBIC_BEZIER_P2X,
+ p2y = DEFAULT_CUBIC_BEZIER_P2Y) {
+ super(api.EasingType.CUBICBEZIER);
+ this.p1x = p1x;
+ this.p1y = p1y;
+ this.p2x = p2x;
+ this.p2y = p2y;
+ }
+}
+
+api.InEasing = class extends api.Easing {
+ constructor(pow = DEFAULT_EASING_POW) {
+ super(api.EasingType.EASEIN);
+ this.pow = pow;
+ }
+}
+
+api.OutEasing = class extends api.Easing {
+ constructor(pow = DEFAULT_EASING_POW) {
+ super(api.EasingType.EASEOUT);
+ this.pow = pow;
+ }
+}
+
/**
* Base animation class. An animation can vary only one object property.
* @struct
@@ -355,7 +409,7 @@ api.Animation = class {
/** @private {Object} */
this.to = {};
/** @private {Object} */
- this.easing = {};
+ this.easing = new api.LinearEasing();
// How many milliseconds in the future to start the animation.
/** @private {number} */
@@ -364,8 +418,6 @@ api.Animation = class {
// Duration of the animation (milliseconds).
/** @private {number} */
this.durationMillis = durationMs;
-
- this.easing.type = api.Easing.LINEAR;
}
/**
@@ -436,11 +488,20 @@ api.Animation = class {
this.property = api.Property.OPACITY;
this.to.x = opacity;
}
+
+ /**
+ * Set the animation's easing.
+ * @param {api.Easing} easing
+ */
+ setEasing(easing) {
+ this.easing = easing;
+ }
};
/**
* Abstract class handling webui command calls from native. The UI must
* subclass this and override the handlers.
+ * @abstract
*/
api.NativeCommandHandler = class {
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698