From 31bb0d576e4b359d6395cc2be024beb9abb18bba Mon Sep 17 00:00:00 2001 From: saicaca Date: Mon, 22 Jan 2024 12:01:06 +0800 Subject: [PATCH] fix: don't initialize the overlay scrollbar if there is a native one --- src/layouts/Layout.astro | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index dc1d6c3..f2b1f95 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -279,13 +279,21 @@ function setBannerHeight() { } function initCustomScrollbar() { - OverlayScrollbars(document.querySelector('body'), { + OverlayScrollbars( + // docs say that a initialization to the body element would affect native functionality like window.scrollTo + // but just leave it here for now + { + target: document.querySelector('body'), + cancel: { + nativeScrollbarsOverlaid: true, // don't initialize the overlay scrollbar if there is a native one + } + }, { scrollbars: { theme: 'scrollbar-base scrollbar-auto py-1', autoHide: 'move', autoHideDelay: 500, - autoHideSuspend: false - } + autoHideSuspend: false, + }, }); document.querySelectorAll('pre').forEach((ele) => { OverlayScrollbars(ele, {