| 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 scalar = parseFloat(config.scalar); |
| 11 |
| 12 this._deltaBg = this.$.backgroundFrontLayer.offsetHeight - this.$.backgrou
nd.offsetHeight; |
| 13 if (this._deltaBg === 0) { |
| 14 if (isNaN(scalar)) { |
| 15 scalar = 0.8; |
| 16 } |
| 17 this._deltaBg = this._dHeight * scalar; |
| 18 } else { |
| 19 if (isNaN(scalar)) { |
| 20 scalar = 1; |
| 21 } |
| 22 this._deltaBg = this._deltaBg * scalar; |
| 23 } |
| 24 }, |
| 25 /** @this Polymer.AppLayout.ElementWithBackground */ |
| 26 tearDown: function tearDown() { |
| 27 delete this._deltaBg; |
| 28 }, |
| 29 /** @this Polymer.AppLayout.ElementWithBackground */ |
| 30 run: function run(p, y) { |
| 31 this.transform('translate3d(0px, ' + (this._deltaBg * Math.min(1, p)) + 'p
x, 0px)', this.$.backgroundFrontLayer); |
| 32 if (this.$.backgroundRearLayer) { |
| 33 this.transform('translate3d(0px, ' + (this._deltaBg * Math.min(1, p)) +
'px, 0px)', this.$.backgroundRearLayer); |
| 34 } |
| 35 } |
| 36 }); |
| OLD | NEW |