Chromium Code Reviews| 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..7bb04d619e16bce5b926769dba596f96dd16a3f5 100644 |
| --- a/chrome/browser/resources/vr_shell/vr_shell_ui_api.js |
| +++ b/chrome/browser/resources/vr_shell/vr_shell_ui_api.js |
| @@ -333,7 +333,7 @@ api.Property = { |
| * @enum {number} |
| * @const |
| */ |
| -api.Easing = { |
| +api.EasingType = { |
| 'LINEAR': 0, |
| 'CUBICBEZIER': 1, |
| 'EASEIN': 2, |
| @@ -341,6 +341,46 @@ api.Easing = { |
| }; |
| /** |
| + * Abstract easing base class. |
| + * @abstract |
|
cjgrant
2017/02/16 14:51:47
Nice! I missed that @abstract exists. Could you
tiborg
2017/02/16 17:30:49
Done. Also added to fill class.
|
| + */ |
| +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, p1y, p2x, p2y) { |
|
mthiesse
2017/02/16 15:12:06
We should provide reasonable defaults for all easi
tiborg
2017/02/16 17:30:49
Makes sense. Done.
|
| + super(api.EasingType.CUBICBEZIER); |
| + this.p1x = p1x; |
| + this.p1y = p1y; |
| + this.p2x = p2x; |
| + this.p2y = p2y; |
| + } |
| +} |
| + |
| +api.InEasing = class extends api.Easing { |
| + constructor(pow) { |
| + super(api.EasingType.EASEIN); |
| + this.pow = pow; |
| + } |
| +} |
| + |
| +api.OutEasing = class extends api.Easing { |
| + constructor(pow) { |
| + super(api.EasingType.EASEOUT); |
| + this.pow = pow; |
| + } |
| +} |
| + |
| +/** |
| * Base animation class. An animation can vary only one object property. |
| * @struct |
| */ |
| @@ -355,7 +395,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 +404,6 @@ api.Animation = class { |
| // Duration of the animation (milliseconds). |
| /** @private {number} */ |
| this.durationMillis = durationMs; |
| - |
| - this.easing.type = api.Easing.LINEAR; |
| } |
| /** |
| @@ -436,6 +474,14 @@ 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; |
| + } |
| }; |
| /** |