page-transition 0.1.0-beta.37 → 0.1.0-beta.39
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.
- package/README.md +1 -1
- package/dist/context/CssTransitionProvider.js +6 -6
- package/dist/functions/checkTransitionStart.d.ts +1 -5
- package/dist/functions/pollTransitionStart.d.ts +1 -4
- package/dist/functions/transitionEnd.d.ts +1 -11
- package/dist/functions/transitionEndReverse.d.ts +1 -11
- package/dist/functions/updatePlaybackRate.js +1 -1
- package/dist/hooks/manual/useHandleLinkClick.js +1 -0
- package/dist/hooks/useHandleLinkClick.d.ts +1 -10
- package/dist/hooks/usePopState.d.ts +1 -10
- package/dist/hooks/usePopState.js +1 -6
- package/dist/hooks/useTransitionEndData.d.ts +1 -6
- package/dist/hooks/useTransitionEndHandler.d.ts +1 -5
- package/dist/hooks/useTransitionEndObj.d.ts +1 -13
- package/dist/types/transitionEnd.types.d.ts +17 -0
- package/dist/types/transitionEnd.types.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A page transition library for the Next.js App Router.
|
|
|
10
10
|
- Scroll restoration
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
|
-
 
|
|
14
14
|
|
|
15
15
|
`npm install page-transition@beta`
|
|
16
16
|
|
|
@@ -110,12 +110,6 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
mount.current.mounted = true;
|
|
113
|
-
if (delayStep.current === null && defaultOptions.overlayCount > 1) {
|
|
114
|
-
delayStep.current = parseDelay(transitionEndData.current.elArray);
|
|
115
|
-
}
|
|
116
|
-
if (duration.current === null) {
|
|
117
|
-
duration.current = parseDuration(transitionEndData.current.elArray[0]);
|
|
118
|
-
}
|
|
119
113
|
if (!container.current)
|
|
120
114
|
return;
|
|
121
115
|
transitionEnd({
|
|
@@ -135,6 +129,12 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
135
129
|
});
|
|
136
130
|
currentPathname.current = window.location.pathname;
|
|
137
131
|
reverse.current.lock = false;
|
|
132
|
+
if (delayStep.current === null && defaultOptions.overlayCount > 1) {
|
|
133
|
+
delayStep.current = parseDelay(transitionEndData.current.elArray);
|
|
134
|
+
}
|
|
135
|
+
if (duration.current === null) {
|
|
136
|
+
duration.current = parseDuration(transitionEndData.current.elArray[0]);
|
|
137
|
+
}
|
|
138
138
|
}, [pathname]);
|
|
139
139
|
const value = useMemo(() => ({ handleLinkClick, overlayWrapper, overlayItems }), []);
|
|
140
140
|
return (_jsxs(TransitionContext.Provider, { value: value, children: [header, _jsxs("div", { ref: container, "data-transition": true, children: [_jsxs("div", { ref: overlayWrapper, className: "overlay-wrapper", children: [defaultOptions.overlayCount > 0 && Array.from({ length: defaultOptions.overlayCount }).map((_, i) => (_jsx("div", { ref: (el) => {
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
elArray: (HTMLDivElement | null)[];
|
|
3
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
4
|
-
}
|
|
1
|
+
import type { TransitionEndData } from "../types/transitionEnd.types";
|
|
5
2
|
export declare function checkTransitionStart(transitionEndData: TransitionEndData, fn: (() => void) | null): boolean;
|
|
6
|
-
export {};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
elArray: (HTMLDivElement | null)[];
|
|
4
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
5
|
-
}
|
|
2
|
+
import type { TransitionEndData } from "../types/transitionEnd.types";
|
|
6
3
|
interface Props {
|
|
7
4
|
id: RefObject<number | null>;
|
|
8
5
|
fn: () => void;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
elArray: (HTMLDivElement | null)[];
|
|
4
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
5
|
-
mirror: boolean;
|
|
6
|
-
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
fn: (() => void) | null;
|
|
8
|
-
}
|
|
9
|
-
interface TransitionEndHandler {
|
|
10
|
-
handler: ((e: TransitionEvent) => void) | null;
|
|
11
|
-
handlerEl: HTMLDivElement | null;
|
|
12
|
-
}
|
|
2
|
+
import type { TransitionEndObj, TransitionEndHandler } from "../types/transitionEnd.types";
|
|
13
3
|
interface Props {
|
|
14
4
|
transitionEndObj: RefObject<TransitionEndObj>;
|
|
15
5
|
transitionEndHandler: RefObject<TransitionEndHandler>;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
elArray: (HTMLDivElement | null)[];
|
|
4
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
5
|
-
mirror: boolean;
|
|
6
|
-
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
fn: (() => void) | null;
|
|
8
|
-
}
|
|
9
|
-
interface TransitionEndHandler {
|
|
10
|
-
handler: ((e: TransitionEvent) => void) | null;
|
|
11
|
-
handlerEl: HTMLDivElement | null;
|
|
12
|
-
}
|
|
2
|
+
import type { TransitionEndObj, TransitionEndHandler } from "../types/transitionEnd.types";
|
|
13
3
|
interface Props {
|
|
14
4
|
transitionEndObj: RefObject<TransitionEndObj>;
|
|
15
5
|
transitionEndHandler: RefObject<TransitionEndHandler>;
|
|
@@ -23,7 +23,7 @@ export function updatePlaybackRate({ rafId, rejectFn, elArray, transitionPropert
|
|
|
23
23
|
if (before === null) {
|
|
24
24
|
before = now;
|
|
25
25
|
}
|
|
26
|
-
const dt = now - before;
|
|
26
|
+
const dt = Math.min(now - before, 30);
|
|
27
27
|
before = now;
|
|
28
28
|
summ = target ? Math.min(summ + dt, d) : Math.max(summ - dt, 0);
|
|
29
29
|
progress = summ / d;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
elArray: (HTMLDivElement | null)[];
|
|
4
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
5
|
-
mirror: boolean;
|
|
6
|
-
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
}
|
|
8
|
-
interface TransitionEndHandler {
|
|
9
|
-
handler: ((e: TransitionEvent) => void) | null;
|
|
10
|
-
handlerEl: HTMLDivElement | null;
|
|
11
|
-
}
|
|
2
|
+
import type { TransitionEndData, TransitionEndHandler } from "../types/transitionEnd.types";
|
|
12
3
|
interface Props {
|
|
13
4
|
container: RefObject<HTMLDivElement | null>;
|
|
14
5
|
handleLinkClick: RefObject<((e: React.MouseEvent, url: string) => void)>;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
elArray: (HTMLDivElement | null)[];
|
|
4
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
5
|
-
mirror: boolean;
|
|
6
|
-
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
}
|
|
8
|
-
interface TransitionEndHandler {
|
|
9
|
-
handler: ((e: TransitionEvent) => void) | null;
|
|
10
|
-
handlerEl: HTMLDivElement | null;
|
|
11
|
-
}
|
|
2
|
+
import type { TransitionEndData, TransitionEndHandler } from "../types/transitionEnd.types";
|
|
12
3
|
interface Props {
|
|
13
4
|
container: RefObject<HTMLDivElement | null>;
|
|
14
5
|
currentPathname: RefObject<string>;
|
|
@@ -68,11 +68,7 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
68
68
|
}
|
|
69
69
|
rejectFn.current?.();
|
|
70
70
|
container.current?.classList.remove('enter');
|
|
71
|
-
|
|
72
|
-
requestAnimationFrame(() => {
|
|
73
|
-
container.current?.classList.add('exit');
|
|
74
|
-
});
|
|
75
|
-
});
|
|
71
|
+
container.current?.classList.add('exit');
|
|
76
72
|
state.current = 'exiting';
|
|
77
73
|
transitionEnd({
|
|
78
74
|
transitionEndObj: pop,
|
|
@@ -89,7 +85,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
89
85
|
resolveUseFn.current = reject;
|
|
90
86
|
new Promise((resolveNavigating) => {
|
|
91
87
|
if (state.current === "navigating") {
|
|
92
|
-
console.log('navigating');
|
|
93
88
|
if (currentPathname.current !== window.location.pathname) {
|
|
94
89
|
resolveFn.current?.();
|
|
95
90
|
setPromise(null);
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
elArray: (HTMLDivElement | null)[];
|
|
4
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
5
|
-
mirror: boolean;
|
|
6
|
-
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
}
|
|
2
|
+
import type { TransitionEndData } from "../types/transitionEnd.types";
|
|
8
3
|
interface Props {
|
|
9
4
|
elArray: RefObject<HTMLDivElement | null | (HTMLDivElement | null)[]>;
|
|
10
5
|
transitionProperty: 'opacity' | 'clip-path';
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
handler: ((e: TransitionEvent) => void) | null;
|
|
4
|
-
handlerEl: HTMLDivElement | null;
|
|
5
|
-
}
|
|
2
|
+
import type { TransitionEndHandler } from "../types/transitionEnd.types";
|
|
6
3
|
export declare function useTransitionEndHandler(): RefObject<TransitionEndHandler>;
|
|
7
|
-
export {};
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
elArray: (HTMLDivElement | null)[];
|
|
4
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
5
|
-
mirror: boolean;
|
|
6
|
-
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
}
|
|
2
|
+
import type { TransitionEndData, TransitionEndObj } from "../types/transitionEnd.types";
|
|
8
3
|
interface Props {
|
|
9
4
|
transitionEndData: RefObject<TransitionEndData>;
|
|
10
5
|
fn: () => void;
|
|
11
6
|
}
|
|
12
|
-
interface TransitionEndObj {
|
|
13
|
-
elArray: (HTMLDivElement | null)[];
|
|
14
|
-
transitionProperty: 'opacity' | 'clip-path';
|
|
15
|
-
mirror: boolean;
|
|
16
|
-
mirrorElArray: (HTMLDivElement | null)[];
|
|
17
|
-
fn: (() => void) | null;
|
|
18
|
-
}
|
|
19
7
|
export declare function useTransitionEndObj({ transitionEndData, fn }: Props): RefObject<TransitionEndObj>;
|
|
20
8
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface TransitionEndData {
|
|
2
|
+
elArray: (HTMLDivElement | null)[];
|
|
3
|
+
transitionProperty: 'opacity' | 'clip-path';
|
|
4
|
+
mirror: boolean;
|
|
5
|
+
mirrorElArray: (HTMLDivElement | null)[];
|
|
6
|
+
}
|
|
7
|
+
export interface TransitionEndObj {
|
|
8
|
+
elArray: (HTMLDivElement | null)[];
|
|
9
|
+
transitionProperty: 'opacity' | 'clip-path';
|
|
10
|
+
mirror: boolean;
|
|
11
|
+
mirrorElArray: (HTMLDivElement | null)[];
|
|
12
|
+
fn: (() => void) | null;
|
|
13
|
+
}
|
|
14
|
+
export interface TransitionEndHandler {
|
|
15
|
+
handler: ((e: TransitionEvent) => void) | null;
|
|
16
|
+
handlerEl: HTMLDivElement | null;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|