Add back to top (#213)
* translate_Chinese * translate_Chinese * Add one-click return to the top function on the article page Signed-off-by: Ray <Chow-Ray@outlook.com> * Fix scroll-to-top button Signed-off-by: hossainemruz <hossainemruz@gmail.com> Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
This commit is contained in:
parent
0848be17ba
commit
62ca383b8b
3 changed files with 48 additions and 0 deletions
|
@ -59,5 +59,23 @@ var isMobile = false, isTablet = false, isLaptop = false;
|
|||
elems[i].classList.add("nav-link");
|
||||
}
|
||||
|
||||
// add scroll to top button
|
||||
function scrollToTop() {
|
||||
var btn = $('#scroll-to-top');
|
||||
$(window).scroll(function () {
|
||||
if ($(window).scrollTop() > 300) {
|
||||
btn.addClass('show');
|
||||
} else {
|
||||
btn.removeClass('show');
|
||||
}
|
||||
});
|
||||
|
||||
btn.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('html, body').animate({ scrollTop: 0 }, '300');
|
||||
});
|
||||
}
|
||||
scrollToTop();
|
||||
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue