page-transition 0.1.0-beta.6 → 0.1.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,12 @@ import { useRouter } from "next/navigation";
4
4
  import { useTransitionEndObj } from "../hooks/useTransitionEndObj";
5
5
  import { transitionEnd } from "../functions/transitionEnd";
6
6
  import { checkTransitionFinish } from "../functions/checkTransitionFinish";
7
+ import { pollTransitionStart } from "../functions/pollTransitionStart";
7
8
  export function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, delay, state, useUse, resolveUseFn }) {
8
9
  const router = useRouter();
9
10
  const afterExitFn = useRef(null);
10
11
  const nextPage = useRef(null);
12
+ const pollRafId = useRef(null);
11
13
  const push = useTransitionEndObj({
12
14
  transitionEndData,
13
15
  fn: () => {
@@ -42,10 +44,17 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
42
44
  state.current = 'navigating';
43
45
  router.push(currentPathname.current);
44
46
  }
47
+ state.current = 'navigating';
45
48
  container.current?.classList.remove('exit');
46
49
  container.current?.classList.add('enter');
47
- reverse.current.lock = false;
48
- state.current = 'entering';
50
+ pollTransitionStart({
51
+ transitionEndData,
52
+ id: pollRafId,
53
+ fn: () => {
54
+ state.current = 'entering';
55
+ reverse.current.lock = false;
56
+ }
57
+ });
49
58
  }
50
59
  });
51
60
  handleLinkClick.current = useCallback((e, url) => {
@@ -3,8 +3,10 @@ import { useEffect, useRef, useState, use } from "react";
3
3
  import { useTransitionEndObj } from "./useTransitionEndObj";
4
4
  import { transitionEnd } from "../functions/transitionEnd";
5
5
  import { checkTransitionFinish } from "../functions/checkTransitionFinish";
6
+ import { pollTransitionStart } from "../functions/pollTransitionStart";
6
7
  export function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, delay, state, useUse, resolveUseFn }) {
7
8
  const [promise, setPromise] = useState(null);
9
+ const pollRafId = useRef(null);
8
10
  if (promise) {
9
11
  useUse.current = true;
10
12
  use(promise);
@@ -31,9 +33,16 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
31
33
  reverse,
32
34
  delay
33
35
  });
36
+ state.current = 'navigating';
34
37
  container.current?.classList.remove('exit');
35
38
  container.current?.classList.add('enter');
36
- state.current = 'entering';
39
+ pollTransitionStart({
40
+ transitionEndData,
41
+ id: pollRafId,
42
+ fn: () => {
43
+ state.current = 'entering';
44
+ }
45
+ });
37
46
  reverse.current.lock = false;
38
47
  resolveFn.current?.();
39
48
  setPromise(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "page-transition",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.1.0-beta.8",
4
4
  "description": "A page transition library for the Next.js App Router.",
5
5
  "license": "MIT",
6
6
  "files": [