diff --git a/CHANGELOG b/CHANGELOG index 0bc1009..2ffb314 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +1.1.4 + - Fixes issue on latest Chrome 61 on Android re: scroll position. + Now using a more standard way to retrieve the scrolling element. 1.1.3 - Use iOS7 background scrolling fix with lockup. Also fixes an issue with input focus competing with browser scroll on focusing on inputs. diff --git a/bower.json b/bower.json index 1804fe0..7dd8b0a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "lockup", - "version": "1.1.3", + "version": "1.1.4", "homepage": "https://github.com/mobify/lockup", "authors": [ "Mobify " diff --git a/dist/lockup.js b/dist/lockup.js index 6df5c2e..dca509b 100644 --- a/dist/lockup.js +++ b/dist/lockup.js @@ -30,7 +30,7 @@ Lockup.__super__.call(this, element, options, Lockup.DEFAULTS); } - Lockup.VERSION = '1.1.3'; + Lockup.VERSION = '1.1.4'; Lockup.DEFAULTS = { container: null, @@ -44,6 +44,7 @@ this.$html = $('html'); this.$body = $('body'); this.$doc = $(document); + this.$scrollingEl = $(document.scrollingElement || document.documentElement); this.$container = this._buildContainer(); @@ -125,7 +126,7 @@ return parseInt(self.$body.css('padding-' + position)); }; - this.scrollPosition = this.$body.scrollTop(); + this.scrollPosition = this.$scrollingEl.scrollTop(); this.$doc.off('touchmove', this._preventDefault); diff --git a/dist/lockup.min.js b/dist/lockup.min.js index aacadab..1a41f46 100644 --- a/dist/lockup.min.js +++ b/dist/lockup.min.js @@ -1,2 +1,2 @@ -/*! lockup 1.1.3 (https://github.com/mobify/lockup.git) */ -(function(t){if("function"==typeof define&&define.amd)define(["$","plugin","deckard"],t);else{var i=window.Zepto||window.jQuery;t(i,window.Plugin)}})(function(t,i){function n(t,i){n.__super__.call(this,t,i,n.DEFAULTS)}t.extend(t.fn,{renameAttr:function(i,n){return this.each(function(){var o=t(this);o.attr(n,o.attr(i)).removeAttr(i)})}});var o={CONTAINER:"lockup__container",LOCKED:"lockup--is-locked"};return n.VERSION="1.1.3",n.DEFAULTS={container:null,locked:t.noop,unlocked:t.noop},i.create("lockup",n,{_init:function(i){this.$element=t(i),this.$html=t("html"),this.$body=t("body"),this.$doc=t(document),this.$container=this._buildContainer();var n=this._instanceCount();this._instanceCount(++n)},destroy:function(){var t=this._instanceCount(),i=this.$container.data("generated");0===this._instanceCount(--t)&&i&&(this._disableScripts(function(){this.$body.append(this.$container.children())}),this.$element.removeData(this.name),this.$container.remove())},_instanceCount:function(t){return!isNaN(t)&&this.$container.data("instance",t),this.$container.data("instance")||0},_buildContainer:function(){var i=t("."+o.CONTAINER);return i.length||(i=this.options.container?t(this.options.container).addClass(o.CONTAINER):this._createContainer()),i},_createContainer:function(){return this._disableScripts(function(){this.$body.wrapInner(t("
").addClass(o.CONTAINER))}),this.$body.find("."+o.CONTAINER).data("generated",!0)},_disableScripts:function(t){var i=this.$body.find("script").renameAttr("src","x-src").attr("type","text/lockup-script");t.call(this),i.renameAttr("x-src","src").attr("type","text/javascript")},lock:function(){var i=this,n=function(t){return parseInt(i.$body.css("padding-"+t))};this.scrollPosition=this.$body.scrollTop(),this.$doc.off("touchmove",this._preventDefault),this.$container.addClass(o.LOCKED),t.browser.chrome?(this.$html.css("position","fixed"),this.$html.css("top",-1*this.scrollPosition)):t.os.ios&&t.os.major>=7&&(this.$body.css("margin-top",0).css("margin-bottom",0),this.$container.height(window.innerHeight).css("overflow","hidden").scrollTop(this.scrollPosition-n("top")-n("bottom"))),this._trigger("locked")},unlock:function(){this.$doc.on("touchmove",this._preventDefault),this.$container.removeClass(o.LOCKED),t.browser.chrome?(this.$html.css("position",""),this.$html.css("top",""),window.scrollTo(0,this.scrollPosition)):t.os.ios&&t.os.major>=7&&(this.$body.css("margin",""),this.$container.css("overflow","").css("height",""),window.scrollTo(0,this.scrollPosition)),this._trigger("unlocked"),this.$doc.off("touchmove",this._preventDefault)},isLocked:function(){return this.$container.hasClass(o.LOCKED)},_preventDefault:function(t){t.preventDefault()}}),t}); \ No newline at end of file +/*! lockup 1.1.4 (https://github.com/mobify/lockup.git) */ +!function(a){if("function"==typeof define&&define.amd)define(["$","plugin","deckard"],a);else{a(window.Zepto||window.jQuery,window.Plugin)}}(function(a,b){function c(a,b){c.__super__.call(this,a,b,c.DEFAULTS)}a.extend(a.fn,{renameAttr:function(b,c){return this.each(function(){var d=a(this);d.attr(c,d.attr(b)).removeAttr(b)})}});var d={CONTAINER:"lockup__container",LOCKED:"lockup--is-locked"};return c.VERSION="1.1.4",c.DEFAULTS={container:null,locked:a.noop,unlocked:a.noop},b.create("lockup",c,{_init:function(b){this.$element=a(b),this.$html=a("html"),this.$body=a("body"),this.$doc=a(document),this.$scrollingEl=a(document.scrollingElement||document.documentElement),this.$container=this._buildContainer();var c=this._instanceCount();this._instanceCount(++c)},destroy:function(){var a=this._instanceCount(),b=this.$container.data("generated");0===this._instanceCount(--a)&&b&&(this._disableScripts(function(){this.$body.append(this.$container.children())}),this.$element.removeData(this.name),this.$container.remove())},_instanceCount:function(a){return!isNaN(a)&&this.$container.data("instance",a),this.$container.data("instance")||0},_buildContainer:function(){var b=a("."+d.CONTAINER);return b.length||(b=this.options.container?a(this.options.container).addClass(d.CONTAINER):this._createContainer()),b},_createContainer:function(){return this._disableScripts(function(){this.$body.wrapInner(a("
").addClass(d.CONTAINER))}),this.$body.find("."+d.CONTAINER).data("generated",!0)},_disableScripts:function(a){var b=this.$body.find("script").renameAttr("src","x-src").attr("type","text/lockup-script");a.call(this),b.renameAttr("x-src","src").attr("type","text/javascript")},lock:function(){var b=this,c=function(a){return parseInt(b.$body.css("padding-"+a))};this.scrollPosition=this.$scrollingEl.scrollTop(),this.$doc.off("touchmove",this._preventDefault),this.$container.addClass(d.LOCKED),a.browser.chrome?(this.$html.css("position","fixed"),this.$html.css("top",-1*this.scrollPosition)):a.os.ios&&a.os.major>=7&&(this.$body.css("margin-top",0).css("margin-bottom",0),this.$container.height(window.innerHeight).css("overflow","hidden").scrollTop(this.scrollPosition-c("top")-c("bottom"))),this._trigger("locked")},unlock:function(){this.$doc.on("touchmove",this._preventDefault),this.$container.removeClass(d.LOCKED),a.browser.chrome?(this.$html.css("position",""),this.$html.css("top",""),window.scrollTo(0,this.scrollPosition)):a.os.ios&&a.os.major>=7&&(this.$body.css("margin",""),this.$container.css("overflow","").css("height",""),window.scrollTo(0,this.scrollPosition)),this._trigger("unlocked"),this.$doc.off("touchmove",this._preventDefault)},isLocked:function(){return this.$container.hasClass(d.LOCKED)},_preventDefault:function(a){a.preventDefault()}}),a}); \ No newline at end of file diff --git a/package.json b/package.json index 097968a..9a3f5b0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type" : "git", "url" : "https://github.com/mobify/lockup.git" }, - "version": "1.1.3", + "version": "1.1.4", "description": "A mobile first scroll blocking plugin", "devDependencies": { "chai": "~1.9.0", diff --git a/src/js/lockup.js b/src/js/lockup.js index 735a396..1ab29c5 100644 --- a/src/js/lockup.js +++ b/src/js/lockup.js @@ -44,6 +44,7 @@ this.$html = $('html'); this.$body = $('body'); this.$doc = $(document); + this.$scrollingEl = $(document.scrollingElement || document.documentElement); this.$container = this._buildContainer(); @@ -125,7 +126,7 @@ return parseInt(self.$body.css('padding-' + position)); }; - this.scrollPosition = this.$body.scrollTop(); + this.scrollPosition = this.$scrollingEl.scrollTop(); this.$doc.off('touchmove', this._preventDefault);