5 is: 'neon-animated-pages',
8 Polymer.IronResizableBehavior,
9 Polymer.IronSelectableBehavior,
10 Polymer.NeonAnimationRunnerBehavior
20 // if true, the initial page selection will also be animated according to its animation config.
21 animateInitialSelection: {
29 '_selectedChanged(selected)'
33 'neon-animation-finish': '_onNeonAnimationFinish'
36 _selectedChanged: function(selected) {
38 var selectedPage = this.selectedItem;
39 var oldPage = this._valueToItem(this._prevSelected) || false;
40 this._prevSelected = selected;
42 // on initial load and if animateInitialSelection is negated, simply display selectedPage.
43 if (!oldPage && !this.animateInitialSelection) {
44 this._completeSelectedChanged();
49 this.animationConfig = [{
50 name: 'opaque-animation',
54 // configure selectedPage animations.
55 if (this.entryAnimation) {
56 this.animationConfig.push({
57 name: this.entryAnimation,
61 if (selectedPage.getAnimationConfig) {
62 this.animationConfig.push({
63 animatable: selectedPage,
69 // configure oldPage animations iff exists.
72 // cancel the currently running animation if one is ongoing.
73 if (oldPage.classList.contains('neon-animating')) {
74 this._squelchNextFinishEvent = true;
75 this.cancelAnimation();
76 this._completeSelectedChanged();
79 // configure the animation.
80 if (this.exitAnimation) {
81 this.animationConfig.push({
82 name: this.exitAnimation,
86 if (oldPage.getAnimationConfig) {
87 this.animationConfig.push({
94 // display the oldPage during the transition.
95 oldPage.classList.add('neon-animating');
98 // display the selectedPage during the transition.
99 selectedPage.classList.add('neon-animating');
101 // actually run the animations.
102 if (this.animationConfig.length > 1) {
104 // on first load, ensure we run animations only after element is attached.
105 if (!this.isAttached) {
106 this.async(function () {
107 this.playAnimation(undefined, {
114 this.playAnimation(undefined, {
121 this._completeSelectedChanged(oldPage, selectedPage);
126 * @param {Object=} oldPage
127 * @param {Object=} selectedPage
129 _completeSelectedChanged: function(oldPage, selectedPage) {
131 selectedPage.classList.remove('neon-animating');
134 oldPage.classList.remove('neon-animating');
136 if (!selectedPage || !oldPage) {
137 var nodes = Polymer.dom(this.$.content).getDistributedNodes();
138 for (var node, index = 0; node = nodes[index]; index++) {
139 node.classList && node.classList.remove('neon-animating');
142 this.async(this._notifyPageResize);
145 _onNeonAnimationFinish: function(event) {
146 if (this._squelchNextFinishEvent) {
147 this._squelchNextFinishEvent = false;
150 this._completeSelectedChanged(event.detail.fromPage, event.detail.toPage);
153 _notifyPageResize: function() {
154 var selectedPage = this.selectedItem;
155 this.resizerShouldNotify = function(element) {
156 return element == selectedPage;