CKTIS / CSS
animation-trigger — trigger-controlled CSS animation playback
`animation-trigger` links each CSS animation to one or more named triggers and actions, delaying ordinary playback until a matching trigger acts.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
[ none | [ <dashed-ident> <animation-action>+ ]+ ]#animation-trigger links each CSS animation to one or more named triggers and actions, delaying ordinary playback until a matching trigger acts.
A timeline trigger named --arrival changes the animation from paused/0 to finished/200 and leaves the target translated by 100px. The source computes to --arrival view(), while the animation binding computes to --arrival play.
Grammar: [ none | [ <dashed-ident> <animation-action>+ ]+ ]#.
none keeps the corresponding animation untriggered. A dashed name followed by actions such as play, pause, reset, replay, or play-once selects behavior for that trigger; a wrong action count is syntactically valid but has no effect. timeline-trigger can react to timeline ranges, while event-trigger is the draft’s event-based counterpart. Multiple comma-separated items coordinate with the animation list, and animation resets this reset-only sub-property. Animation Triggers Level 1 is an Editor’s Draft and work in progress, so production use needs a feature query and target-browser testing even though this Chromium run executes the behavior.
Examples
document.body.innerHTML =
'<style>@keyframes travel{from{transform:translateX(0)}to{transform:translateX(100px)}}#viewport{height:80px;overflow:auto}#spacer{height:100px}#source{height:20px;timeline-trigger:--arrival view()}#target{width:10px;height:10px;animation:travel .2s linear both;animation-trigger:--arrival play}</style>' +
'<div id="viewport"><div id="spacer"></div><div id="source"></div><div style="height:100px"></div></div><div id="target"></div>';
const viewport=document.querySelector('#viewport');
const target=document.querySelector('#target');
await new Promise(requestAnimationFrame);
const animation=target.getAnimations()[0];
const before=animation.playState+'/'+Math.round(animation.currentTime||0);
viewport.scrollTop=100;
await new Promise(resolve=>setTimeout(resolve,350));
const matrix=new DOMMatrixReadOnly(getComputedStyle(target).transform);
console.log('before='+before+'; after='+animation.playState+'/'+Math.round(animation.currentTime||0)+'; x='+Math.round(matrix.m41)+'; trigger='+getComputedStyle(target).animationTrigger+'; timeline='+getComputedStyle(document.querySelector('#source')).timelineTrigger);Result
before=paused/0; after=finished/200; x=100; trigger=--arrival play; timeline=--arrival view()
`animation-trigger` links each CSS animation to one or more named triggers and actions, delaying ordinary playback until a matching trigger acts.