nandorojo/moti

Add `custom` option for `exitTransition`

nandorojo opened this issue · 1 comments

Currently, we can use the custom prop with AnimatePresence to apply different exit animations based on some state value.

const [pagination] = useState<1 | -1>(1)

return (
  <AnimatePresence custom={pagination}>
    {visible && (
      <MotiView
        exit={(pagination) => {
          'worklet'

          return { translateX: pagination * 10 }
        }}
      />
    )}
  </AnimatePresence>
)

However, we can't use this with exitTransition. It would be nice to do this for exitTransition too:

const [pagination] = useState<1 | -1>(1)

return (
  <AnimatePresence custom={pagination}>
    {visible && (
      <MotiView
        exit={(pagination) => {
          'worklet'

          return { translateX: pagination * 10 }
        }}
        exitTransition={(pagination) => {
          'worklet'

          return { delay: pagination > 1 ? 100 : 400 }
        }}
      />
    )}
  </AnimatePresence>
)

Added in 0.19.x