Created
June 11, 2018 12:00
-
-
Save laurenclark/4788be6032a746582d2fc75625bc2eee 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
var offset = 700; | |
var duration = 500; | |
$(window).scroll(function() { | |
if ($(this).scrollTop() > offset) { | |
$('.back-to-top').fadeIn(duration); | |
} else { | |
$('.back-to-top').fadeOut(duration); | |
} | |
}); | |
$('.back-to-top').click(function(event) { | |
event.preventDefault(); | |
$('html, body').animate({scrollTop: 0}, duration); | |
return false; | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment