Created
January 16, 2018 19:31
-
-
Save syzer/143532ed7eabb2dde0f401aa4684bda8 to your computer and use it in GitHub Desktop.
My friend's did some jQyery... let's see
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var $scrolledelement = document.getElementById("left"); | |
| $scrolledelement.scrollTop = localStorage.scrollPosition; | |
| $scrolledelement.onscroll = function() { | |
| $pos = $scrolledelement.scrollTop | |
| localStorage.setItem("scrollPosition", $pos); | |
| $outelement.innerHTML = localStorage.scrollPosition; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Advantage of this compared to pure-anchor solution is that it keeps the exact position of scroll after reload. Sometimes you want to position the scroll so it shows a little bit of upper content.
This could be combined with an anchor to give realy nice scroll behavior.