From bbbfadefed29284c326a0887022eca0939a5da2d Mon Sep 17 00:00:00 2001 From: ppoffice Date: Sun, 13 Sep 2020 00:41:15 -0400 Subject: [PATCH] chore(plugin): smoother scroll using scroll-behavior --- source/js/back_to_top.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/js/back_to_top.js b/source/js/back_to_top.js index e4235c8..cf56af1 100644 --- a/source/js/back_to_top.js +++ b/source/js/back_to_top.js @@ -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); + } }); });