1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-06-08 00:27:58 +00:00
Cotes Chung d81f836b06
refactor: simplify basic layout (#1039)
A dynamically expanding/collapsing topbar is difficult to maintain and not very useful.
2023-05-17 01:59:34 +08:00

18 lines
350 B
JavaScript

/**
* Reference: https://bootsnipp.com/snippets/featured/link-to-top-page
*/
export function back2top() {
$(window).on('scroll', () => {
if ($(window).scrollTop() > 50) {
$('#back-to-top').fadeIn();
} else {
$('#back-to-top').fadeOut();
}
});
$('#back-to-top').on('click', () => {
window.scrollTo(0, 0);
});
}