From f0d75abeafbb1c53842ebc69744d43b993091d89 Mon Sep 17 00:00:00 2001 From: Maksym Kotielnikov Date: Thu, 3 Dec 2020 09:03:08 +0100 Subject: [PATCH] fix: position on orientation change (#274) --- src/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index b664208a..9bc653d5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -850,9 +850,14 @@ const ModalizeBase = ( }, })); + const lastSnapRef = React.useRef(lastSnap); React.useEffect(() => { - if (alwaysOpen && (modalHeightValue || adjustToContentHeight)) { - handleAnimateOpen(alwaysOpen); + lastSnapRef.current = lastSnap; + }, [lastSnap]); + + React.useEffect(() => { + if (lastSnapRef.current || (alwaysOpen && (modalHeightValue || adjustToContentHeight))) { + handleAnimateOpen(alwaysOpen, lastSnapRef.current ? 'default' : undefined); } }, [alwaysOpen, modalHeightValue]);