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

Side by Side Diff: chrome/browser/resources/md_extensions/animation_helper.js

Issue 2960293002: MD Extensions: Convert classes to use ES6 class syntax. (Closed)
Patch Set: Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/md_extensions/manager.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.exportPath('extensions'); 5 cr.exportPath('extensions');
6 6
7 /** 7 /**
8 * The different types of animations this helper supports. 8 * The different types of animations this helper supports.
9 * @enum {number} 9 * @enum {number}
10 */ 10 */
11 extensions.Animation = { 11 extensions.Animation = {
12 HERO: 0, 12 HERO: 0,
13 FADE_IN: 1, 13 FADE_IN: 1,
14 FADE_OUT: 2, 14 FADE_OUT: 2,
15 SCALE_DOWN: 3, 15 SCALE_DOWN: 3,
16 }; 16 };
17 17
18 cr.define('extensions', function() { 18 cr.define('extensions', function() {
19 'use strict'; 19 'use strict';
20 20
21 /** 21 /**
22 * A helper object for setting entry/exit animations. Polymer's support of 22 * A helper object for setting entry/exit animations. Polymer's support of
23 * this is pretty limited, since it doesn't allow for things like specifying 23 * this is pretty limited, since it doesn't allow for things like specifying
24 * hero properties or nodes. 24 * hero properties or nodes.
25 * @param {!HTMLElement} element The parent element to set the animations on.
26 * This will be used as the page in to/fromPage.
27 * @param {?HTMLElement} node The node to use for scaling and fading
28 * animations.
29 * @constructor
30 */ 25 */
31 function AnimationHelper(element, node) { 26 class AnimationHelper {
32 this.element_ = element; 27 /**
33 this.node_ = node; 28 * @param {!HTMLElement} element The parent element to set the animations
34 element.animationConfig = {}; 29 * on. This will be used as the page in to/fromPage.
35 } 30 * @param {?HTMLElement} node The node to use for scaling and fading
31 * animations.
32 */
33 constructor(element, node) {
34 this.element_ = element;
35 this.node_ = node;
36 element.animationConfig = {};
37 }
36 38
37 AnimationHelper.prototype = {
38 /** 39 /**
39 * Set the entry animation for the element. 40 * Set the entry animation for the element.
40 * @param {!Array<extensions.Animation>} animations 41 * @param {!Array<extensions.Animation>} animations
41 */ 42 */
42 setEntryAnimations: function(animations) { 43 setEntryAnimations(animations) {
43 var configs = []; 44 var configs = [];
44 for (let animation of animations) { 45 for (let animation of animations) {
45 switch (animation) { 46 switch (animation) {
46 case extensions.Animation.HERO: 47 case extensions.Animation.HERO:
47 configs.push( 48 configs.push(
48 {name: 'hero-animation', id: 'hero', toPage: this.element_}); 49 {name: 'hero-animation', id: 'hero', toPage: this.element_});
49 break; 50 break;
50 case extensions.Animation.FADE_IN: 51 case extensions.Animation.FADE_IN:
51 assert(this.node_); 52 assert(this.node_);
52 configs.push({name: 'fade-in-animation', node: this.node_}); 53 configs.push({name: 'fade-in-animation', node: this.node_});
53 break; 54 break;
54 default: 55 default:
55 assertNotReached(); 56 assertNotReached();
56 } 57 }
57 } 58 }
58 this.element_.animationConfig.entry = configs; 59 this.element_.animationConfig.entry = configs;
59 }, 60 }
60 61
61 /** 62 /**
62 * Set the exit animation for the element. 63 * Set the exit animation for the element.
63 * @param {!Array<extensions.Animation>} animations 64 * @param {!Array<extensions.Animation>} animations
64 */ 65 */
65 setExitAnimations: function(animations) { 66 setExitAnimations(animations) {
66 var configs = []; 67 var configs = [];
67 for (let animation of animations) { 68 for (let animation of animations) {
68 switch (animation) { 69 switch (animation) {
69 case extensions.Animation.HERO: 70 case extensions.Animation.HERO:
70 configs.push( 71 configs.push(
71 {name: 'hero-animation', id: 'hero', fromPage: this.element_}); 72 {name: 'hero-animation', id: 'hero', fromPage: this.element_});
72 break; 73 break;
73 case extensions.Animation.FADE_OUT: 74 case extensions.Animation.FADE_OUT:
74 assert(this.node_); 75 assert(this.node_);
75 configs.push({name: 'fade-out-animation', node: this.node_}); 76 configs.push({name: 'fade-out-animation', node: this.node_});
76 break; 77 break;
77 case extensions.Animation.SCALE_DOWN: 78 case extensions.Animation.SCALE_DOWN:
78 assert(this.node_); 79 assert(this.node_);
79 configs.push({ 80 configs.push({
80 name: 'scale-down-animation', 81 name: 'scale-down-animation',
81 node: this.node_, 82 node: this.node_,
82 transformOrigin: '50% 50%', 83 transformOrigin: '50% 50%',
83 axis: 'y', 84 axis: 'y',
84 }); 85 });
85 break; 86 break;
86 default: 87 default:
87 assertNotReached(); 88 assertNotReached();
88 } 89 }
89 } 90 }
90 this.element_.animationConfig.exit = configs; 91 this.element_.animationConfig.exit = configs;
91 }, 92 }
92 }; 93 }
93 94
94 return {AnimationHelper: AnimationHelper}; 95 return {AnimationHelper: AnimationHelper};
95 }); 96 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_extensions/manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698