Skip to content

Instantly share code, notes, and snippets.

@fiximportant
Created October 30, 2017 08:08
Show Gist options
  • Save fiximportant/8d477723f9630a520f966ffcce7cc56e to your computer and use it in GitHub Desktop.
Save fiximportant/8d477723f9630a520f966ffcce7cc56e to your computer and use it in GitHub Desktop.
ScrollUP
<script>
$(window).scroll(function () {
if ($(this).scrollTop() > 300) $('.js-scrollup>a').fadeIn(200);
else $('.js-scrollup>a').fadeOut(400);
});
$('.js-scrollup>a').click(function () {
$('html,body').animate({
scrollTop: 0
}, 800);
return false;
});
</script>
<div class="b-scrollup js-scrollup"><a href="#moveup"><img src="/files/110/i-scrollup.png" alt=""></a></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment