Skip to content

Commit

Permalink
chore(plugin): smoother scroll using scroll-behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ppoffice committed Sep 13, 2020
1 parent 7846071 commit bbbfade
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/js/back_to_top.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ $(document).ready(() => {
$(window).scroll(update);

$('#back-to-top').on('click', () => {
$('body, html').animate({ scrollTop: 0 }, 400);
if (CSS && CSS.supports && CSS.supports('(scroll-behavior: smooth)')) {
window.scroll({ top: 0, behavior: 'smooth' });
} else {
$('body, html').animate({ scrollTop: 0 }, 400);
}
});
});

0 comments on commit bbbfade

Please sign in to comment.