| OLD | NEW |
| 1 /** | 1 /** |
| 2 * While scrolling down, fade in the rear background layer and fade out the fr
ont background | 2 * While scrolling down, fade in the rear background layer and fade out the fr
ont background |
| 3 * layer (opacity interpolated based on scroll position). | 3 * layer (opacity interpolated based on scroll position). |
| 4 */ | 4 */ |
| 5 Polymer.AppLayout.registerEffect('blend-background', { | 5 Polymer.AppLayout.registerEffect('blend-background', { |
| 6 /** @this Polymer.AppLayout.ElementWithBackground */ | 6 /** @this Polymer.AppLayout.ElementWithBackground */ |
| 7 setUp: function setUp() { | 7 setUp: function setUp() { |
| 8 this.$.backgroundFrontLayer.style.willChange = 'opacity'; | 8 var fx = {}; |
| 9 this.$.backgroundFrontLayer.style.webkitTransform = 'translateZ(0)'; | 9 fx.backgroundFrontLayer = this._getDOMRef('backgroundFrontLayer'); |
| 10 this.$.backgroundRearLayer.style.willChange = 'opacity'; | 10 fx.backgroundRearLayer = this._getDOMRef('backgroundRearLayer'); |
| 11 this.$.backgroundRearLayer.style.webkitTransform = 'translateZ(0)'; | 11 fx.backgroundFrontLayer.style.willChange = 'opacity'; |
| 12 this.$.backgroundRearLayer.style.opacity = 0; | 12 fx.backgroundFrontLayer.style.transform = 'translateZ(0)'; |
| 13 fx.backgroundRearLayer.style.willChange = 'opacity'; |
| 14 fx.backgroundRearLayer.style.transform = 'translateZ(0)'; |
| 15 fx.backgroundRearLayer.style.opacity = 0; |
| 16 this._fxBlendBackground = fx; |
| 13 }, | 17 }, |
| 14 /** @this Polymer.AppLayout.ElementWithBackground */ | 18 /** @this Polymer.AppLayout.ElementWithBackground */ |
| 15 run: function run(p, y) { | 19 run: function run(p, y) { |
| 16 this.$.backgroundFrontLayer.style.opacity = 1 - p; | 20 var fx = this._fxBlendBackground; |
| 17 this.$.backgroundRearLayer.style.opacity = p; | 21 fx.backgroundFrontLayer.style.opacity = 1 - p; |
| 22 fx.backgroundRearLayer.style.opacity = p; |
| 23 }, |
| 24 /** @this Polymer.AppLayout.ElementWithBackground */ |
| 25 tearDown: function tearDown() { |
| 26 delete this._fxBlendBackground; |
| 18 } | 27 } |
| 19 }); | 28 }); |
| OLD | NEW |