From dc5c35fc4b7784819636d43f023b69e401b2cc48 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Mon, 17 Jun 2024 19:43:16 +0300 Subject: [PATCH] fix: add behavior: 'instant' to window.scrollTo in toggleScroll Fix enable scroll when html has `scroll-behavior: smooth` --- src/utils/toggleScroll.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/toggleScroll.js b/src/utils/toggleScroll.js index f2032d72..5cb2586a 100644 --- a/src/utils/toggleScroll.js +++ b/src/utils/toggleScroll.js @@ -23,7 +23,11 @@ const enable = () => { Object.assign(body.style, prevBodyStyles); - window.scrollTo(0, parseInt(scrollY || '0', 10) * -1); + window.scrollTo({ + left: 0, + top: parseInt(scrollY || '0', 10) * -1, + behavior: 'instant', + }); }; export default { disable, enable };