From 8666056214a07cad5b5cb84657a5bb305ab3a977 Mon Sep 17 00:00:00 2001 From: DafCoe Date: Tue, 8 Feb 2022 22:47:04 +0000 Subject: [PATCH] fix: prevent restorePositionSetting to run before setPositionFixed --- src/bodyScrollLock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bodyScrollLock.js b/src/bodyScrollLock.js index cb4b1459..6789eaff 100644 --- a/src/bodyScrollLock.js +++ b/src/bodyScrollLock.js @@ -133,7 +133,7 @@ const setPositionFixed = () => window.requestAnimationFrame(() => { } }); -const restorePositionSetting = () => { +const restorePositionSetting = () => window.requestAnimationFrame(() => { if (previousBodyPosition !== undefined) { // Convert the position from "px" to Int const y = -parseInt(document.body.style.top, 10); @@ -149,7 +149,7 @@ const restorePositionSetting = () => { previousBodyPosition = undefined; } -}; +}); // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions const isTargetElementTotallyScrolled = (targetElement: any): boolean =>