Jump to the anchor position smoothly
This commit is contained in:
parent
fa310d3190
commit
dfba411d61
2 changed files with 5 additions and 7 deletions
|
@ -46,8 +46,9 @@ html[mode=dark] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
html, body {
|
:root {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Reference: https://bootsnipp.com/snippets/featured/link-to-top-page
|
Reference: https://bootsnipp.com/snippets/featured/link-to-top-page
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$(window).scroll(function() {
|
$(window).scroll(() => {
|
||||||
if ($(this).scrollTop() > 50 &&
|
if ($(this).scrollTop() > 50 &&
|
||||||
$("#sidebar-trigger").css("display") === "none") {
|
$("#sidebar-trigger").css("display") === "none") {
|
||||||
$("#back-to-top").fadeIn();
|
$("#back-to-top").fadeIn();
|
||||||
|
@ -12,10 +11,8 @@ $(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#back-to-top").click(function() {
|
$("#back-to-top").click(() => {
|
||||||
$("body,html").animate({
|
$("body,html").scrollTop(0);
|
||||||
scrollTop: 0
|
|
||||||
}, 800);
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue