Skip to content

[css-anchor-position-1] Should animations use View Transitions as their backing mechanism? (by default or as an opt-in) #9945

@FremyCompany

Description

@FremyCompany

At today's presentation (F2F Mountain View 2024), Tab proposed some "magical" computed-time animation for the anchored-element when its position or size would otherwise change as a result of anchoring updates.

As far as I understand, this would be implemented as an internal position-coordinates property which would be the bounding box of the element, would be set by the anchor positioning choices, and would be animatable.

One issue with this is that this animation requires layout at every step of the animation, and there is no guarantee that the intermediate layouts are even valid.

For example (see figure below), if your popup switches from a "top center" tooltip (above the anchor, sized as a wide but not tall box) to a "left center" tooltip (on the left of the anchor, sized as a tall but not wide box), then you can end up with an intermediate "mid-wide, mid-tall" box that does not fit its content, so it overflows, and authors have little to no control over this.

image

An alternative design would be to instead trigger scoped view transitions. Doing this would take a screenshot of the initial state (or multiple small screenshots if there are multiple parts in the animation) and each part is then transitioned using the view-transition pipeline, which has various affordances to deal with these details. This also allows to animate different parts in different ways, especially if the content of a wide popup and a tall popup is different (some elements might move, appear, disappear, etc...).

I would posit that this is easier to implement than the position-coordinates animation magic, and is more efficient.... pending the view-transition animations are already implemented (which is not yet the case in all browser).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions