mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-23 16:13:05 +00:00
refactor(build): modularize JS code
- replace gulp with rollup - remove JS output from repo
This commit is contained in:
26
_javascript/modules/components/back-to-top.js
Normal file
26
_javascript/modules/components/back-to-top.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Reference: https://bootsnipp.com/snippets/featured/link-to-top-page
|
||||
*/
|
||||
|
||||
export function back2top() {
|
||||
$(window).on('scroll', () => {
|
||||
if (
|
||||
$(window).scrollTop() > 50 &&
|
||||
$('#sidebar-trigger').css('display') === 'none'
|
||||
) {
|
||||
$('#back-to-top').fadeIn();
|
||||
} else {
|
||||
$('#back-to-top').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
$('#back-to-top').on('click', () => {
|
||||
$('body,html').animate(
|
||||
{
|
||||
scrollTop: 0
|
||||
},
|
||||
800
|
||||
);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user