#1111: Declarative Interactions

Visit on Github.

Opened Jun 11, 2025

こんにちは TAG-さん!

I'm requesting a TAG review of Declarative Interactions.

This CSS provides a declarative syntax, via the CSS 'animation-trigger' property, for specifying that an input event targeting a particular element should start an animation on another specified element. The syntax is designed to make it possible for an implementation to opportunistically start the animation independently of the window event loop, thereby eliminating a significant source of input response delay.

Further details:

Demo of the kind of performance problems this feature is meant to eradicate. Try interacting with the form elements in the upper part of the page -- the animations should be smooth. Then check the "inject random jank" checkbox at the bottom and try interacting with the other form controls again; response time will be laggy during periods of main thread jank.

Discussions

Comment by @szager-chromium Jun 23, 2025 (See Github)

@Shrinivassab, I must confess that my framework-fu is very weak, so I can't give you substantial answers about how animation-trigger would combine with Angular, Lit, React, etc.

The spec proposal for animation-trigger does feature a scoping mechanism similar to that used by anchor positioning, which doesn't inherently rely on shadow DOM.

This feature is orthogonal to prefers-reduced-motion and other accessibility settings -- it should not change the rendering of animations.

As for custom gestures: I don't know how those things are implemented, but the proposal is limited to events that use the built-in Event interface and dispatch mechanism. Within that constraint, any event type can be specified, including custom events; but custom events will not get the performance benefits available to standard non-custom events.