Skip to content

Commit 9b65274

Browse files
authored
Merge pull request #10 from hydrostack/9-hydro-link-navigation-does-not-reset-scroll-position-on-new-page
Scroll the window to the top after replacing the body content.
2 parents de697df + 6999058 commit 9b65274

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Scripts/hydro.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
let newContent = doc.querySelector(selector);
4343
let newTitle = doc.querySelector('head>title');
4444
element.innerHTML = newContent.innerHTML;
45+
46+
if (selector === 'body'){
47+
window.scrollTo(0, 0);
48+
}
4549

4650
if (newTitle) {
4751
document.title = newTitle.textContent;

0 commit comments

Comments
 (0)