Skip to content

Commit

Permalink
fix: animate backdrop out whenever stack is closed programmatically/v…
Browse files Browse the repository at this point in the history
…ia hardware back press 🧹
  • Loading branch information
CharlesMangwa committed Jan 24, 2022
1 parent 3bdc9df commit 091c9af
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/ModalStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ const ModalStack = <P extends ModalfyParams>(props: Props<P>) => {
easing: Easing.inOut(Easing.ease),
duration: 300,
useNativeDriver: true,
}).start()
translateY.setValue(sh(100))
}).start(({ finished }) => {
if (finished) translateY.setValue(sh(100))
})
}
}, [openedItemsArray.length, stack.openedItems.size, translateY, opacity])

Expand Down Expand Up @@ -104,7 +105,19 @@ const ModalStack = <P extends ModalfyParams>(props: Props<P>) => {
const onBackdropPress = () => {
if (backBehavior === 'none') return

const currentItem = openedItemsArray.slice(-1)[0]
const currentItem = [...stack.openedItems].slice(-1)[0]

if (stack.openedItemsSize === 1) {
Animated.timing(opacity, {
toValue: 0,
easing: Easing.inOut(Easing.ease),
duration: 300,
useNativeDriver: true,
}).start(({ finished }) => {
if (finished) translateY.setValue(sh(100))
})
}

setBackdropClosedItems([...backdropClosedItems, currentItem?.hash])
}

Expand Down

0 comments on commit 091c9af

Please sign in to comment.