@@ -101,9 +101,8 @@ const { fallback = 'animate' } = Astro.props as Props;
101101
102102 const parser = new DOMParser();
103103
104- async function updateDOM(dir: Direction, html: string, state?: State, fallback?: Fallback) {
104+ async function updateDOM(html: string, state?: State, fallback?: Fallback) {
105105 const doc = parser.parseFromString(html, 'text/html');
106- doc.documentElement.dataset.astroTransition = dir;
107106
108107 // Check for a head element that should persist, either because it has the data
109108 // attribute or is a link el.
@@ -233,15 +232,17 @@ const { fallback = 'animate' } = Astro.props as Props;
233232 location.href = href;
234233 return;
235234 }
235+ document.documentElement.dataset.astroTransition = dir;
236236 if (supportsViewTransitions) {
237- finished = document.startViewTransition(() => updateDOM(dir, html, state)).finished;
237+ finished = document.startViewTransition(() => updateDOM(html, state)).finished;
238238 } else {
239- finished = updateDOM(dir, html, state, getFallback());
239+ finished = updateDOM(html, state, getFallback());
240240 }
241241 try {
242242 await finished;
243243 } finally {
244- document.documentElement.removeAttribute('data-astro-transition');
244+ // skip this for the moment as it tends to stop fallback animations
245+ // document.documentElement.removeAttribute('data-astro-transition');
245246 await runScripts();
246247 markScriptsExec();
247248 onload();
@@ -291,8 +292,7 @@ const { fallback = 'animate' } = Astro.props as Props;
291292 transitionEnabledOnThisPage()
292293 ) {
293294 ev.preventDefault();
294- navigate('forward', link.href, { index: currentHistoryIndex, scrollY: 0 });
295- currentHistoryIndex++;
295+ navigate('forward', link.href, { index: ++currentHistoryIndex, scrollY: 0 });
296296 const newState: State = { index: currentHistoryIndex, scrollY };
297297 persistState({ index: currentHistoryIndex - 1, scrollY });
298298 history.pushState(newState, '', link.href);
0 commit comments