sdxc

Type to search, or start from one of these:

[ @sdxc/ui/animations ]

enterExit

Composes a CSS-only enter/exit transition mixin whose @starting-style block animates the first entered paint from the exit values.

import { enterExit } from "@sdxc/ui/animations";

Usage

Composes a CSS-only enter/exit transition mixin whose @starting-style block animates the first entered paint from the exit values. Owns the host's transition, so apply exactly one animation factory per host.

Signature

enterExit(options?: EnterExit.Options): CSSMixinDescriptor

Returns a css() mixin ready for a host element's mix prop.

Parameters

ParameterTypeDescription
options?EnterExit.OptionsWhich axes to animate, the timing, and the entered-state selector.

Examples

<div id="filters" popover="auto" mix={enterExit({ opacity: 0, scale: 0.95, duration: 150 })}>
	...
</div>;
<div data-visible mix={enterExit({ opacity: 0, when: "[data-visible]" })}>...</div>;

The events, constants and types its module publishes, each imported from @sdxc/ui/animations too.

Interface

EnterExit.Options

Every field is the host's closed/exit-state value for one CSS property; the entered state is always that property's reset (1 for opacity, none for scale/translate). Omitted fields leave their property as is.

MemberTypeDescription
opacity?numberExit-state opacity, 0 to 1.
scale?numberExit-state scale factor, e.g. 0.95.
translate?stringExit-state translate value, e.g. "0 0.5rem".
duration?numberTransition duration in milliseconds. Defaults to durations.normal.
easing?stringA transition-timing-function value. Defaults to easings.standard.
when?stringA selector fragment relative to the host (e.g. "[data-visible]") marking the entered state, replacing the [open]/:popover-open default for hosts that carry their own entered-state attribute.

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.