Focus, reset, animation and transition triggers
triggersince 0.5.10.8 syntaxSeven more events for on:: focusin(), focusout(), reset(), animationend(), animationcancel(), transitionend() and transitioncancel().
On this page · 8 sections+−
Caution · 0.8.x compatibility syntax
This page documents 0.8 syntax that Reactive CSS 0.9.0 still runs. New code uses the 0.9 form: see Legacy 0.8.x compatibility.
Syntax
on: focusin(<action>#), animationend(<action>#), …;registry syntax: focusin(action, ...)
Parameters
- focusin() focusout() reset()eventbubbling
- Run on the target and its ancestors: a wrapper sees focus enter and leave.
- animationend() animationcancel() transitionend() transitioncancel()eventtarget only
- Run only for the element’s own animations and transitions; a child’s animation does not trigger the parent.
Effect
Each trigger runs its actions when the event fires.
Example
toast.cssreactive
@keyframes fade { to { opacity: 0; } }.toast { --shown: state(true); }.toast:when(--shown) { animation: fade 2s forwards; }.toast { on: animationend(set(--shown, false)); }.toast:when(not --shown) { display: none; }state()Function · hover any red tokenMakes each matching element the owner of an independent state with an initial value.Reference →
Behavior
- 0.9. The new form is an
:on()rule such as.toast:on(animationend) { --shown: set(false); }.:on()also hassubmit,animationstart,dblclickandkeyup. Theseon:triggers keep working in 0.9. - No name filter: any animation or transition of the element runs the actions.
- One
transitionendper transitioning property. animationcancelfires only for animations that had started (native behavior).resetruns after the native reset.
Supported contexts
- Inside
on:.
Limitations
- In
on:,submit,animationstart,animationiteration,transitionrun,transitionstart,dblclickandkeyupare not supported.:on()hassubmit,animationstart,dblclickandkeyup. - Each used event type adds one delegated listener.
Related
Experimental · syntax may change between minor versions