Skip to content

Instantly share code, notes, and snippets.

@peteee
Created November 27, 2018 22:40
Show Gist options
  • Save peteee/add0aedd44839f6bae9cfcbbd6ca461d to your computer and use it in GitHub Desktop.
Save peteee/add0aedd44839f6bae9cfcbbd6ca461d to your computer and use it in GitHub Desktop.
Paste'N'Ready
/**
* Scroll Top Arrow
*/
jQuery('body').append('<div id="scroll-top" style="display:none;position: fixed;bottom: 40px;right: 40px;color: #000;font-size: 56px;z-index: 999999;height: 70px;width: 70px;transform: rotate(-90deg) scale(1,1.2);text-shadow: -1px -1px 0 #FFF, 1px -1px 0 #FFF, -1px 1px 0 #FFF, 1px 1px 0 #FFF;cursor: pointer;">&#x27A4;</div>');
jQuery(document).scroll(function() {
var y = jQuery(this).scrollTop();
if (y > 1200) {
jQuery('#scroll-top').fadeIn();
} else {
jQuery('#scroll-top').fadeOut();
}
});
jQuery('#scroll-top').click(function () {
jQuery('body,html').animate({
scrollTop: 1
}, 800);
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment