Overview
animatedIf(condition, trueTemplate, falseTemplate?, config?) swaps between two templates with Web Animations API enter/exit presets. Prefer it over bare cond ? tpl : nothing when you want the leaving content to finish animating before removal.
animatedX(component, props, config) is a thin wrapper: when config.show is true it renders the component with x(); when false it animates out to nothing. Same enter/exit presets as animatedIf.
Defaults when omitted: enter is animationPresets.fadeIn(250), exit is animationPresets.fadeOut(200).
animatedIf vs animatedX vs ternary
|
API
|
Renders
|
Notes
|
|---|---|---|
cond ? a : b
| Instant swap | No animation — content mounts/unmounts immediately. |
animatedIf(cond, a, b?, cfg?)
| Animated templates |
True/false templates (or nothing). Plays exit then enter via animateSwap.
|
animatedX(Comp, props, cfg)
| Animated component |
Requires cfg.show. Internally calls animatedIf with x(Component, props) as the true template.
|
Fade in / fade out
animatedIf accepts a boolean condition, a true-template, an optional false-template, and an optional config with enter/exit animation presets. The element animates in when the condition becomes true and animates out before it is removed.
animatedX for a component
animatedX(Component, props, { show, enter, exit }) renders the component with x() when show is true and animates out to nothing when false.