Skip to content

Commit 0f4c914

Browse files
committed
Fix assumed parallax background on scrolling element
1 parent 9d940e2 commit 0f4c914

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

stellar.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,8 @@
136136
this._startAnimationLoop();
137137
},
138138
_defineElements: function() {
139-
this.$element = this.element === window ? $('body') : $(this.element);
140-
141-
if (this.options.scrollProperty === 'scroll') {
142-
this.$scrollElement = this.element === window || this.element.nodeName === 'BODY' || this.element.nodeName === 'HTML' ? $(window) : this.$element;
143-
} else {
144-
this.$scrollElement = this.$element;
145-
}
146-
139+
this.$scrollElement = $(this.element);
140+
this.$element = this.element === window ? $('body') : this.$scrollElement;
147141
this.$viewportElement = (this.options.viewportElement !== undefined ? $(this.options.viewportElement) : (this.$scrollElement[0] === window ? this.$scrollElement : this.$scrollElement.parent()) );
148142
},
149143
_defineGetters: function() {
@@ -288,7 +282,11 @@
288282

289283
if (!this.options.parallaxBackgrounds) return;
290284

291-
$backgroundElements = this.$element.add(this.$element.find('[data-stellar-background-ratio]'));
285+
$backgroundElements = this.$element.find('[data-stellar-background-ratio]');
286+
287+
if (this.$element.is('[data-stellar-background-ratio]')) {
288+
$backgroundElements.add(this.$element);
289+
}
292290

293291
$backgroundElements.each(function(){
294292
var $this = $(this),

0 commit comments

Comments
 (0)