From 2051858ab77eaec82abe5b287d740dcfbb3e7605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ak=C3=A7akaya?= Date: Fri, 13 Jan 2017 13:54:50 +0200 Subject: [PATCH] Fix for jQuery 3.x compatibility without using 3.x migrate plugin --- src/jquery.stellar.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/jquery.stellar.js b/src/jquery.stellar.js index 98b2ea5..f3422db 100644 --- a/src/jquery.stellar.js +++ b/src/jquery.stellar.js @@ -225,7 +225,7 @@ // Fix for WebKit background rendering bug if (options && options.firstLoad && /WebKit/.test(navigator.userAgent)) { - $(window).load(function() { + $(window).on('load',function() { var oldLeft = self._getScrollLeft(), oldTop = self._getScrollTop(); @@ -241,7 +241,8 @@ this._setScrollTop(oldTop); }, _detectViewport: function() { - var viewportOffsets = this.$viewportElement.offset(), + + var viewportOffsets = this.$viewportElement[0] !== window ? this.$viewportElement.offset() : {top: 0, left: 0}, hasOffsets = viewportOffsets !== null && viewportOffsets !== undefined; this.viewportWidth = this.$viewportElement.width(); @@ -648,4 +649,4 @@ // Expose the plugin class so it can be modified window.Stellar = Plugin; -}(jQuery, this, document)); \ No newline at end of file +}(jQuery, this, document));