diff --git a/dist/swup.js b/dist/swup.js index 0208b958..39749e0e 100644 --- a/dist/swup.js +++ b/dist/swup.js @@ -1148,8 +1148,10 @@ module.exports = function (page, popstate) { this.cache.empty(this.options.debugMode); } setTimeout(function () { - _this.triggerEvent('animationInStart'); - document.documentElement.classList.remove('is-animating'); + if (!popstate || _this.options.animateHistoryBrowsing) { + _this.triggerEvent('animationInStart'); + document.documentElement.classList.remove('is-animating'); + } }, 10); // scrolling @@ -1174,15 +1176,17 @@ module.exports = function (page, popstate) { //preload pages if possible this.preloadPages(); - Promise.all(promises).then(function () { - _this.triggerEvent('animationInDone'); - // remove "to-{page}" classes - document.documentElement.className.split(' ').forEach(function (classItem) { - if (new RegExp("^to-").test(classItem) || classItem === "is-changing" || classItem === "is-rendering" || classItem === "is-popstate") { - document.documentElement.classList.remove(classItem); - } + if (!popstate || this.options.animateHistoryBrowsing) { + Promise.all(promises).then(function () { + _this.triggerEvent('animationInDone'); + // remove "to-{page}" classes + document.documentElement.className.split(' ').forEach(function (classItem) { + if (new RegExp("^to-").test(classItem) || classItem === "is-changing" || classItem === "is-rendering" || classItem === "is-popstate") { + document.documentElement.classList.remove(classItem); + } + }); }); - }); + } // update current url this.getUrl(); diff --git a/dist/swup.min.js b/dist/swup.min.js index 19196fcc..60d5a850 100644 --- a/dist/swup.min.js +++ b/dist/swup.min.js @@ -1 +1 @@ -(function e(t,n){if(typeof exports==="object"&&typeof module==="object")module.exports=n();else if(typeof define==="function"&&define.amd)define([],n);else if(typeof exports==="object")exports["Swup"]=n();else t["Swup"]=n()})(window,function(){return function(e){var t={};function n(o){if(t[o]){return t[o].exports}var r=t[o]={i:o,l:false,exports:{}};e[o].call(r.exports,r,r.exports,n);r.l=true;return r.exports}n.m=e;n.c=t;n.d=function(e,t,o){if(!n.o(e,t)){Object.defineProperty(e,t,{enumerable:true,get:o})}};n.r=function(e){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})};n.t=function(e,t){if(t&1)e=n(e);if(t&8)return e;if(t&4&&typeof e==="object"&&e&&e.__esModule)return e;var o=Object.create(null);n.r(o);Object.defineProperty(o,"default",{enumerable:true,value:e});if(t&2&&typeof e!="string")for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o};n.n=function(e){var t=e&&e.__esModule?function t(){return e["default"]}:function t(){return e};n.d(t,"a",t);return t};n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};n.p="";return n(n.s=1)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var o=function(){function e(e,t){for(var n=0;n1&&arguments[1]!==undefined?arguments[1]:false;var n={url:window.location.pathname+window.location.search,method:"GET",data:null};var r=o({},n,e);var i=new XMLHttpRequest;i.onreadystatechange=function(){if(i.readyState===4){if(i.status!==500){t(i.responseText,i)}else{t(null,i)}}};i.open(r.method,r.url,true);i.setRequestHeader("X-Requested-With","swup");i.send(r.data);return i}},function(e,t,n){"use strict";e.exports=function(e,t){var n=this;var o=e.replace("","");var r=document.createElement("div");r.innerHTML=o;var i=[];for(var s=0;s2&&arguments[2]!==undefined?arguments[2]:this.options.animateScroll;var r=1-this.options.scrollFriction;var i=this.options.scrollAcceleration;var s=0;var a=0;var l=0;var u=0;var c=0;var d=null;function f(){return document.body.scrollTop||document.documentElement.scrollTop}var h=function e(){var t=p();m();if(c===1&&l>s||c===-1&&lt?-1:1;u=t+c;l=t;a=0;if(s!=l){h()}else{n.triggerEvent("scrollDone")}};this.triggerEvent("scrollStart");if(o==0){window.scrollTo(0,t);this.triggerEvent("scrollDone")}else{v(t)}}},function(e,t,n){"use strict";e.exports=function(e){var t=e.toString().toLowerCase().replace(/\s+/g,"-").replace(/\//g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");if(t[0]=="/")t=t.splice(1);if(t=="")t="homepage";return t}},function(e,t,n){"use strict";e.exports=function(e){if(this.options.scroll&&(!e||this.options.animateHistoryBrowsing)){if(this.scrollToElement!=null){var t=document.querySelector(this.scrollToElement);if(t!=null){var n=t.getBoundingClientRect().top+window.pageYOffset;this.scrollTo(document.body,n)}else{console.warn("Element for offset not found ("+this.scrollToElement+")")}this.scrollToElement=null}else{this.scrollTo(document.body,0)}}}},function(e,t,n){"use strict";e.exports=function(e){var t=this;var n=0;for(var o=0;o1&&arguments[1]!==undefined?arguments[1]:false;var n={url:window.location.pathname+window.location.search,method:"GET",data:null};var r=o({},n,e);var i=new XMLHttpRequest;i.onreadystatechange=function(){if(i.readyState===4){if(i.status!==500){t(i.responseText,i)}else{t(null,i)}}};i.open(r.method,r.url,true);i.setRequestHeader("X-Requested-With","swup");i.send(r.data);return i}},function(e,t,n){"use strict";e.exports=function(e,t){var n=this;var o=e.replace("","");var r=document.createElement("div");r.innerHTML=o;var i=[];for(var s=0;s2&&arguments[2]!==undefined?arguments[2]:this.options.animateScroll;var r=1-this.options.scrollFriction;var i=this.options.scrollAcceleration;var s=0;var a=0;var l=0;var u=0;var c=0;var d=null;function f(){return document.body.scrollTop||document.documentElement.scrollTop}var h=function e(){var t=p();m();if(c===1&&l>s||c===-1&&lt?-1:1;u=t+c;l=t;a=0;if(s!=l){h()}else{n.triggerEvent("scrollDone")}};this.triggerEvent("scrollStart");if(o==0){window.scrollTo(0,t);this.triggerEvent("scrollDone")}else{v(t)}}},function(e,t,n){"use strict";e.exports=function(e){var t=e.toString().toLowerCase().replace(/\s+/g,"-").replace(/\//g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");if(t[0]=="/")t=t.splice(1);if(t=="")t="homepage";return t}},function(e,t,n){"use strict";e.exports=function(e){if(this.options.scroll&&(!e||this.options.animateHistoryBrowsing)){if(this.scrollToElement!=null){var t=document.querySelector(this.scrollToElement);if(t!=null){var n=t.getBoundingClientRect().top+window.pageYOffset;this.scrollTo(document.body,n)}else{console.warn("Element for offset not found ("+this.scrollToElement+")")}this.scrollToElement=null}else{this.scrollTo(document.body,0)}}}},function(e,t,n){"use strict";e.exports=function(e){var t=this;var n=0;for(var o=0;o { - this.triggerEvent('animationInStart') - document.documentElement.classList.remove('is-animating') + if (!popstate || this.options.animateHistoryBrowsing) { + this.triggerEvent('animationInStart') + document.documentElement.classList.remove('is-animating') + } }, 10) // scrolling @@ -86,17 +88,19 @@ module.exports = function (page, popstate) { //preload pages if possible this.preloadPages() - Promise - .all(promises) - .then(() => { - this.triggerEvent('animationInDone') - // remove "to-{page}" classes - document.documentElement.className.split(' ').forEach(classItem => { - if (new RegExp("^to-").test(classItem) || classItem === "is-changing" || classItem === "is-rendering" || classItem === "is-popstate") { - document.documentElement.classList.remove(classItem); - } - }); - }) + if (!popstate || this.options.animateHistoryBrowsing) { + Promise + .all(promises) + .then(() => { + this.triggerEvent('animationInDone') + // remove "to-{page}" classes + document.documentElement.className.split(' ').forEach(classItem => { + if (new RegExp("^to-").test(classItem) || classItem === "is-changing" || classItem === "is-rendering" || classItem === "is-popstate") { + document.documentElement.classList.remove(classItem); + } + }); + }) + } // update current url this.getUrl()