web/assets/js/_commons/back-to-top.js
2020-08-19 23:45:10 +08:00

18 lines
No EOL
410 B
JavaScript

/*
Reference: https://bootsnipp.com/snippets/featured/link-to-top-page
*/
$(window).scroll(function() {
if ($(this).scrollTop() > 50
&& $("#sidebar-trigger").css("display") === "none") {
$("#back-to-top").fadeIn();
} else {
$("#back-to-top").fadeOut();
}
});
$(function() {
$("#back-to-top").click(function() {
$("body,html").animate({scrollTop: 0}, 800);
return false;
});
});