[css-view-transitions] Normalize the exposed transform
for ::view-transition-group()
pseudos to be Viewport-relative.
#11456
Labels
css-view-transitions-1
View Transitions; Bugs only
When setting up a View Transition, all
transform
s are relative to the snapshot containing block origin.Relevant spec snippets:
These transforms are then used in the
::view-transition-group
’s keyframes (setting the starting position) and on the element itself (setting its ending position).For example, when animating a
position: fixed
element in a browser that has a retractable top bar of56px
high, atop,left
translation from100,100
to24,24
of that element results in the following transforms:transform
:matrix(1, 0, 0, 1, 100, 156)
transform
:matrix(1, 0, 0, 1, 24, 80)
See this screenshot taken in Chrome on Android: the box got animated from position
24,24
as measured against the viewport (red outline + red arrow) but ends up being24,80
when measured against the snapshot containing block (blue outline + blue arrow)When getting the keyframes of the resulting
::view-transition-group
pseudo usinganimation.effect.getKeyframes()
you end up with the following (simplified):From an author POV these values are problematic, because the
transform
s contain values that are not relative to the coordinate space authors have access to, namely the (layout) viewport:<height-of-the-retractable-top-bar>
animation.effect.setKeyframes(animation.effect.getKeyframes())
is destructive because the element has now shifted by<height-of-the-retractable-top-bar>
.To fix this issue I suggest that engines keep on using the snapshot containing block-relative offsets internally, but expose viewport-relative offsets to authors. The viewport as presented at the time of the new state would be used for this.
That way authors can rely on the keyframes for extracting the correct positional information and manipulate the generated keyframes without needing to worry about messing up the positions.
The text was updated successfully, but these errors were encountered: