Skip to content

Commit

Permalink
livereload: Maintain the scroll position if possible
Browse files Browse the repository at this point in the history
This fixes #3824: when the current pathname is the same as the one to be loaded, just call location.reload() so that the current scroll position can be preserved, instead of assigning to location.href, which will cause the scroll position to be lost.
  • Loading branch information
yihui authored and bep committed Aug 22, 2017
1 parent 88e1bca commit 7231d5a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion livereload/livereload.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ HugoReload.prototype.reload = function(path, options) {
}
path = path.substring(prefix.length);
window.location.href = path;
if (window.location.pathname === path) {
window.location.reload();
} else {
window.location.href = path;
}
return true;
};
Expand Down

0 comments on commit 7231d5a

Please sign in to comment.