| OLD | NEW |
| (Empty) |
| 1 /** | |
| 2 * Vertically translate the background based on a factor of the scroll positio
n. | |
| 3 */ | |
| 4 Polymer.AppLayout.registerEffect('parallax-background', { | |
| 5 /** | |
| 6 * @param {{scalar: string}} config | |
| 7 * @this Polymer.AppLayout.ElementWithBackground | |
| 8 */ | |
| 9 setUp: function setUp(config) { | |
| 10 var fx = {}; | |
| 11 var scalar = parseFloat(config.scalar); | |
| 12 fx.background = this._getDOMRef('background'); | |
| 13 fx.backgroundFrontLayer = this._getDOMRef('backgroundFrontLayer'); | |
| 14 fx.backgroundRearLayer = this._getDOMRef('backgroundRearLayer'); | |
| 15 fx.deltaBg = fx.backgroundFrontLayer.offsetHeight - fx.background.offsetHe
ight; | |
| 16 if (fx.deltaBg === 0) { | |
| 17 if (isNaN(scalar)) { | |
| 18 scalar = 0.8; | |
| 19 } | |
| 20 fx.deltaBg = this._dHeight * scalar; | |
| 21 } else { | |
| 22 if (isNaN(scalar)) { | |
| 23 scalar = 1; | |
| 24 } | |
| 25 fx.deltaBg = fx.deltaBg * scalar; | |
| 26 } | |
| 27 this._fxParallaxBackground = fx; | |
| 28 }, | |
| 29 /** @this Polymer.AppLayout.ElementWithBackground */ | |
| 30 run: function run(p, y) { | |
| 31 var fx = this._fxParallaxBackground; | |
| 32 this.transform('translate3d(0px, ' + (fx.deltaBg * Math.min(1, p)) + 'px,
0px)', fx.backgroundFrontLayer); | |
| 33 if (fx.backgroundRearLayer) { | |
| 34 this.transform('translate3d(0px, ' + (fx.deltaBg * Math.min(1, p)) + 'px
, 0px)', fx.backgroundRearLayer); | |
| 35 } | |
| 36 }, | |
| 37 /** @this Polymer.AppLayout.ElementWithBackground */ | |
| 38 tearDown: function tearDown() { | |
| 39 delete this._fxParallaxBackground; | |
| 40 } | |
| 41 }); | |
| OLD | NEW |