A drawer component for React.
Fix scroll to bug bug] (#57)
Emil Kowalski76eb9d3ef159
diff --git a/src/index.tsx b/src/index.tsxindex b19e895..351ea18 100644--- a/src/index.tsx+++ b/src/index.tsx@@ -332,7 +332,7 @@ function Root({if (!isOpen) {let id = setTimeout(() => {setIsFullyClosed(true);- }, ANIMATION_DURATION);+ }, 300);return () => clearTimeout(id);}diff --git a/src/use-position-fixed.ts b/src/use-position-fixed.tsindex 238325b..ac76891 100644--- a/src/use-position-fixed.ts+++ b/src/use-position-fixed.ts@@ -16,7 +16,7 @@ export function usePositionFixed({ isOpen, isFullyClosed }: { isOpen: boolean; i};// Update the dom inside an animation frame- const { scrollY, scrollX, innerHeight } = window;+ const { scrollX, innerHeight } = window;document.body.style.setProperty('position', 'fixed', 'important');document.body.style.top = `${-scrollPos.current}px`;@@ -28,7 +28,7 @@ export function usePositionFixed({ isOpen, isFullyClosed }: { isOpen: boolean; irequestAnimationFrame(() => {// Attempt to check if the bottom bar appeared due to the position changeconst bottomBarHeight = innerHeight - window.innerHeight;- if (bottomBarHeight && scrollY >= innerHeight) {+ if (bottomBarHeight && scrollPos.current >= innerHeight) {// Move the content further up so that the bottom bar doesn't hide itdocument.body.style.top = `${-(scrollPos.current + bottomBarHeight)}px`;}@@ -60,9 +60,12 @@ export function usePositionFixed({ isOpen, isFullyClosed }: { isOpen: boolean; iReact.useEffect(() => {function onScroll() {+ console.log(window.scrollY, 'coming from onScroll');scrollPos.current = window.scrollY;}+ onScroll();+window.addEventListener('scroll', onScroll);return () => {