Created
February 2, 2018 04:24
-
-
Save jbd91/4a079a15c672a9ceced718390f699ef8 to your computer and use it in GitHub Desktop.
Back to Top Button
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
| // Back to Top Button | |
| var offset = 100; | |
| var speed = 250; | |
| var duration = 500; | |
| $(window).scroll(function(){ | |
| if ($(this).scrollTop() < offset) { | |
| $('.top-button') .fadeOut(duration); | |
| } else { | |
| $('.top-button') .fadeIn(duration); | |
| } | |
| }); | |
| $('.top-button').on('click', function(){ | |
| $('html, body').animate({scrollTop:0}, speed); | |
| return false; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment