1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 13:44:15 +00:00

Jump to the anchor position smoothly

This commit is contained in:
Cotes Chung
2020-12-24 22:51:08 +08:00
parent fa310d3190
commit dfba411d61
2 changed files with 5 additions and 7 deletions

View File

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