Skip to content

Commit

Permalink
Merge pull request #60 from juanolon/jump-to
Browse files Browse the repository at this point in the history
jumpt to last position
  • Loading branch information
emad-elsaid committed Jun 29, 2024
2 parents c742e33 + 69c4ac7 commit a3d652c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions extensions/hotreload/hotreload.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,16 @@ const clientScript = `
let socket = new WebSocket(socketUrl);
socket.addEventListener('message', (evt) => {
let data = JSON.parse(evt.data)
sessionStorage.setItem('scrollPosition', window.scrollY);
window.location.href = data.url;
});
})();
window.addEventListener('load', function() {
const scrollPosition = sessionStorage.getItem('scrollPosition');
if (scrollPosition !== null) {
window.scrollTo(0, parseInt(scrollPosition, 10));
}
});
</script>
`

Expand Down

0 comments on commit a3d652c

Please sign in to comment.