Method AnimatePresence
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
AnimatePresence(VNode?[]?, string?, bool, float, float, int, AnimatePresenceMode, Action?, bool)
Container that supports mount / unmount animations. When a keyed child becomes null, removal is deferred until its exit completes, and always to a later render than the one that removed it.
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, bool propagate = false)
Parameters
childrenVNode[]Child VNodes whose enter / exit transitions are tracked.
keystringKey used to disambiguate siblings at the same position.
initialboolWhen false, suppresses the enter animations of the children the first render mounts, and of the Motions mounting under them for as long as they stay, other than an inner presence's children.
staggerSecfloatDelay (seconds) staggered between sequential children.
delayChildrenSecfloatstaggerDirectionintmodeAnimatePresenceModeExit / enter sequencing. Sync (default) overlaps exit and enter; Wait renders only the exiting children 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 the exits of the removed children have all completed, an exit with nothing to animate after the commit that removed its child; not fired for cancelled exits.
propagateboolSet on an inner presence: while the enclosing presence's keyed child holding it is leaving, every child of this presence exits too, and the enclosing presence keeps that child mounted until they have completed. A presence between the two that does not propagate stops it.
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.
Exceptions
- ArgumentOutOfRangeException
modenames no member of AnimatePresenceMode.