Skip to content

Commit

Permalink
update: use sessionStorage instead of localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
mahiarirani committed Oct 22, 2023
1 parent 4ee9df5 commit 7df53f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
window.addEventListener('scroll', function () {
if (document.getElementsByClassName('keep-scroll').length) {
localStorage.top = window.scrollY;
sessionStorage.top = window.scrollY;
}
})
window.addEventListener('load', function () {
if (document.getElementsByClassName('keep-scroll').length) {
window.scrollTo({top: localStorage.top || 0, behavior: 'smooth'});
window.scrollTo({top: sessionStorage.top || 0, behavior: 'smooth'});
}
})

0 comments on commit 7df53f2

Please sign in to comment.