Created
April 18, 2016 09:26
-
-
Save alxpsr/ad1813a5bcd05cc4c969d8b8b5890d45 to your computer and use it in GitHub Desktop.
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
<script> | |
var toTopBtn = document.getElementsByClassName('to-top-btn')[0]; | |
window.onscroll = function() { | |
var scrollTop = window.pageYOffset; | |
if ( scrollTop >= 120 ) { | |
toTopBtn.classList.add('to-top-btn--active'); | |
} | |
else { | |
toTopBtn.classList.remove('to-top-btn--active'); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment