page-transition 0.1.0-beta.34 → 0.1.0-beta.36
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 +9 -7
- package/dist/context/CssTransitionProvider.js +8 -5
- package/dist/functions/transitionEnd.d.ts +2 -3
- package/dist/functions/transitionEnd.js +3 -2
- package/dist/functions/transitionEndReverse.d.ts +2 -3
- package/dist/functions/transitionEndReverse.js +3 -3
- package/dist/hooks/useHandleLinkClick.d.ts +3 -3
- package/dist/hooks/useHandleLinkClick.js +16 -15
- package/dist/hooks/usePopState.d.ts +3 -3
- package/dist/hooks/usePopState.js +17 -26
- package/dist/hooks/useTransitionEndData.d.ts +0 -2
- package/dist/hooks/useTransitionEndData.js +0 -2
- package/dist/hooks/useTransitionEndObj.d.ts +0 -4
- package/dist/hooks/useTransitionEndObj.js +1 -3
- 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
|
|
|
@@ -117,7 +117,9 @@ After navigation, the `exit` class is removed and the `enter` class is added. On
|
|
|
117
117
|
|
|
118
118
|
For overlay animations, a `.overlay-wrapper` is available. You can add overlay items by setting the `overlayCount` option.
|
|
119
119
|
|
|
120
|
-
If mirror is set to true, the same number of div elements specified by overlayCount are added to the `.
|
|
120
|
+
If mirror is set to true, the same number of div elements specified by `overlayCount` are added to the `.overlay-wrapper` with the class `mirror-item`. The transitionend dont wait for mirror items. This ideal for mirror effects.
|
|
121
|
+
|
|
122
|
+
*At the moment, it only supports duration and delay in seconds.*
|
|
121
123
|
|
|
122
124
|
To access the overlay wrapper and its items, use `useTransitionContext`.
|
|
123
125
|
|
|
@@ -262,11 +264,11 @@ mirror: true
|
|
|
262
264
|
|
|
263
265
|
transition: none;
|
|
264
266
|
will-change: clip-path;
|
|
265
|
-
clip-path: inset(0
|
|
267
|
+
clip-path: inset(0 -1px 100% -1px);
|
|
266
268
|
}
|
|
267
269
|
[data-transition].exit .overlay-item{
|
|
268
270
|
grid-row: 1;
|
|
269
|
-
clip-path: inset(0
|
|
271
|
+
clip-path: inset(0 -1px 0 -1px);
|
|
270
272
|
transition: clip-path 1.2s ease;
|
|
271
273
|
@for $i from 0 to 10{
|
|
272
274
|
&:nth-child(#{$i+1}){
|
|
@@ -276,7 +278,7 @@ mirror: true
|
|
|
276
278
|
}
|
|
277
279
|
[data-transition].enter .overlay-item{
|
|
278
280
|
grid-row: 1;
|
|
279
|
-
clip-path: inset(0
|
|
281
|
+
clip-path: inset(0 -1px 100% -1px);
|
|
280
282
|
transition: clip-path 1.2s ease;
|
|
281
283
|
@for $i from 0 to 10{
|
|
282
284
|
&:nth-child(#{$i+1}){
|
|
@@ -295,7 +297,7 @@ mirror: true
|
|
|
295
297
|
}
|
|
296
298
|
[data-transition].exit .mirror-item{
|
|
297
299
|
grid-row: 2;
|
|
298
|
-
clip-path: inset(0
|
|
300
|
+
clip-path: inset(0 -1px 0 -1px);
|
|
299
301
|
transition: clip-path 1.2s ease;
|
|
300
302
|
@for $i from 0 to 10{
|
|
301
303
|
&:nth-child(#{$i+11}){
|
|
@@ -305,7 +307,7 @@ mirror: true
|
|
|
305
307
|
}
|
|
306
308
|
[data-transition].enter .mirror-item{
|
|
307
309
|
grid-row: 2;
|
|
308
|
-
clip-path: inset(100%
|
|
310
|
+
clip-path: inset(100% -1px 0 -1px);
|
|
309
311
|
transition: clip-path 1.2s ease;
|
|
310
312
|
@for $i from 0 to 10{
|
|
311
313
|
&:nth-child(#{$i+11}){
|
|
@@ -72,7 +72,9 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
72
72
|
resolveUseFn,
|
|
73
73
|
pollRafId,
|
|
74
74
|
rafId,
|
|
75
|
-
rejectFn
|
|
75
|
+
rejectFn,
|
|
76
|
+
delayStep,
|
|
77
|
+
duration
|
|
76
78
|
});
|
|
77
79
|
useHandleLinkClick({
|
|
78
80
|
container,
|
|
@@ -87,7 +89,9 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
87
89
|
basePath,
|
|
88
90
|
pollRafId,
|
|
89
91
|
rafId,
|
|
90
|
-
rejectFn
|
|
92
|
+
rejectFn,
|
|
93
|
+
delayStep,
|
|
94
|
+
duration
|
|
91
95
|
});
|
|
92
96
|
useScrollRestoration();
|
|
93
97
|
const removeEnter = useTransitionEndObj({
|
|
@@ -108,18 +112,17 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
108
112
|
mount.current.mounted = true;
|
|
109
113
|
if (delayStep.current === null && defaultOptions.overlayCount > 1) {
|
|
110
114
|
delayStep.current = parseDelay(transitionEndData.current.elArray);
|
|
111
|
-
transitionEndData.current.delayStep = delayStep.current ?? 0;
|
|
112
115
|
}
|
|
113
116
|
if (duration.current === null) {
|
|
114
117
|
duration.current = parseDuration(transitionEndData.current.elArray[0]);
|
|
115
|
-
transitionEndData.current.duration = duration.current ?? 0;
|
|
116
118
|
}
|
|
117
119
|
if (!container.current)
|
|
118
120
|
return;
|
|
119
121
|
transitionEnd({
|
|
120
122
|
transitionEndObj: removeEnter,
|
|
121
123
|
transitionEndHandler,
|
|
122
|
-
reverse
|
|
124
|
+
reverse,
|
|
125
|
+
delayStep
|
|
123
126
|
});
|
|
124
127
|
container.current.classList.remove('exit');
|
|
125
128
|
container.current.classList.add('enter');
|
|
@@ -4,8 +4,6 @@ interface TransitionEndObj {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
delayStep: number;
|
|
8
|
-
duration: number;
|
|
9
7
|
fn: (() => void) | null;
|
|
10
8
|
}
|
|
11
9
|
interface TransitionEndHandler {
|
|
@@ -19,6 +17,7 @@ interface Props {
|
|
|
19
17
|
_lock: boolean;
|
|
20
18
|
lock: boolean;
|
|
21
19
|
}>;
|
|
20
|
+
delayStep: RefObject<number | null>;
|
|
22
21
|
}
|
|
23
|
-
export declare function transitionEnd({ transitionEndObj, transitionEndHandler, reverse, }: Props): void;
|
|
22
|
+
export declare function transitionEnd({ transitionEndObj, transitionEndHandler, reverse, delayStep }: Props): void;
|
|
24
23
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { transtionEndReverse } from "./transitionEndReverse";
|
|
2
|
-
export function transitionEnd({ transitionEndObj, transitionEndHandler, reverse, }) {
|
|
2
|
+
export function transitionEnd({ transitionEndObj, transitionEndHandler, reverse, delayStep }) {
|
|
3
3
|
const lastIndex = transitionEndObj.current.elArray.length - 1;
|
|
4
4
|
if (transitionEndHandler.current.handler &&
|
|
5
5
|
transitionEndHandler.current.handlerEl) {
|
|
@@ -10,7 +10,8 @@ export function transitionEnd({ transitionEndObj, transitionEndHandler, reverse,
|
|
|
10
10
|
transtionEndReverse({
|
|
11
11
|
transitionEndObj,
|
|
12
12
|
transitionEndHandler,
|
|
13
|
-
reverse
|
|
13
|
+
reverse,
|
|
14
|
+
delayStep
|
|
14
15
|
});
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
@@ -4,8 +4,6 @@ interface TransitionEndObj {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
delayStep: number;
|
|
8
|
-
duration: number;
|
|
9
7
|
fn: (() => void) | null;
|
|
10
8
|
}
|
|
11
9
|
interface TransitionEndHandler {
|
|
@@ -19,6 +17,7 @@ interface Props {
|
|
|
19
17
|
_lock: boolean;
|
|
20
18
|
lock: boolean;
|
|
21
19
|
}>;
|
|
20
|
+
delayStep: RefObject<number | null>;
|
|
22
21
|
}
|
|
23
|
-
export declare function transtionEndReverse({ transitionEndObj, transitionEndHandler, reverse }: Props): void;
|
|
22
|
+
export declare function transtionEndReverse({ transitionEndObj, transitionEndHandler, reverse, delayStep }: Props): void;
|
|
24
23
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setDelayReverse } from "./setDelayReverse";
|
|
2
2
|
import { resetDelay } from "./resetDelay";
|
|
3
|
-
export function transtionEndReverse({ transitionEndObj, transitionEndHandler, reverse }) {
|
|
3
|
+
export function transtionEndReverse({ transitionEndObj, transitionEndHandler, reverse, delayStep }) {
|
|
4
4
|
if (transitionEndHandler.current.handler &&
|
|
5
5
|
transitionEndHandler.current.handlerEl)
|
|
6
6
|
transitionEndHandler.current.handlerEl.removeEventListener('transitionend', transitionEndHandler.current.handler);
|
|
@@ -8,13 +8,13 @@ export function transtionEndReverse({ transitionEndObj, transitionEndHandler, re
|
|
|
8
8
|
setDelayReverse({
|
|
9
9
|
elArray: endObj.elArray,
|
|
10
10
|
transitionProperty: endObj.transitionProperty,
|
|
11
|
-
delayStep:
|
|
11
|
+
delayStep: delayStep.current
|
|
12
12
|
});
|
|
13
13
|
if (endObj.mirror) {
|
|
14
14
|
setDelayReverse({
|
|
15
15
|
elArray: endObj.mirrorElArray,
|
|
16
16
|
transitionProperty: endObj.transitionProperty,
|
|
17
|
-
delayStep:
|
|
17
|
+
delayStep: delayStep.current
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
const firstEl = endObj.elArray[0];
|
|
@@ -4,8 +4,6 @@ interface TransitionEndData {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
delayStep: number;
|
|
8
|
-
duration: number;
|
|
9
7
|
}
|
|
10
8
|
interface TransitionEndHandler {
|
|
11
9
|
handler: ((e: TransitionEvent) => void) | null;
|
|
@@ -28,6 +26,8 @@ interface Props {
|
|
|
28
26
|
pollRafId: RefObject<number | null>;
|
|
29
27
|
rafId: RefObject<number | null>;
|
|
30
28
|
rejectFn: RefObject<(() => void) | null>;
|
|
29
|
+
delayStep: RefObject<number | null>;
|
|
30
|
+
duration: RefObject<number | null>;
|
|
31
31
|
}
|
|
32
|
-
export declare function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn }: Props): void;
|
|
32
|
+
export declare function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn, delayStep, duration }: Props): void;
|
|
33
33
|
export {};
|
|
@@ -6,7 +6,7 @@ import { transitionEnd } from "../functions/transitionEnd";
|
|
|
6
6
|
import { pollTransitionStart } from "../functions/pollTransitionStart";
|
|
7
7
|
import { updatePlaybackRate } from "../functions/updatePlaybackRate";
|
|
8
8
|
import { setPlaybackRate } from "../functions/setPlaybackRate";
|
|
9
|
-
export function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn }) {
|
|
9
|
+
export function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn, delayStep, duration }) {
|
|
10
10
|
const router = useRouter();
|
|
11
11
|
const afterExitFn = useRef(null);
|
|
12
12
|
const nextPage = useRef(null);
|
|
@@ -36,7 +36,8 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
36
36
|
transitionEnd({
|
|
37
37
|
transitionEndObj: removeEnter,
|
|
38
38
|
transitionEndHandler,
|
|
39
|
-
reverse
|
|
39
|
+
reverse,
|
|
40
|
+
delayStep
|
|
40
41
|
});
|
|
41
42
|
if (useUse.current) {
|
|
42
43
|
resolveUseFn.current?.();
|
|
@@ -59,23 +60,19 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
59
60
|
const afterEntering = useTransitionEndObj({
|
|
60
61
|
transitionEndData,
|
|
61
62
|
fn: () => {
|
|
62
|
-
console.log('afterEntering transitionEnd');
|
|
63
63
|
if (rafId.current) {
|
|
64
64
|
cancelAnimationFrame(rafId.current);
|
|
65
65
|
rafId.current = null;
|
|
66
66
|
}
|
|
67
67
|
rejectFn.current?.();
|
|
68
68
|
container.current?.classList.remove('enter');
|
|
69
|
-
|
|
70
|
-
requestAnimationFrame(() => {
|
|
71
|
-
container.current?.classList.add('exit');
|
|
72
|
-
});
|
|
73
|
-
});
|
|
69
|
+
container.current?.classList.add('exit');
|
|
74
70
|
state.current = 'exiting';
|
|
75
71
|
transitionEnd({
|
|
76
72
|
transitionEndObj: push,
|
|
77
73
|
transitionEndHandler,
|
|
78
|
-
reverse
|
|
74
|
+
reverse,
|
|
75
|
+
delayStep
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
78
|
});
|
|
@@ -107,7 +104,8 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
107
104
|
transitionEnd({
|
|
108
105
|
transitionEndObj: afterExit,
|
|
109
106
|
transitionEndHandler,
|
|
110
|
-
reverse
|
|
107
|
+
reverse,
|
|
108
|
+
delayStep
|
|
111
109
|
});
|
|
112
110
|
return;
|
|
113
111
|
}
|
|
@@ -115,7 +113,8 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
115
113
|
transitionEnd({
|
|
116
114
|
transitionEndObj: afterEntering,
|
|
117
115
|
transitionEndHandler,
|
|
118
|
-
reverse
|
|
116
|
+
reverse,
|
|
117
|
+
delayStep
|
|
119
118
|
});
|
|
120
119
|
let elArray = [];
|
|
121
120
|
if (transitionEndData.current.mirror) {
|
|
@@ -130,12 +129,13 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
130
129
|
elArray,
|
|
131
130
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
132
131
|
target: 0,
|
|
133
|
-
duration:
|
|
132
|
+
duration: duration.current ?? 0
|
|
134
133
|
}).then(() => {
|
|
135
134
|
transitionEnd({
|
|
136
135
|
transitionEndObj: push,
|
|
137
136
|
transitionEndHandler,
|
|
138
|
-
reverse
|
|
137
|
+
reverse,
|
|
138
|
+
delayStep
|
|
139
139
|
});
|
|
140
140
|
container.current?.classList.remove('enter');
|
|
141
141
|
container.current?.classList.add('exit');
|
|
@@ -151,7 +151,7 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
151
151
|
elArray,
|
|
152
152
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
153
153
|
target: 1,
|
|
154
|
-
duration:
|
|
154
|
+
duration: duration.current ?? 0
|
|
155
155
|
}).catch(() => { });
|
|
156
156
|
}).catch(() => { });
|
|
157
157
|
return;
|
|
@@ -159,7 +159,8 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
159
159
|
transitionEnd({
|
|
160
160
|
transitionEndObj: push,
|
|
161
161
|
transitionEndHandler,
|
|
162
|
-
reverse
|
|
162
|
+
reverse,
|
|
163
|
+
delayStep
|
|
163
164
|
});
|
|
164
165
|
container.current?.classList.remove('enter');
|
|
165
166
|
container.current?.classList.add('exit');
|
|
@@ -4,8 +4,6 @@ interface TransitionEndData {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
delayStep: number;
|
|
8
|
-
duration: number;
|
|
9
7
|
}
|
|
10
8
|
interface TransitionEndHandler {
|
|
11
9
|
handler: ((e: TransitionEvent) => void) | null;
|
|
@@ -26,6 +24,8 @@ interface Props {
|
|
|
26
24
|
pollRafId: RefObject<number | null>;
|
|
27
25
|
rafId: RefObject<number | null>;
|
|
28
26
|
rejectFn: RefObject<(() => void) | null>;
|
|
27
|
+
delayStep: RefObject<number | null>;
|
|
28
|
+
duration: RefObject<number | null>;
|
|
29
29
|
}
|
|
30
|
-
export declare function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn }: Props): void;
|
|
30
|
+
export declare function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn, delayStep, duration }: Props): void;
|
|
31
31
|
export {};
|
|
@@ -5,8 +5,7 @@ import { transitionEnd } from "../functions/transitionEnd";
|
|
|
5
5
|
import { pollTransitionStart } from "../functions/pollTransitionStart";
|
|
6
6
|
import { updatePlaybackRate } from "../functions/updatePlaybackRate";
|
|
7
7
|
import { setPlaybackRate } from "../functions/setPlaybackRate";
|
|
8
|
-
|
|
9
|
-
export function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn }) {
|
|
8
|
+
export function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn, delayStep, duration }) {
|
|
10
9
|
const [promise, setPromise] = useState(null);
|
|
11
10
|
if (promise) {
|
|
12
11
|
useUse.current = true;
|
|
@@ -20,7 +19,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
20
19
|
const removeEnter = useTransitionEndObj({
|
|
21
20
|
transitionEndData,
|
|
22
21
|
fn: () => {
|
|
23
|
-
console.log('removeEnter transitionEnd');
|
|
24
22
|
container.current?.classList.remove('enter');
|
|
25
23
|
state.current = 'idle';
|
|
26
24
|
reverse.current.lock = true;
|
|
@@ -29,11 +27,11 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
29
27
|
const afterExit = useTransitionEndObj({
|
|
30
28
|
transitionEndData,
|
|
31
29
|
fn: afterExitFn.current = () => {
|
|
32
|
-
console.log('afterExit transitionEnd');
|
|
33
30
|
transitionEnd({
|
|
34
31
|
transitionEndObj: removeEnter,
|
|
35
32
|
transitionEndHandler,
|
|
36
|
-
reverse
|
|
33
|
+
reverse,
|
|
34
|
+
delayStep
|
|
37
35
|
});
|
|
38
36
|
state.current = 'navigating';
|
|
39
37
|
container.current?.classList.remove('exit');
|
|
@@ -54,7 +52,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
54
52
|
const pop = useTransitionEndObj({
|
|
55
53
|
transitionEndData,
|
|
56
54
|
fn: () => {
|
|
57
|
-
console.log('pop transitionEnd');
|
|
58
55
|
state.current = 'navigating';
|
|
59
56
|
window.scrollTo(0, window.history.state.scrollY ?? 0);
|
|
60
57
|
resolveFn.current?.();
|
|
@@ -65,7 +62,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
65
62
|
const afterEntering = useTransitionEndObj({
|
|
66
63
|
transitionEndData,
|
|
67
64
|
fn: () => {
|
|
68
|
-
console.log('afterEntering transitionEnd');
|
|
69
65
|
if (rafId.current) {
|
|
70
66
|
cancelAnimationFrame(rafId.current);
|
|
71
67
|
rafId.current = null;
|
|
@@ -81,7 +77,8 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
81
77
|
transitionEnd({
|
|
82
78
|
transitionEndObj: pop,
|
|
83
79
|
transitionEndHandler,
|
|
84
|
-
reverse
|
|
80
|
+
reverse,
|
|
81
|
+
delayStep
|
|
85
82
|
});
|
|
86
83
|
}
|
|
87
84
|
});
|
|
@@ -94,13 +91,11 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
94
91
|
if (state.current === "navigating") {
|
|
95
92
|
console.log('navigating');
|
|
96
93
|
if (currentPathname.current !== window.location.pathname) {
|
|
97
|
-
console.log('currentPathname.current !== window.location.pathname');
|
|
98
94
|
resolveFn.current?.();
|
|
99
95
|
setPromise(null);
|
|
100
96
|
return;
|
|
101
97
|
}
|
|
102
98
|
else if (currentPathname.current === window.location.pathname) {
|
|
103
|
-
console.log('currentPathname.current === window.location.pathname');
|
|
104
99
|
afterExitFn.current?.();
|
|
105
100
|
}
|
|
106
101
|
}
|
|
@@ -108,13 +103,12 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
108
103
|
resolveNavigating();
|
|
109
104
|
}
|
|
110
105
|
}).then(() => {
|
|
111
|
-
console.log('not navigating');
|
|
112
106
|
if (currentPathname.current === window.location.pathname) {
|
|
113
|
-
console.log('currentPathname.current === window.location.pathname');
|
|
114
107
|
transitionEnd({
|
|
115
108
|
transitionEndObj: afterExit,
|
|
116
109
|
transitionEndHandler,
|
|
117
|
-
reverse
|
|
110
|
+
reverse,
|
|
111
|
+
delayStep
|
|
118
112
|
});
|
|
119
113
|
return;
|
|
120
114
|
}
|
|
@@ -122,10 +116,9 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
122
116
|
transitionEnd({
|
|
123
117
|
transitionEndObj: afterEntering,
|
|
124
118
|
transitionEndHandler,
|
|
125
|
-
reverse
|
|
119
|
+
reverse,
|
|
120
|
+
delayStep
|
|
126
121
|
});
|
|
127
|
-
console.log('state:', state.current);
|
|
128
|
-
console.log('oben');
|
|
129
122
|
let elArray = [];
|
|
130
123
|
if (transitionEndData.current.mirror) {
|
|
131
124
|
elArray = [...transitionEndData.current.mirrorElArray, ...transitionEndData.current.elArray];
|
|
@@ -139,19 +132,16 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
139
132
|
elArray,
|
|
140
133
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
141
134
|
target: 0,
|
|
142
|
-
duration:
|
|
135
|
+
duration: duration.current ?? 0
|
|
143
136
|
}).then(() => {
|
|
144
|
-
console.log('state:', state.current);
|
|
145
|
-
console.log('unten');
|
|
146
137
|
transitionEnd({
|
|
147
138
|
transitionEndObj: pop,
|
|
148
139
|
transitionEndHandler,
|
|
149
|
-
reverse
|
|
140
|
+
reverse,
|
|
141
|
+
delayStep
|
|
150
142
|
});
|
|
151
143
|
container.current?.classList.remove('enter');
|
|
152
144
|
container.current?.classList.add('exit');
|
|
153
|
-
console.log('classList done');
|
|
154
|
-
console.log(parseFirstOpacity(elArray), 'true > 0, false <=0');
|
|
155
145
|
state.current = 'exiting';
|
|
156
146
|
setPlaybackRate({
|
|
157
147
|
elArray,
|
|
@@ -164,15 +154,16 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
164
154
|
elArray,
|
|
165
155
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
166
156
|
target: 1,
|
|
167
|
-
duration:
|
|
168
|
-
}).catch(() => {
|
|
169
|
-
}).catch(() => {
|
|
157
|
+
duration: duration.current ?? 0
|
|
158
|
+
}).catch(() => { });
|
|
159
|
+
}).catch(() => { });
|
|
170
160
|
return;
|
|
171
161
|
}
|
|
172
162
|
transitionEnd({
|
|
173
163
|
transitionEndObj: pop,
|
|
174
164
|
transitionEndHandler,
|
|
175
|
-
reverse
|
|
165
|
+
reverse,
|
|
166
|
+
delayStep
|
|
176
167
|
});
|
|
177
168
|
container.current?.classList.remove('enter');
|
|
178
169
|
container.current?.classList.add('exit');
|
|
@@ -4,8 +4,6 @@ interface TransitionEndData {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
delayStep: number;
|
|
8
|
-
duration: number;
|
|
9
7
|
}
|
|
10
8
|
interface Props {
|
|
11
9
|
elArray: RefObject<HTMLDivElement | null | (HTMLDivElement | null)[]>;
|
|
@@ -4,8 +4,6 @@ interface TransitionEndData {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
-
delayStep: number;
|
|
8
|
-
duration: number;
|
|
9
7
|
}
|
|
10
8
|
interface Props {
|
|
11
9
|
transitionEndData: RefObject<TransitionEndData>;
|
|
@@ -16,8 +14,6 @@ interface TransitionEndObj {
|
|
|
16
14
|
transitionProperty: 'opacity' | 'clip-path';
|
|
17
15
|
mirror: boolean;
|
|
18
16
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
19
|
-
delayStep: number;
|
|
20
|
-
duration: number;
|
|
21
17
|
fn: (() => void) | null;
|
|
22
18
|
}
|
|
23
19
|
export declare function useTransitionEndObj({ transitionEndData, fn }: Props): RefObject<TransitionEndObj>;
|
|
@@ -5,9 +5,7 @@ export function useTransitionEndObj({ transitionEndData, fn }) {
|
|
|
5
5
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
6
6
|
mirror: transitionEndData.current.mirror,
|
|
7
7
|
mirrorElArray: [],
|
|
8
|
-
fn: null
|
|
9
|
-
delayStep: transitionEndData.current.delayStep,
|
|
10
|
-
duration: transitionEndData.current.duration
|
|
8
|
+
fn: null
|
|
11
9
|
});
|
|
12
10
|
useEffect(() => {
|
|
13
11
|
transitionEndObj.current = {
|