presence custom
Exit follows your last move The leaving card reads the latest parent custom value, even after Svelte has swapped it.
<AnimatePresence custom={direction}> forwards the latest direction into exiting dynamic variants. The leaving card can move left or right even after it has been removed from Svelte state.
direction before swapping the keyed child.exit with AnimatePresence custom data, matching upstream Motion.custom data to prove the parent presence
value wins during exit.This mirrors Motion’s published example: the parent passes custom={direction} and the exiting slide reads that value with usePresenceData().
direction, then wrap the selected item.usePresenceData() to read the latest AnimatePresence custom value.mode="popLayout" pops the exiting square out while the next one enters.