Skip to content

Commit

Permalink
reverted function declaration after review (#8166)
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp committed Aug 22, 2023
1 parent c72fee0 commit 2fb0bb1
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/astro/components/ViewTransitions.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const { fallback = 'animate' } = Astro.props as Props;
type Events = 'astro:load' | 'astro:beforeload';

const persistState = (state: State) => history.replaceState(state, '');
const supportsViewTransitions = !!document.startViewTransition;
const transitionEnabledOnThisPage = () =>
!!document.querySelector('[name="astro-view-transitions-enabled"]');
const triggerEvent = (name: Events) => document.dispatchEvent(new Event(name));
const onload = () => triggerEvent('astro:load');
const PERSIST_ATTR = 'data-astro-transition-persist';

// The History API does not tell you if navigation is forward or back, so
// you can figure it using an index. On pushState the index is incremented so you
Expand All @@ -29,14 +35,6 @@ const { fallback = 'animate' } = Astro.props as Props;
persistState({ index: currentHistoryIndex, scrollY: 0 });
}

const supportsViewTransitions = !!document.startViewTransition;
function transitionEnabledOnThisPage() {
return !!document.querySelector('[name="astro-view-transitions-enabled"]');
}
const triggerEvent = (name: Events) => document.dispatchEvent(new Event(name));
const onload = () => triggerEvent('astro:load');
const PERSIST_ATTR = 'data-astro-transition-persist';

const throttle = (cb: (...args: any[]) => any, delay: number) => {
let wait = false;
// During the waiting time additional events are lost.
Expand Down

0 comments on commit 2fb0bb1

Please sign in to comment.