[csswg-drafts] [view-transitions-2] Add method to get all animations of a ViewTransition object (#9908)

bramus has just created a new issue for https://github.com/w3c/csswg-drafts:

== [view-transitions-2] Add method to get all animations of a ViewTransition object ==
This is a side-issue to https://github.com/w3c/csswg-drafts/issues/9901 where [this demo](https://twitter.com/bramus/status/1749461824817311947) was mentioned.

To make this work, I basically need to hijack all animations and either pause them (when manually updating their `currentTime`) or give them non-`DocumentTimeline`s (when attaching them to a `ScrollTimeline`).

The code to get all these animations is this:

```js
const transition = document.startViewTransition(…);
await transition.ready;

const animations =
  document
    .getAnimations()
    .filter((anim) => {
      return anim.effect.target === document.documentElement && anim.effect.pseudoElement?.startsWith("::view-transition")
    });
```

While this works, it’s not very ergonomic. Therefore I’m suggesting something like `ViewTransition.getAnimations()` to easily get them:

```js
const transition = document.startViewTransition(…);
await transition.ready;
const animations = transition.getAnimations();
```

This would also benefit [Scoped Transitions](https://github.com/w3c/csswg-drafts/issues/9890), where you can have multiple View Transitions going on at once.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9908 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 5 February 2024 14:37:50 UTC