diff options
author | 2023-07-28 13:09:24 +0000 | |
---|---|---|
committer | 2023-07-28 13:09:24 +0000 | |
commit | 2f95a3e0ca04643c9879d1b3c4a234f6e9b7ec4d (patch) | |
tree | 5b1545f3e01401bd2fa40c71866a6bbc3c12c071 | |
parent | 49a4b28202cfc571897bcc74042b873a2ceecba4 (diff) | |
download | astro-2f95a3e0ca04643c9879d1b3c4a234f6e9b7ec4d.tar.gz astro-2f95a3e0ca04643c9879d1b3c4a234f6e9b7ec4d.tar.zst astro-2f95a3e0ca04643c9879d1b3c4a234f6e9b7ec4d.zip |
[ci] format
-rw-r--r-- | packages/astro/components/ViewTransitions.astro | 22 | ||||
-rw-r--r-- | packages/astro/e2e/view-transitions.test.js | 6 |
2 files changed, 16 insertions, 12 deletions
diff --git a/packages/astro/components/ViewTransitions.astro b/packages/astro/components/ViewTransitions.astro index 3a4ef12ce..ac40608d3 100644 --- a/packages/astro/components/ViewTransitions.astro +++ b/packages/astro/components/ViewTransitions.astro @@ -41,11 +41,11 @@ const { fallback = 'animate' } = Astro.props as Props; if (wait) return; cb(...args); - wait = true + wait = true; setTimeout(() => { - wait = false + wait = false; }, delay); - } + }; }; async function getHTML(href: string) { @@ -89,7 +89,7 @@ const { fallback = 'animate' } = Astro.props as Props; const swap = () => { document.documentElement.replaceWith(doc.documentElement); - if(state?.scrollY != null) { + if (state?.scrollY != null) { scrollTo(0, state.scrollY); } @@ -237,10 +237,14 @@ const { fallback = 'animate' } = Astro.props as Props; addEventListener('load', onload); // There's not a good way to record scroll position before a back button. // So the way we do it is by listening to scroll and just continuously recording it. - addEventListener('scroll', throttle(() => { - if(history.state) { - persistState({ ...history.state, scrollY }) - } - }, 300), { passive: true }); + addEventListener( + 'scroll', + throttle(() => { + if (history.state) { + persistState({ ...history.state, scrollY }); + } + }, 300), + { passive: true } + ); } </script> diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index 222d4108d..e71b892ba 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -190,7 +190,7 @@ test.describe('View Transitions', () => { await expect(p, 'should have content').toHaveText('Page 1'); }); - test('Scroll position restored on back button', async ({ page, astro }) => { + test('Scroll position restored on back button', async ({ page, astro }) => { // Go to page 1 await page.goto(astro.resolveUrl('/long-page')); let article = page.locator('#longpage'); @@ -211,7 +211,7 @@ test.describe('View Transitions', () => { expect(oldScrollY).toEqual(newScrollY); }); - test('Scroll position restored on forward button', async ({ page, astro }) => { + test('Scroll position restored on forward button', async ({ page, astro }) => { // Go to page 1 await page.goto(astro.resolveUrl('/one')); let p = page.locator('#one'); @@ -235,7 +235,7 @@ test.describe('View Transitions', () => { const newScrollY = await page.evaluate(() => window.scrollY); expect(oldScrollY).toEqual(newScrollY); - }) + }); test('<Image /> component forwards transitions to the <img>', async ({ page, astro }) => { // Go to page 1 |