Method AnimatePresence
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
AnimatePresence(VNode?[]?, string?, bool, float, float, int, AnimatePresenceMode, Action?)
Container that supports mount / unmount animations. When a keyed child becomes null, removal is deferred until the exit animation completes.
public static AnimatePresenceNode AnimatePresence(VNode?[]? children = null, string? key = null, bool initial = true, float staggerSec = 0, float delayChildrenSec = 0, int staggerDirection = 1, AnimatePresenceMode mode = AnimatePresenceMode.Sync, Action? onExitComplete = null)
Parameters
childrenVNode[]Child VNodes whose enter / exit transitions are tracked.
keystringKey used to disambiguate siblings at the same position.
initialboolWhen false, suppresses enter animations on the very first mount.
staggerSecfloatDelay (seconds) staggered between sequential children.
delayChildrenSecfloatstaggerDirectionintmodeAnimatePresenceModeExit / enter sequencing. Sync (default) overlaps exit and enter; Wait holds a brand-new child back until in-flight exits finish (suited to single-child route / screen swaps); PopLayout pulls an exiting child out of layout flow so still-present siblings reflow immediately.
onExitCompleteActionInvoked once when every in-flight exit animation has finished; not fired for cancelled exits or animation-less removals.
Returns
- AnimatePresenceNode
The created AnimatePresenceNode.
Remarks
AnimatePresence emits no element of its own — its keyed children expand directly into the parent.
Put flex / wrap / gap on the parent element.
Equivalent to Framer Motion's AnimatePresence (with mode="wait" and
onExitComplete) for users migrating from Framer Motion.