Skip to content

Instantly share code, notes, and snippets.

@jimmyk69
Created May 4, 2017 20:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmyk69/96f043dff78126bb787cb5d2822aed44 to your computer and use it in GitHub Desktop.
Save jimmyk69/96f043dff78126bb787cb5d2822aed44 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($){
var offset = 100;
var speed = 250;
var duration = 500;
$(window).scroll(function(){
if ($(this).scrollTop() < offset) {
$('.topbutton') .fadeOut(duration);
} else {
$('.topbutton') .fadeIn(duration);
}
});
$('.topbutton').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