diff options
author | 2022-02-28 21:38:17 -0800 | |
---|---|---|
committer | 2022-02-28 21:38:17 -0800 | |
commit | 918f1ea4f72850c650282c134de94548ef2fcad5 (patch) | |
tree | cac396f9e7be425b59cdbfea7725b3915acf3406 /smoke/astro.build-main/src/scripts/animations.ts | |
parent | a217c6608df684ddf3672bbef73bd7efc9a6a191 (diff) | |
download | astro-918f1ea4f72850c650282c134de94548ef2fcad5.tar.gz astro-918f1ea4f72850c650282c134de94548ef2fcad5.tar.zst astro-918f1ea4f72850c650282c134de94548ef2fcad5.zip |
Make smoke tests more deterministic (#2618)
* sync first remote smoke tests
* update smoke test scripts
Diffstat (limited to 'smoke/astro.build-main/src/scripts/animations.ts')
-rw-r--r-- | smoke/astro.build-main/src/scripts/animations.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/smoke/astro.build-main/src/scripts/animations.ts b/smoke/astro.build-main/src/scripts/animations.ts new file mode 100644 index 000000000..2171ebc38 --- /dev/null +++ b/smoke/astro.build-main/src/scripts/animations.ts @@ -0,0 +1,21 @@ +async function loop(element: Element) { + const animations = element.getAnimations({ subtree: true }); + await Promise.all(animations.map(anim => anim.finished)); + // reset the animation after 3.5 seconds + setTimeout(() => { + const clone = element.cloneNode(true) + element.replaceWith(clone); + loop(clone as Element); + }, 3500) +} + +function setup() { + const illustrations = Array.from(document.querySelectorAll('.illustration')); + const hydrate = illustrations.find(el => (el as HTMLElement).dataset.name === 'hydration'); + loop(hydrate); +} +setup(); + +window.addEventListener('astro:navchange', () => { + setup(); +}); |