|
138 | 138 | _defineElements: function() {
|
139 | 139 | this.$scrollElement = $(this.element);
|
140 | 140 | this.$element = this.element === window ? $('body') : this.$scrollElement;
|
141 |
| - this.$viewportElement = (this.options.viewportElement !== undefined ? $(this.options.viewportElement) : (this.$scrollElement[0] === window ? this.$scrollElement : this.$scrollElement.parent()) ); |
| 141 | + this.$viewportElement = (this.options.viewportElement !== undefined ? $(this.options.viewportElement) : (this.$scrollElement[0] === window || this.options.scrollProperty.indexOf('scroll') === 0 ? this.$scrollElement : this.$scrollElement.parent()) ); |
142 | 142 | },
|
143 | 143 | _defineGetters: function() {
|
144 | 144 | var self = this;
|
|
199 | 199 | scrollLeft = this._getScrollLeft(),
|
200 | 200 | scrollTop = this._getScrollTop();
|
201 | 201 |
|
| 202 | + if (this.particles !== undefined) { |
| 203 | + for (var i = this.particles.length - 1; i >= 0; i--) { |
| 204 | + this.particles[i].$element.data('stellar-elementIsActive', undefined); |
| 205 | + } |
| 206 | + } |
| 207 | + |
202 | 208 | this.particles = [];
|
203 | 209 |
|
204 | 210 | if (!this.options.parallaxElements) return;
|
|
217 | 223 | tempParentOffsetLeft = 0,
|
218 | 224 | tempParentOffsetTop = 0;
|
219 | 225 |
|
| 226 | + // Ensure this element isn't already part of another scrolling element |
| 227 | + if ($this.data('stellar-elementIsActive') === undefined) { |
| 228 | + $this.data('stellar-elementIsActive', true); |
| 229 | + } else { |
| 230 | + return; |
| 231 | + } |
| 232 | + |
220 | 233 | self.options.showElement($this);
|
221 | 234 |
|
222 | 235 | // Save/restore the original top and left CSS values in case we refresh the particles
|
|
280 | 293 | scrollTop = this._getScrollTop(),
|
281 | 294 | $backgroundElements;
|
282 | 295 |
|
| 296 | + if (this.background !== undefined) { |
| 297 | + for (var i = this.backgrounds.length - 1; i >= 0; i--) { |
| 298 | + this.backgrounds[i].$element.data('stellar-backgroundIsActive', undefined); |
| 299 | + } |
| 300 | + } |
| 301 | + |
283 | 302 | this.backgrounds = [];
|
284 | 303 |
|
285 | 304 | if (!this.options.parallaxBackgrounds) return;
|
|
300 | 319 | offsetLeft,
|
301 | 320 | offsetTop;
|
302 | 321 |
|
| 322 | + // Ensure this element isn't already part of another scrolling element |
| 323 | + if ($this.data('stellar-backgroundIsActive') === undefined) { |
| 324 | + $this.data('stellar-backgroundIsActive', true); |
| 325 | + } else { |
| 326 | + return; |
| 327 | + } |
| 328 | + |
303 | 329 | offsetLeft = $this.offset().left - parseInt($this.css('margin-left'), 10) - scrollLeft;
|
304 | 330 | offsetTop = $this.offset().top - parseInt($this.css('margin-top'), 10) - scrollTop;
|
305 | 331 |
|
|
0 commit comments