Skip to content

Commit

Permalink
fix incorrect replaceState on links leading to an anchor element on t…
Browse files Browse the repository at this point in the history
…he same page
  • Loading branch information
gmrchk committed Oct 12, 2018
1 parent a1f78f1 commit c8b00c7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
9 changes: 8 additions & 1 deletion dist/swup.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,11 @@ var Swup = function () {
var top = element.getBoundingClientRect().top + window.pageYOffset;
this.scrollTo(document.body, top);
}
history.replaceState(undefined, undefined, link.getHash());
history.replaceState({
url: link.getAddress() + link.getHash(),
random: Math.random(),
source: "swup"
}, document.title, link.getAddress() + link.getHash());
} else {
console.warn('Element for offset not found (' + link.getHash() + ')');
}
Expand Down Expand Up @@ -647,6 +651,7 @@ var Swup = function () {
} else {
event.preventDefault();
}
console.log(event.state);
this.triggerEvent('popState');
this.loadPage({ url: link.getAddress() }, event);
}
Expand Down Expand Up @@ -1180,6 +1185,8 @@ module.exports = function (page, popstate) {

// update current url
this.getUrl();
// reset scroll-to element
this.scrollToElement = null;
};

/***/ }),
Expand Down
Loading

0 comments on commit c8b00c7

Please sign in to comment.