| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Upon scrolling past a threshold, fade in the rear background layer and fade
out the front | 2 * Upon scrolling past a threshold, fade in the rear background layer and fade
out the front |
| 3 * background layer (opacity CSS transitioned over time). | 3 * background layer (opacity CSS transitioned over time). |
| 4 * |
| 5 * |
| 4 */ | 6 */ |
| 5 Polymer.AppLayout.registerEffect('fade-background', { | 7 Polymer.AppLayout.registerEffect('fade-background', { |
| 6 /** @this Polymer.AppLayout.ElementWithBackground */ | 8 /** @this Polymer.AppLayout.ElementWithBackground */ |
| 7 setUp: function setUp(config) { | 9 setUp: function setUp(config) { |
| 10 var fx = {}; |
| 8 var duration = config.duration || '0.5s'; | 11 var duration = config.duration || '0.5s'; |
| 9 this.$.backgroundFrontLayer.style.willChange = 'opacity'; | 12 fx.backgroundFrontLayer = this._getDOMRef('backgroundFrontLayer'); |
| 10 this.$.backgroundFrontLayer.style.webkitTransform = 'translateZ(0)'; | 13 fx.backgroundRearLayer = this._getDOMRef('backgroundRearLayer'); |
| 11 this.$.backgroundFrontLayer.style.transitionProperty = 'opacity'; | 14 fx.backgroundFrontLayer.style.willChange = 'opacity'; |
| 12 this.$.backgroundFrontLayer.style.transitionDuration = duration; | 15 fx.backgroundFrontLayer.style.webkitTransform = 'translateZ(0)'; |
| 13 this.$.backgroundRearLayer.style.willChange = 'opacity'; | 16 fx.backgroundFrontLayer.style.transitionProperty = 'opacity'; |
| 14 this.$.backgroundRearLayer.style.webkitTransform = 'translateZ(0)'; | 17 fx.backgroundFrontLayer.style.transitionDuration = duration; |
| 15 this.$.backgroundRearLayer.style.transitionProperty = 'opacity'; | 18 fx.backgroundRearLayer.style.willChange = 'opacity'; |
| 16 this.$.backgroundRearLayer.style.transitionDuration = duration; | 19 fx.backgroundRearLayer.style.webkitTransform = 'translateZ(0)'; |
| 20 fx.backgroundRearLayer.style.transitionProperty = 'opacity'; |
| 21 fx.backgroundRearLayer.style.transitionDuration = duration; |
| 22 this._fxFadeBackground = fx; |
| 17 }, | 23 }, |
| 18 /** @this Polymer.AppLayout.ElementWithBackground */ | 24 /** @this Polymer.AppLayout.ElementWithBackground */ |
| 19 run: function run(p, y) { | 25 run: function run(p, y) { |
| 26 var fx = this._fxFadeBackground; |
| 20 if (p >= 1) { | 27 if (p >= 1) { |
| 21 this.$.backgroundFrontLayer.style.opacity = 0; | 28 fx.backgroundFrontLayer.style.opacity = 0; |
| 22 this.$.backgroundRearLayer.style.opacity = 1; | 29 fx.backgroundRearLayer.style.opacity = 1; |
| 23 } else { | 30 } else { |
| 24 this.$.backgroundFrontLayer.style.opacity = 1; | 31 fx.backgroundFrontLayer.style.opacity = 1; |
| 25 this.$.backgroundRearLayer.style.opacity = 0; | 32 fx.backgroundRearLayer.style.opacity = 0; |
| 26 } | 33 } |
| 34 }, |
| 35 /** @this Polymer.AppLayout.ElementWithBackground */ |
| 36 tearDown: function tearDown() { |
| 37 delete this._fxFadeBackground; |
| 27 } | 38 } |
| 28 }); | 39 }); |
| OLD | NEW |