web/assets/js/_commons/back-to-top.js
2020-12-26 00:41:06 +08:00

18 lines
399 B
JavaScript

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