SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

enterExit

Composes a CSS-only enter/exit transition mixin.

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

Usage

Composes a CSS-only enter/exit transition mixin: @starting-style paints the first entered frame from the entry values, and closing transitions to the exit values on the exit timing. Every change is a transition, so a reversal mid-flight retargets smoothly. Owns the host's transition, so apply exactly one animation factory per host.

Signature

typescript
enterExit(options?: EnterExit.Options): CSSMixinDescriptor

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

Parameters

ParameterTypeDefaultRequiredDescription
optionsEnterExit.Options—NoEntry and exit values, their timing, and the entered-state selector.

Examples

tsx
<div id="filters" popover="auto" mix={enterExit({ opacity: 0, scale: 0.95, duration: 150 })}>
	...
</div>;
tsx
<div data-visible mix={enterExit({ opacity: 0, when: "[data-visible]" })}>...</div>;
tsx
<dialog mix={enterExit({ translate: "100% 0", exit: { translate: "1rem 0", opacity: 0, blur: 4 } })}>...</dialog>;

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

Interface

EnterExit.Values

The off-stage value of each animated CSS property; the entered state is always that property's reset (1 for opacity, none for scale, translate and filter). Omitted fields leave their property as is.

MemberTypeDefaultRequiredDescription
opacitynumber—NoOff-stage opacity, 0 to 1.
scalenumber—NoOff-stage scale factor, e.g. 0.95.
translatestring—NoOff-stage translate value, e.g. "0 0.5rem".
blurnumber—NoOff-stage filter: blur() radius in pixels, e.g. 4.
Interface

EnterExit.Options

The top-level values are where the host enters from. exit overrides any of them for where it leaves to, and a property only exit names enters from its reset, so a surface can blur away without blurring in.

MemberTypeDefaultRequiredDescription
exitValues—NoWhere the host leaves to, per property; each omitted field reuses its entry value.
durationnumber—NoEntry duration in milliseconds. Defaults to durations.normal.
easingstring—NoA transition-timing-function value for the entry. Defaults to easings.standard.
exitDurationnumber—NoExit duration in milliseconds. Defaults to three quarters of duration.
exitEasingstring—NoA transition-timing-function value for the exit. Defaults to easing.
whenstring—NoA 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.
@sdxc/ui

Can’t find it? Contact us