Method Motion
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Motion(string?, string?, string?, StyleTransitionConfig?, float?, EasingMode?, float?, Action?, VNode?[]?, FiberElementProps?, FiberEventBinding[]?, Func<VisualElement, Action>?, string?, string?, string?, Type?, IReadOnlyDictionary<string, string>?, string?, string?, string?)
Element targeted by an animation.
Used inside AnimatePresence; toggles CSS classes on mount / unmount according to transition.
The one exception is a variant initial/animate pair (see
initial), which plays its mount enter on any Motion, standalone or not.
When transition is null, StyleTransition.Fade is applied as the default.
duration / easing can override individual fields of the
transition preset (e.g. setting only the duration while keeping the preset's other fields).
To disable animation entirely (immediate mount / unmount), pass transition: StyleTransitionConfig.None.
Note: when DurationSec is 0 (including StyleTransitionConfig.None), delay is ignored
and completion is immediate.
public static MotionNode Motion(string? className = null, string? key = null, string? name = null, StyleTransitionConfig? transition = null, float? duration = null, EasingMode? easing = null, float? delay = null, Action? onEnterComplete = null, VNode?[]? children = null, FiberElementProps? props = null, FiberEventBinding[]? events = null, Func<VisualElement, Action>? refCallback = null, string? whileHoverClass = null, string? whileTapClass = null, string? whileFocusClass = null, Type? elementType = null, IReadOnlyDictionary<string, string>? variants = null, string? animate = null, string? initial = null, string? exit = null)
Parameters
classNamestringCSS-like utility class string. Multiple classes separated by spaces.
keystringKey used to disambiguate siblings at the same position.
namestringElement name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.
transitionStyleTransitionConfigTransition preset; defaults to
StyleTransition.Fadewhen null.durationfloat?Override the transition duration (seconds).
easingEasingMode?Override the transition easing mode.
delayfloat?Override the transition delay (seconds). Ignored when
DurationSecis 0.onEnterCompleteActionCallback invoked when the enter transition finishes.
childrenVNode[]Child VNodes rendered inside the motion element.
propsFiberElementPropsOptional FiberElementProps (text / tooltip / enabled / etc.) bag.
eventsFiberEventBinding[]Array of pre-built FiberEventBinding objects applied to the element.
refCallbackFunc<VisualElement, Action>Callback invoked on mount with the created VisualElement; returned Action runs on unmount.
whileHoverClassstringUSS class toggled while the pointer hovers the element.
whileTapClassstringUSS class toggled while the pointer is pressed on the element.
whileFocusClassstringUSS class toggled while the element holds keyboard/UI focus.
elementTypeTypeThe VisualElement type the animated cell IS, e.g.
typeof(Button)so a clickable cell is one element instead of a Motion wrapping a Button. Defaults to UnityEngine.UIElements.VisualElement. Supply interactions viaevents.variantsIReadOnlyDictionary<string, string>Named animation states: each label maps to a utility class string for that state. The label selected by
animatehas its classes merged on top ofclassName. Because switchinganimatechanges the element's class list, a USStransition-*utility in the classes tweens between states. Parent→child propagation: a descendant Motion that suppliesvariantsbut leavesanimatenull inherits the nearest ANCESTOR Motion's active label and resolves it against its OWN variants — so settinganimateon a parent drives the whole subtree.animatestringThe active variant label (a key of
variants). When null, the nearest ancestor Motion's active label is inherited; when set, it overrides any inherited label.initialstringMount-time starting variant label. When this Motion also sets
animate+variants, the enter starts atvariants[initial]and transitions tovariants[animate](its persistent resting state) using this Motion's transition timing — whether this Motion is the DIRECT child of an AnimatePresence or mounts standalone (Framer parity:initial/animateapply to any motion.* component).exitstringExit variant label. When this Motion is the DIRECT child of an AnimatePresence and also sets
animate+variants, removal animates fromvariants[animate]tovariants[exit](using this Motion's transition timing) before the element unmounts. Unlikeinitial, this needs AnimatePresence to defer the unmount — set outside one, it is inert and logs a warning.
Returns
- MotionNode
The created MotionNode.
Remarks
Equivalent to Framer Motion's motion.<tag> component (with its variants,
initial, animate, and exit props, and parent→child context propagation) for
users migrating from Framer Motion.