Skip to content

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

Open
@bramus

Description

@bramus

This is a side-issue to #9901 where this demo 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-DocumentTimelines (when attaching them to a ScrollTimeline).

The code to get all these animations is this:

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:

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

This would also benefit Scoped Transitions, where you can have multiple View Transitions going on at once.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Thursday afternoon

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions