Skip to content

Commit

Permalink
trigger contentReplaced after changing body classes
Browse files Browse the repository at this point in the history
  • Loading branch information
gmrchk committed Oct 19, 2018
1 parent 7af18e1 commit 3575627
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
22 changes: 11 additions & 11 deletions dist/swup.js
Original file line number Diff line number Diff line change
Expand Up @@ -1122,16 +1122,8 @@ module.exports = function (page, popstate) {
// set title
document.title = page.title;

this.triggerEvent('contentReplaced');
this.triggerEvent('pageView');
if (!this.options.cache) {
this.cache.empty(this.options.debugMode);
}
setTimeout(function () {
document.documentElement.classList.remove('is-animating');
}, 10);

// handle classes after render
// remove
if (this.options.pageClassPrefix !== false) {
document.body.className.split(' ').forEach(function (className) {
// empty string for page class
Expand All @@ -1140,8 +1132,7 @@ module.exports = function (page, popstate) {
}
});
}

// empty string for page class
// add
if (page.pageClass != "") {
page.pageClass.split(' ').forEach(function (className) {
if (className != "" && className.includes(_this.options.pageClassPrefix)) {
Expand All @@ -1150,6 +1141,15 @@ module.exports = function (page, popstate) {
});
}

this.triggerEvent('contentReplaced');
this.triggerEvent('pageView');
if (!this.options.cache) {
this.cache.empty(this.options.debugMode);
}
setTimeout(function () {
document.documentElement.classList.remove('is-animating');
}, 10);

// scrolling
if (!this.options.doScrollingRightAway || this.scrollToElement) {
this.doScrolling(popstate);
Expand Down
Loading

0 comments on commit 3575627

Please sign in to comment.