6 is
: 'neon-animated-pages',
9 Polymer
.IronResizableBehavior
,
10 Polymer
.IronSelectableBehavior
,
11 Polymer
.NeonAnimationRunnerBehavior
21 // if true, the initial page selection will also be animated according to its animation config.
22 animateInitialSelection
: {
30 '_selectedChanged(selected)'
34 'neon-animation-finish': '_onNeonAnimationFinish'
37 _selectedChanged: function(selected
) {
39 var selectedPage
= this.selectedItem
;
40 var oldPage
= this._valueToItem(this._prevSelected
) || false;
41 this._prevSelected
= selected
;
43 // on initial load and if animateInitialSelection is negated, simply display selectedPage.
44 if (!oldPage
&& !this.animateInitialSelection
) {
45 this._completeSelectedChanged();
50 this.animationConfig
= [{
51 name
: 'opaque-animation',
55 // configure selectedPage animations.
56 if (this.entryAnimation
) {
57 this.animationConfig
.push({
58 name
: this.entryAnimation
,
62 if (selectedPage
.getAnimationConfig
) {
63 this.animationConfig
.push({
64 animatable
: selectedPage
,
70 // configure oldPage animations iff exists.
73 // cancel the currently running animation if one is ongoing.
74 if (oldPage
.classList
.contains('neon-animating')) {
75 this._squelchNextFinishEvent
= true;
76 this.cancelAnimation();
77 this._completeSelectedChanged();
80 // configure the animation.
81 if (this.exitAnimation
) {
82 this.animationConfig
.push({
83 name
: this.exitAnimation
,
87 if (oldPage
.getAnimationConfig
) {
88 this.animationConfig
.push({
95 // display the oldPage during the transition.
96 oldPage
.classList
.add('neon-animating');
99 // display the selectedPage during the transition.
100 selectedPage
.classList
.add('neon-animating');
102 // actually run the animations.
103 if (this.animationConfig
.length
> 1) {
105 // on first load, ensure we run animations only after element is attached.
106 if (!this.isAttached
) {
107 this.async(function () {
108 this.playAnimation(undefined, {
115 this.playAnimation(undefined, {
122 this._completeSelectedChanged(oldPage
, selectedPage
);
127 * @param {Object=} oldPage
128 * @param {Object=} selectedPage
130 _completeSelectedChanged: function(oldPage
, selectedPage
) {
132 selectedPage
.classList
.remove('neon-animating');
135 oldPage
.classList
.remove('neon-animating');
137 if (!selectedPage
|| !oldPage
) {
138 var nodes
= Polymer
.dom(this.$.content
).getDistributedNodes();
139 for (var node
, index
= 0; node
= nodes
[index
]; index
++) {
140 node
.classList
&& node
.classList
.remove('neon-animating');
143 this.async(this._notifyPageResize
);
146 _onNeonAnimationFinish: function(event
) {
147 if (this._squelchNextFinishEvent
) {
148 this._squelchNextFinishEvent
= false;
151 this._completeSelectedChanged(event
.detail
.fromPage
, event
.detail
.toPage
);
154 _notifyPageResize: function() {
155 var selectedPage
= this.selectedItem
;
156 this.resizerShouldNotify = function(element
) {
157 return element
== selectedPage
;