Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 33 additions & 29 deletions src/jquery.stellar.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,32 +504,25 @@
}
},
_repositionElements: function() {
var scrollLeft = this._getScrollLeft(),
scrollTop = this._getScrollTop(),
horizontalOffset,
verticalOffset,
particle,
fixedRatioOffset,
background,
bgLeft,
bgTop,
isVisibleVertical = true,
isVisibleHorizontal = true,
newPositionLeft,
newPositionTop,
newOffsetLeft,
newOffsetTop,
i;

// First check that the scroll position or container size has changed
if (this.currentScrollLeft === scrollLeft && this.currentScrollTop === scrollTop && this.currentWidth === this.viewportWidth && this.currentHeight === this.viewportHeight) {
return;
} else {
this.currentScrollLeft = scrollLeft;
this.currentScrollTop = scrollTop;
this.currentWidth = this.viewportWidth;
this.currentHeight = this.viewportHeight;
}
var scrollLeft=this.currentScrollLeft,
scrollTop=this.currentScrollTop,
horizontalOffset,
verticalOffset,
particle,
fixedRatioOffset,
background,
bgLeft,
bgTop,
isVisibleVertical = true,
isVisibleHorizontal = true,
newPositionLeft,
newPositionTop,
newOffsetLeft,
newOffsetTop,
i;

this.currentWidth = this.viewportWidth;
this.currentHeight = this.viewportHeight;

// Reposition elements
for (i = this.particles.length - 1; i >= 0; i--) {
Expand Down Expand Up @@ -595,8 +588,19 @@
ticking = false;
};

var requestTick = function() {
if (!ticking) {
var requestTick = function(evt) {
var scrollLeft = self._getScrollLeft();
var scrollTop = self._getScrollTop();

// First check that the scroll position or container size has changed
if (((self.currentScrollLeft === scrollLeft && self.currentWidth === self.viewportWidth) || !self.options.horizontalScrolling) && ((self.currentScrollTop === scrollTop && self.currentHeight === self.viewportHeight) || !self.options.verticalScrolling)) {
return;
}

self.currentScrollLeft = scrollLeft;
self.currentScrollTop = scrollTop;

if (!ticking) {
requestAnimFrame(update);
ticking = true;
}
Expand Down Expand Up @@ -648,4 +652,4 @@

// Expose the plugin class so it can be modified
window.Stellar = Plugin;
}(jQuery, this, document));
}(jQuery, this, document));