|
15 | 15 | for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
16 | 16 | window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
17 | 17 | window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
18 |
| - || window[vendors[x]+'CancelRequestAnimationFrame']; |
| 18 | + || window[vendors[x]+'CancelRequestAnimationFrame']; |
19 | 19 | }
|
20 | 20 |
|
21 | 21 | if (!window.requestAnimationFrame)
|
|
115 | 115 |
|
116 | 116 | this.$mirror = $('<div />').prependTo('body');
|
117 | 117 |
|
118 |
| - |
119 | 118 | var slider = this.$element.find('>.parallax-slider');
|
| 119 | + var sliderExisted = false; |
120 | 120 |
|
121 | 121 | if (slider.length == 0)
|
122 | 122 | this.$slider = $('<img />').prependTo(this.$mirror);
|
123 |
| - else |
| 123 | + else { |
124 | 124 | this.$slider = slider.prependTo(this.$mirror)
|
| 125 | + sliderExisted = true; |
| 126 | + } |
125 | 127 |
|
126 | 128 | this.$mirror.addClass('parallax-mirror').css({
|
127 | 129 | visibility: 'hidden',
|
|
145 | 147 | Parallax.requestRender();
|
146 | 148 | });
|
147 | 149 |
|
148 |
| - this.$slider[0].src = this.imageSrc; |
| 150 | + if (!sliderExisted) |
| 151 | + this.$slider[0].src = this.imageSrc; |
149 | 152 |
|
150 | 153 | if (this.naturalHeight && this.naturalWidth || this.$slider[0].complete || slider.length > 0) {
|
151 | 154 | this.$slider.trigger('load');
|
|
287 | 290 | };
|
288 | 291 |
|
289 | 292 | $win.on('resize.px.parallax load.px.parallax', function() {
|
290 |
| - loadDimensions(); |
291 |
| - Parallax.isFresh = false; |
292 |
| - Parallax.requestRender(); |
293 |
| - }) |
294 |
| - .on('scroll.px.parallax load.px.parallax', function() { |
295 |
| - loadScrollPosition(); |
296 |
| - Parallax.requestRender(); |
297 |
| - }); |
| 293 | + loadDimensions(); |
| 294 | + Parallax.isFresh = false; |
| 295 | + Parallax.requestRender(); |
| 296 | + }) |
| 297 | + .on('scroll.px.parallax load.px.parallax', function() { |
| 298 | + loadScrollPosition(); |
| 299 | + Parallax.requestRender(); |
| 300 | + }); |
298 | 301 |
|
299 | 302 | loadDimensions();
|
300 | 303 | loadScrollPosition();
|
|
0 commit comments