Skip to content

Commit

Permalink
trigger animationInStart only when animation is not skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
gmrchk committed Oct 25, 2018
1 parent db180f3 commit f71b256
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
24 changes: 14 additions & 10 deletions dist/swup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down
Loading

0 comments on commit f71b256

Please sign in to comment.