diff --git a/_javascript/modules/components/back-to-top.js b/_javascript/modules/components/back-to-top.js index 6088d76..777a659 100644 --- a/_javascript/modules/components/back-to-top.js +++ b/_javascript/modules/components/back-to-top.js @@ -3,15 +3,18 @@ */ export function back2top() { - $(window).on('scroll', () => { - if ($(window).scrollTop() > 50) { - $('#back-to-top').fadeIn(); + const $window = $(window); + const $btn = $('#back-to-top'); + + $window.on('scroll', () => { + if ($window.scrollTop() > 50) { + $btn.fadeIn(); } else { - $('#back-to-top').fadeOut(); + $btn.fadeOut(); } }); - $('#back-to-top').on('click', () => { - window.scrollTo(0, 0); + $btn.on('click', () => { + $window.scrollTop(0); }); } diff --git a/_layouts/default.html b/_layouts/default.html index bc434d6..634701c 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -34,9 +34,9 @@ layout: compress
- + + {% if site.pwa.enabled %}