krata/assets/js/_commons/back-to-top.js

22 lines
438 B
JavaScript
Raw Normal View History

2019-09-30 14:38:41 +02:00
/*
Reference: https://bootsnipp.com/snippets/featured/link-to-top-page
*/
$(function() {
2020-12-10 12:49:43 +01:00
$(window).scroll(function() {
if ($(this).scrollTop() > 50 &&
$("#sidebar-trigger").css("display") === "none") {
$("#back-to-top").fadeIn();
} else {
$("#back-to-top").fadeOut();
}
});
2020-08-19 06:26:45 +02:00
$("#back-to-top").click(function() {
2020-12-10 12:49:43 +01:00
$("body,html").animate({
scrollTop: 0
}, 800);
2019-09-30 14:38:41 +02:00
return false;
});
2020-12-10 12:49:43 +01:00
});