Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause animations in open shadow roots #924

Closed
jakearchibald opened this issue Feb 20, 2024 · 1 comment
Closed

Pause animations in open shadow roots #924

jakearchibald opened this issue Feb 20, 2024 · 1 comment
Labels
needs triage Tracking: Issue needs confirmation

Comments

@jakearchibald
Copy link

Feature request

https://www.chromatic.com/docs/animations/ - Chromatic has functionality to pause animations, along with options to change how they're paused.

However, this doesn't work for animations within open shadow roots.

Proposed solution

Assuming that Chromatic gets animations via document.getAnimations(), you can get shadow roots via:

function getAllDeepShadowRoots(root: Element) {
  const els = [...root.querySelectorAll('*')];
  const shadowRoots: ShadowRoot[] = [];

  for (const el of els) {
    if (!el.shadowRoot) continue;

    shadowRoots.push(el.shadowRoot);
    els.push(...el.shadowRoot.querySelectorAll('*'));
  }

  return shadowRoots;
}

And call getAnimations() on the shadow roots too.

I couldn't find where Chromatic actually implements this.

@jakearchibald jakearchibald added the needs triage Tracking: Issue needs confirmation label Feb 20, 2024
@winkerVSbecks
Copy link
Member

@jakearchibald this is implemented on Chromatic's cloud infrastructure and not in the CLI. I'll pass this on as a feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Tracking: Issue needs confirmation
Projects
None yet
Development

No branches or pull requests

2 participants