Skip to content

Instantly share code, notes, and snippets.

@igorvieira
Created April 29, 2017 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igorvieira/e2eadd12aeb6e149fca6b04e60f31c7e to your computer and use it in GitHub Desktop.
Save igorvieira/e2eadd12aeb6e149fca6b04e60f31c7e to your computer and use it in GitHub Desktop.
up-button
$(document).ready(function(){
var offset = 220;
var duration = 700;
$(window).scroll(function() {
if ($(this).scrollTop() > offset) {
$('.topo').fadeIn(duration);
} else {
$('.topo').fadeOut(duration);
}
});
$('.topo').click(function(event) {
event.preventDefault();
jQuery('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