page-transition 0.1.0-beta.33 → 0.1.0-beta.35
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/dist/context/CssTransitionProvider.js +8 -4
- package/dist/functions/parseDuration.d.ts +1 -0
- package/dist/functions/parseDuration.js +6 -0
- package/dist/functions/transitionEnd.d.ts +3 -2
- package/dist/functions/transitionEnd.js +2 -3
- package/dist/functions/transitionEndReverse.d.ts +3 -2
- package/dist/functions/transitionEndReverse.js +3 -4
- package/dist/functions/updatePlaybackRate.d.ts +2 -1
- package/dist/functions/updatePlaybackRate.js +8 -13
- package/dist/hooks/useHandleLinkClick.d.ts +3 -2
- package/dist/hooks/useHandleLinkClick.js +30 -16
- package/dist/hooks/usePopState.d.ts +3 -2
- package/dist/hooks/usePopState.js +31 -41
- package/dist/hooks/useTransitionEndData.d.ts +2 -0
- package/dist/hooks/useTransitionEndData.js +3 -1
- package/dist/hooks/useTransitionEndObj.d.ts +4 -0
- package/dist/hooks/useTransitionEndObj.js +2 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ import { useHandleLinkClick } from "../hooks/useHandleLinkClick";
|
|
|
11
11
|
import { useScrollRestoration } from "../hooks/useScrollRestoration";
|
|
12
12
|
import { usePopState } from "../hooks/usePopState";
|
|
13
13
|
import { parseDelay } from "../functions/parseDelay";
|
|
14
|
+
import { parseDuration } from "../functions/parseDuration";
|
|
14
15
|
import { pollTransitionStart } from "../functions/pollTransitionStart";
|
|
15
16
|
export function CssTransitionProvider({ header, options, children }) {
|
|
16
17
|
const defaultOptions = {
|
|
@@ -48,6 +49,7 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
51
|
const delayStep = useRef(null);
|
|
52
|
+
const duration = useRef(null);
|
|
51
53
|
const handleLinkClick = useRef(() => { });
|
|
52
54
|
const transitionEndHandler = useTransitionEndHandler();
|
|
53
55
|
const transitionEndData = useTransitionEndData({
|
|
@@ -66,7 +68,6 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
66
68
|
transitionEndHandler,
|
|
67
69
|
state,
|
|
68
70
|
reverse,
|
|
69
|
-
delayStep,
|
|
70
71
|
useUse,
|
|
71
72
|
resolveUseFn,
|
|
72
73
|
pollRafId,
|
|
@@ -81,7 +82,6 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
81
82
|
transitionEndHandler,
|
|
82
83
|
state,
|
|
83
84
|
reverse,
|
|
84
|
-
delayStep,
|
|
85
85
|
useUse,
|
|
86
86
|
resolveUseFn,
|
|
87
87
|
basePath,
|
|
@@ -108,14 +108,18 @@ export function CssTransitionProvider({ header, options, children }) {
|
|
|
108
108
|
mount.current.mounted = true;
|
|
109
109
|
if (delayStep.current === null && defaultOptions.overlayCount > 1) {
|
|
110
110
|
delayStep.current = parseDelay(transitionEndData.current.elArray);
|
|
111
|
+
transitionEndData.current.delayStep = delayStep.current ?? 0;
|
|
112
|
+
}
|
|
113
|
+
if (duration.current === null) {
|
|
114
|
+
duration.current = parseDuration(transitionEndData.current.elArray[0]);
|
|
115
|
+
transitionEndData.current.duration = duration.current ?? 0;
|
|
111
116
|
}
|
|
112
117
|
if (!container.current)
|
|
113
118
|
return;
|
|
114
119
|
transitionEnd({
|
|
115
120
|
transitionEndObj: removeEnter,
|
|
116
121
|
transitionEndHandler,
|
|
117
|
-
reverse
|
|
118
|
-
delayStep
|
|
122
|
+
reverse
|
|
119
123
|
});
|
|
120
124
|
container.current.classList.remove('exit');
|
|
121
125
|
container.current.classList.add('enter');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseDuration(el: HTMLElement | null): number | null;
|
|
@@ -4,6 +4,8 @@ interface TransitionEndObj {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
+
delayStep: number;
|
|
8
|
+
duration: number;
|
|
7
9
|
fn: (() => void) | null;
|
|
8
10
|
}
|
|
9
11
|
interface TransitionEndHandler {
|
|
@@ -17,7 +19,6 @@ interface Props {
|
|
|
17
19
|
_lock: boolean;
|
|
18
20
|
lock: boolean;
|
|
19
21
|
}>;
|
|
20
|
-
delayStep: RefObject<number | null>;
|
|
21
22
|
}
|
|
22
|
-
export declare function transitionEnd({ transitionEndObj, transitionEndHandler, reverse,
|
|
23
|
+
export declare function transitionEnd({ transitionEndObj, transitionEndHandler, reverse, }: Props): void;
|
|
23
24
|
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, }) {
|
|
3
3
|
const lastIndex = transitionEndObj.current.elArray.length - 1;
|
|
4
4
|
if (transitionEndHandler.current.handler &&
|
|
5
5
|
transitionEndHandler.current.handlerEl) {
|
|
@@ -10,8 +10,7 @@ export function transitionEnd({ transitionEndObj, transitionEndHandler, reverse,
|
|
|
10
10
|
transtionEndReverse({
|
|
11
11
|
transitionEndObj,
|
|
12
12
|
transitionEndHandler,
|
|
13
|
-
reverse
|
|
14
|
-
delayStep
|
|
13
|
+
reverse
|
|
15
14
|
});
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
@@ -4,6 +4,8 @@ interface TransitionEndObj {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
+
delayStep: number;
|
|
8
|
+
duration: number;
|
|
7
9
|
fn: (() => void) | null;
|
|
8
10
|
}
|
|
9
11
|
interface TransitionEndHandler {
|
|
@@ -17,7 +19,6 @@ interface Props {
|
|
|
17
19
|
_lock: boolean;
|
|
18
20
|
lock: boolean;
|
|
19
21
|
}>;
|
|
20
|
-
delayStep: RefObject<number | null>;
|
|
21
22
|
}
|
|
22
|
-
export declare function transtionEndReverse({ transitionEndObj, transitionEndHandler, reverse
|
|
23
|
+
export declare function transtionEndReverse({ transitionEndObj, transitionEndHandler, reverse }: Props): void;
|
|
23
24
|
export {};
|
|
@@ -1,21 +1,20 @@
|
|
|
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 }) {
|
|
4
4
|
if (transitionEndHandler.current.handler &&
|
|
5
5
|
transitionEndHandler.current.handlerEl)
|
|
6
6
|
transitionEndHandler.current.handlerEl.removeEventListener('transitionend', transitionEndHandler.current.handler);
|
|
7
7
|
const endObj = transitionEndObj.current;
|
|
8
|
-
console.log('transitionEndReverse setDelayReverse');
|
|
9
8
|
setDelayReverse({
|
|
10
9
|
elArray: endObj.elArray,
|
|
11
10
|
transitionProperty: endObj.transitionProperty,
|
|
12
|
-
delayStep: delayStep
|
|
11
|
+
delayStep: endObj.delayStep
|
|
13
12
|
});
|
|
14
13
|
if (endObj.mirror) {
|
|
15
14
|
setDelayReverse({
|
|
16
15
|
elArray: endObj.mirrorElArray,
|
|
17
16
|
transitionProperty: endObj.transitionProperty,
|
|
18
|
-
delayStep: delayStep
|
|
17
|
+
delayStep: endObj.delayStep
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
const firstEl = endObj.elArray[0];
|
|
@@ -5,6 +5,7 @@ interface Props {
|
|
|
5
5
|
elArray: (HTMLDivElement | null)[];
|
|
6
6
|
transitionProperty: 'opacity' | 'clip-path';
|
|
7
7
|
target: number;
|
|
8
|
+
duration: number;
|
|
8
9
|
}
|
|
9
|
-
export declare function updatePlaybackRate({ rafId, rejectFn, elArray, transitionProperty, target }: Props): Promise<void>;
|
|
10
|
+
export declare function updatePlaybackRate({ rafId, rejectFn, elArray, transitionProperty, target, duration }: Props): Promise<void>;
|
|
10
11
|
export {};
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
export function updatePlaybackRate({ rafId, rejectFn, elArray, transitionProperty, target }) {
|
|
1
|
+
export function updatePlaybackRate({ rafId, rejectFn, elArray, transitionProperty, target, duration }) {
|
|
2
2
|
if (rafId.current !== null)
|
|
3
3
|
cancelAnimationFrame(rafId.current);
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
if (duration <= 0) {
|
|
9
|
-
console.warn('updatePlaybackRate: duration is 0, check if the element has a transition-duration set in CSS');
|
|
10
|
-
duration = 300;
|
|
11
|
-
}
|
|
4
|
+
if (duration === 0)
|
|
5
|
+
return Promise.resolve();
|
|
6
|
+
const d = (duration * 1000) / 2;
|
|
12
7
|
let progress = 0;
|
|
13
|
-
let summ = target ? 0 :
|
|
8
|
+
let summ = target ? 0 : d;
|
|
14
9
|
let animationArray = [];
|
|
15
10
|
elArray.forEach((el) => {
|
|
16
11
|
el?.getAnimations().forEach((obj) => {
|
|
@@ -30,9 +25,9 @@ export function updatePlaybackRate({ rafId, rejectFn, elArray, transitionPropert
|
|
|
30
25
|
}
|
|
31
26
|
const dt = now - before;
|
|
32
27
|
before = now;
|
|
33
|
-
summ = target ? Math.min(summ + dt,
|
|
34
|
-
progress = summ /
|
|
35
|
-
animationArray.forEach((obj
|
|
28
|
+
summ = target ? Math.min(summ + dt, d) : Math.max(summ - dt, 0);
|
|
29
|
+
progress = summ / d;
|
|
30
|
+
animationArray.forEach((obj) => {
|
|
36
31
|
obj.updatePlaybackRate(progress);
|
|
37
32
|
});
|
|
38
33
|
if (target && progress >= 1 || !target && progress <= 0) {
|
|
@@ -4,6 +4,8 @@ interface TransitionEndData {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
+
delayStep: number;
|
|
8
|
+
duration: number;
|
|
7
9
|
}
|
|
8
10
|
interface TransitionEndHandler {
|
|
9
11
|
handler: ((e: TransitionEvent) => void) | null;
|
|
@@ -20,7 +22,6 @@ interface Props {
|
|
|
20
22
|
_lock: boolean;
|
|
21
23
|
lock: boolean;
|
|
22
24
|
}>;
|
|
23
|
-
delayStep: RefObject<number | null>;
|
|
24
25
|
useUse: RefObject<boolean>;
|
|
25
26
|
resolveUseFn: RefObject<(() => void) | null>;
|
|
26
27
|
basePath: RefObject<string | null>;
|
|
@@ -28,5 +29,5 @@ interface Props {
|
|
|
28
29
|
rafId: RefObject<number | null>;
|
|
29
30
|
rejectFn: RefObject<(() => void) | null>;
|
|
30
31
|
}
|
|
31
|
-
export declare function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse,
|
|
32
|
+
export declare function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn }: Props): void;
|
|
32
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,
|
|
9
|
+
export function useHandleLinkClick({ container, handleLinkClick, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, basePath, pollRafId, rafId, rejectFn }) {
|
|
10
10
|
const router = useRouter();
|
|
11
11
|
const afterExitFn = useRef(null);
|
|
12
12
|
const nextPage = useRef(null);
|
|
@@ -36,8 +36,7 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
36
36
|
transitionEnd({
|
|
37
37
|
transitionEndObj: removeEnter,
|
|
38
38
|
transitionEndHandler,
|
|
39
|
-
reverse
|
|
40
|
-
delayStep
|
|
39
|
+
reverse
|
|
41
40
|
});
|
|
42
41
|
if (useUse.current) {
|
|
43
42
|
resolveUseFn.current?.();
|
|
@@ -57,10 +56,27 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
58
|
});
|
|
60
|
-
const
|
|
59
|
+
const afterEntering = useTransitionEndObj({
|
|
61
60
|
transitionEndData,
|
|
62
61
|
fn: () => {
|
|
63
|
-
console.log('
|
|
62
|
+
console.log('afterEntering transitionEnd');
|
|
63
|
+
if (rafId.current) {
|
|
64
|
+
cancelAnimationFrame(rafId.current);
|
|
65
|
+
rafId.current = null;
|
|
66
|
+
}
|
|
67
|
+
rejectFn.current?.();
|
|
68
|
+
container.current?.classList.remove('enter');
|
|
69
|
+
requestAnimationFrame(() => {
|
|
70
|
+
requestAnimationFrame(() => {
|
|
71
|
+
container.current?.classList.add('exit');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
state.current = 'exiting';
|
|
75
|
+
transitionEnd({
|
|
76
|
+
transitionEndObj: push,
|
|
77
|
+
transitionEndHandler,
|
|
78
|
+
reverse
|
|
79
|
+
});
|
|
64
80
|
}
|
|
65
81
|
});
|
|
66
82
|
handleLinkClick.current = useCallback((e, url) => {
|
|
@@ -91,17 +107,15 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
91
107
|
transitionEnd({
|
|
92
108
|
transitionEndObj: afterExit,
|
|
93
109
|
transitionEndHandler,
|
|
94
|
-
reverse
|
|
95
|
-
delayStep
|
|
110
|
+
reverse
|
|
96
111
|
});
|
|
97
112
|
return;
|
|
98
113
|
}
|
|
99
114
|
if (state.current === 'entering') {
|
|
100
115
|
transitionEnd({
|
|
101
|
-
transitionEndObj:
|
|
116
|
+
transitionEndObj: afterEntering,
|
|
102
117
|
transitionEndHandler,
|
|
103
|
-
reverse
|
|
104
|
-
delayStep
|
|
118
|
+
reverse
|
|
105
119
|
});
|
|
106
120
|
let elArray = [];
|
|
107
121
|
if (transitionEndData.current.mirror) {
|
|
@@ -115,13 +129,13 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
115
129
|
rejectFn,
|
|
116
130
|
elArray,
|
|
117
131
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
118
|
-
target: 0
|
|
132
|
+
target: 0,
|
|
133
|
+
duration: transitionEndData.current.duration
|
|
119
134
|
}).then(() => {
|
|
120
135
|
transitionEnd({
|
|
121
136
|
transitionEndObj: push,
|
|
122
137
|
transitionEndHandler,
|
|
123
|
-
reverse
|
|
124
|
-
delayStep
|
|
138
|
+
reverse
|
|
125
139
|
});
|
|
126
140
|
container.current?.classList.remove('enter');
|
|
127
141
|
container.current?.classList.add('exit');
|
|
@@ -136,7 +150,8 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
136
150
|
rejectFn,
|
|
137
151
|
elArray,
|
|
138
152
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
139
|
-
target: 1
|
|
153
|
+
target: 1,
|
|
154
|
+
duration: transitionEndData.current.duration
|
|
140
155
|
}).catch(() => { });
|
|
141
156
|
}).catch(() => { });
|
|
142
157
|
return;
|
|
@@ -144,8 +159,7 @@ export function useHandleLinkClick({ container, handleLinkClick, currentPathname
|
|
|
144
159
|
transitionEnd({
|
|
145
160
|
transitionEndObj: push,
|
|
146
161
|
transitionEndHandler,
|
|
147
|
-
reverse
|
|
148
|
-
delayStep
|
|
162
|
+
reverse
|
|
149
163
|
});
|
|
150
164
|
container.current?.classList.remove('enter');
|
|
151
165
|
container.current?.classList.add('exit');
|
|
@@ -4,6 +4,8 @@ interface TransitionEndData {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
+
delayStep: number;
|
|
8
|
+
duration: number;
|
|
7
9
|
}
|
|
8
10
|
interface TransitionEndHandler {
|
|
9
11
|
handler: ((e: TransitionEvent) => void) | null;
|
|
@@ -18,7 +20,6 @@ interface Props {
|
|
|
18
20
|
_lock: boolean;
|
|
19
21
|
lock: boolean;
|
|
20
22
|
}>;
|
|
21
|
-
delayStep: RefObject<number | null>;
|
|
22
23
|
state: RefObject<'idle' | 'exiting' | 'entering' | 'navigating'>;
|
|
23
24
|
useUse: RefObject<boolean>;
|
|
24
25
|
resolveUseFn: RefObject<(() => void) | null>;
|
|
@@ -26,5 +27,5 @@ interface Props {
|
|
|
26
27
|
rafId: RefObject<number | null>;
|
|
27
28
|
rejectFn: RefObject<(() => void) | null>;
|
|
28
29
|
}
|
|
29
|
-
export declare function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse,
|
|
30
|
+
export declare function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn }: Props): void;
|
|
30
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, delayStep, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn }) {
|
|
8
|
+
export function usePopState({ container, currentPathname, transitionEndData, transitionEndHandler, reverse, state, useUse, resolveUseFn, pollRafId, rafId, rejectFn }) {
|
|
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,12 +27,10 @@ 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
|
|
37
|
-
delayStep
|
|
33
|
+
reverse
|
|
38
34
|
});
|
|
39
35
|
state.current = 'navigating';
|
|
40
36
|
container.current?.classList.remove('exit');
|
|
@@ -55,7 +51,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
55
51
|
const pop = useTransitionEndObj({
|
|
56
52
|
transitionEndData,
|
|
57
53
|
fn: () => {
|
|
58
|
-
console.log('pop transitionEnd');
|
|
59
54
|
state.current = 'navigating';
|
|
60
55
|
window.scrollTo(0, window.history.state.scrollY ?? 0);
|
|
61
56
|
resolveFn.current?.();
|
|
@@ -63,10 +58,26 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
63
58
|
useUse.current = false;
|
|
64
59
|
}
|
|
65
60
|
});
|
|
66
|
-
const
|
|
61
|
+
const afterEntering = useTransitionEndObj({
|
|
67
62
|
transitionEndData,
|
|
68
63
|
fn: () => {
|
|
69
|
-
|
|
64
|
+
if (rafId.current) {
|
|
65
|
+
cancelAnimationFrame(rafId.current);
|
|
66
|
+
rafId.current = null;
|
|
67
|
+
}
|
|
68
|
+
rejectFn.current?.();
|
|
69
|
+
container.current?.classList.remove('enter');
|
|
70
|
+
requestAnimationFrame(() => {
|
|
71
|
+
requestAnimationFrame(() => {
|
|
72
|
+
container.current?.classList.add('exit');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
state.current = 'exiting';
|
|
76
|
+
transitionEnd({
|
|
77
|
+
transitionEndObj: pop,
|
|
78
|
+
transitionEndHandler,
|
|
79
|
+
reverse
|
|
80
|
+
});
|
|
70
81
|
}
|
|
71
82
|
});
|
|
72
83
|
useEffect(() => {
|
|
@@ -78,13 +89,11 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
78
89
|
if (state.current === "navigating") {
|
|
79
90
|
console.log('navigating');
|
|
80
91
|
if (currentPathname.current !== window.location.pathname) {
|
|
81
|
-
console.log('currentPathname.current !== window.location.pathname');
|
|
82
92
|
resolveFn.current?.();
|
|
83
93
|
setPromise(null);
|
|
84
94
|
return;
|
|
85
95
|
}
|
|
86
96
|
else if (currentPathname.current === window.location.pathname) {
|
|
87
|
-
console.log('currentPathname.current === window.location.pathname');
|
|
88
97
|
afterExitFn.current?.();
|
|
89
98
|
}
|
|
90
99
|
}
|
|
@@ -94,29 +103,19 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
94
103
|
}).then(() => {
|
|
95
104
|
console.log('not navigating');
|
|
96
105
|
if (currentPathname.current === window.location.pathname) {
|
|
97
|
-
console.log('currentPathname.current === window.location.pathname');
|
|
98
106
|
transitionEnd({
|
|
99
107
|
transitionEndObj: afterExit,
|
|
100
108
|
transitionEndHandler,
|
|
101
|
-
reverse
|
|
102
|
-
delayStep
|
|
109
|
+
reverse
|
|
103
110
|
});
|
|
104
111
|
return;
|
|
105
112
|
}
|
|
106
113
|
if (state.current === 'entering') {
|
|
107
114
|
transitionEnd({
|
|
108
|
-
transitionEndObj:
|
|
115
|
+
transitionEndObj: afterEntering,
|
|
109
116
|
transitionEndHandler,
|
|
110
|
-
reverse
|
|
111
|
-
delayStep
|
|
117
|
+
reverse
|
|
112
118
|
});
|
|
113
|
-
if (state.current !== 'entering') {
|
|
114
|
-
console.log('state.current !== entering');
|
|
115
|
-
console.log('state:', state.current);
|
|
116
|
-
console.log('oben');
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
console.log('state.current === entering');
|
|
120
119
|
let elArray = [];
|
|
121
120
|
if (transitionEndData.current.mirror) {
|
|
122
121
|
elArray = [...transitionEndData.current.mirrorElArray, ...transitionEndData.current.elArray];
|
|
@@ -129,25 +128,16 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
129
128
|
rejectFn,
|
|
130
129
|
elArray,
|
|
131
130
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
132
|
-
target: 0
|
|
131
|
+
target: 0,
|
|
132
|
+
duration: transitionEndData.current.duration
|
|
133
133
|
}).then(() => {
|
|
134
|
-
if (state.current !== 'entering') {
|
|
135
|
-
console.log('state.current !== entering');
|
|
136
|
-
console.log('state:', state.current);
|
|
137
|
-
console.log('unten');
|
|
138
|
-
}
|
|
139
|
-
console.log('updatePlaybackRate done');
|
|
140
134
|
transitionEnd({
|
|
141
135
|
transitionEndObj: pop,
|
|
142
136
|
transitionEndHandler,
|
|
143
|
-
reverse
|
|
144
|
-
delayStep
|
|
137
|
+
reverse
|
|
145
138
|
});
|
|
146
|
-
console.log('transitionEnd done');
|
|
147
139
|
container.current?.classList.remove('enter');
|
|
148
140
|
container.current?.classList.add('exit');
|
|
149
|
-
console.log('classList done');
|
|
150
|
-
console.log(parseFirstOpacity(elArray), 'true > 0, false <=0');
|
|
151
141
|
state.current = 'exiting';
|
|
152
142
|
setPlaybackRate({
|
|
153
143
|
elArray,
|
|
@@ -159,16 +149,16 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
159
149
|
rejectFn,
|
|
160
150
|
elArray,
|
|
161
151
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
162
|
-
target: 1
|
|
163
|
-
|
|
164
|
-
|
|
152
|
+
target: 1,
|
|
153
|
+
duration: transitionEndData.current.duration
|
|
154
|
+
}).catch(() => { });
|
|
155
|
+
}).catch(() => { });
|
|
165
156
|
return;
|
|
166
157
|
}
|
|
167
158
|
transitionEnd({
|
|
168
159
|
transitionEndObj: pop,
|
|
169
160
|
transitionEndHandler,
|
|
170
|
-
reverse
|
|
171
|
-
delayStep
|
|
161
|
+
reverse
|
|
172
162
|
});
|
|
173
163
|
container.current?.classList.remove('enter');
|
|
174
164
|
container.current?.classList.add('exit');
|
|
@@ -4,6 +4,8 @@ interface TransitionEndData {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
+
delayStep: number;
|
|
8
|
+
duration: number;
|
|
7
9
|
}
|
|
8
10
|
interface Props {
|
|
9
11
|
elArray: RefObject<HTMLDivElement | null | (HTMLDivElement | null)[]>;
|
|
@@ -4,6 +4,8 @@ interface TransitionEndData {
|
|
|
4
4
|
transitionProperty: 'opacity' | 'clip-path';
|
|
5
5
|
mirror: boolean;
|
|
6
6
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
7
|
+
delayStep: number;
|
|
8
|
+
duration: number;
|
|
7
9
|
}
|
|
8
10
|
interface Props {
|
|
9
11
|
transitionEndData: RefObject<TransitionEndData>;
|
|
@@ -14,6 +16,8 @@ interface TransitionEndObj {
|
|
|
14
16
|
transitionProperty: 'opacity' | 'clip-path';
|
|
15
17
|
mirror: boolean;
|
|
16
18
|
mirrorElArray: (HTMLDivElement | null)[];
|
|
19
|
+
delayStep: number;
|
|
20
|
+
duration: number;
|
|
17
21
|
fn: (() => void) | null;
|
|
18
22
|
}
|
|
19
23
|
export declare function useTransitionEndObj({ transitionEndData, fn }: Props): RefObject<TransitionEndObj>;
|
|
@@ -6,6 +6,8 @@ export function useTransitionEndObj({ transitionEndData, fn }) {
|
|
|
6
6
|
mirror: transitionEndData.current.mirror,
|
|
7
7
|
mirrorElArray: [],
|
|
8
8
|
fn: null,
|
|
9
|
+
delayStep: transitionEndData.current.delayStep,
|
|
10
|
+
duration: transitionEndData.current.duration
|
|
9
11
|
});
|
|
10
12
|
useEffect(() => {
|
|
11
13
|
transitionEndObj.current = {
|