Skip to content

Commit f9b83e2

Browse files
committed
With regular scroll, use scroll events rather than a requestAnimationFrame loop
1 parent 80126a4 commit f9b83e2

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

jquery.stellar.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@
170170
this._detectViewport();
171171
this.refresh({ firstLoad: true });
172172

173-
this._startAnimationLoop();
173+
if (this.options.scrollProperty === 'scroll') {
174+
this._handleScrollEvent();
175+
} else {
176+
this._startAnimationLoop();
177+
}
174178
},
175179
_defineElements: function() {
176180
if (this.element === document.body) this.element = window;
@@ -484,6 +488,7 @@
484488
setBackgroundPosition(background.$element, background.startingValueLeft, background.startingValueTop);
485489
}
486490

491+
this.$scrollElement.unbind('resize.' + this.name);
487492
this._animationLoop = $.noop;
488493

489494
$(window).unbind('load.' + this.name).unbind('resize.' + this.name);
@@ -594,6 +599,10 @@
594599
setBackgroundPosition(background.$element, bgLeft, bgTop);
595600
}
596601
},
602+
_handleScrollEvent: function() {
603+
this.$scrollElement.bind('scroll.' + this.name, $.proxy(this._repositionElements, this));
604+
this._repositionElements();
605+
},
597606
_startAnimationLoop: function() {
598607
var self = this,
599608
requestAnimFrame = (function(){

0 commit comments

Comments
 (0)