page-transition 0.1.0-beta.34 → 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/hooks/usePopState.js +2 -16
- package/package.json +1 -1
|
@@ -5,7 +5,6 @@ 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
|
-
import { parseFirstOpacity } from "../functions/parseFirstOpacity";
|
|
9
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) {
|
|
@@ -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,7 +27,6 @@ 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,
|
|
@@ -54,7 +51,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
54
51
|
const pop = useTransitionEndObj({
|
|
55
52
|
transitionEndData,
|
|
56
53
|
fn: () => {
|
|
57
|
-
console.log('pop transitionEnd');
|
|
58
54
|
state.current = 'navigating';
|
|
59
55
|
window.scrollTo(0, window.history.state.scrollY ?? 0);
|
|
60
56
|
resolveFn.current?.();
|
|
@@ -65,7 +61,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
65
61
|
const afterEntering = useTransitionEndObj({
|
|
66
62
|
transitionEndData,
|
|
67
63
|
fn: () => {
|
|
68
|
-
console.log('afterEntering transitionEnd');
|
|
69
64
|
if (rafId.current) {
|
|
70
65
|
cancelAnimationFrame(rafId.current);
|
|
71
66
|
rafId.current = null;
|
|
@@ -94,13 +89,11 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
94
89
|
if (state.current === "navigating") {
|
|
95
90
|
console.log('navigating');
|
|
96
91
|
if (currentPathname.current !== window.location.pathname) {
|
|
97
|
-
console.log('currentPathname.current !== window.location.pathname');
|
|
98
92
|
resolveFn.current?.();
|
|
99
93
|
setPromise(null);
|
|
100
94
|
return;
|
|
101
95
|
}
|
|
102
96
|
else if (currentPathname.current === window.location.pathname) {
|
|
103
|
-
console.log('currentPathname.current === window.location.pathname');
|
|
104
97
|
afterExitFn.current?.();
|
|
105
98
|
}
|
|
106
99
|
}
|
|
@@ -110,7 +103,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
110
103
|
}).then(() => {
|
|
111
104
|
console.log('not navigating');
|
|
112
105
|
if (currentPathname.current === window.location.pathname) {
|
|
113
|
-
console.log('currentPathname.current === window.location.pathname');
|
|
114
106
|
transitionEnd({
|
|
115
107
|
transitionEndObj: afterExit,
|
|
116
108
|
transitionEndHandler,
|
|
@@ -124,8 +116,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
124
116
|
transitionEndHandler,
|
|
125
117
|
reverse
|
|
126
118
|
});
|
|
127
|
-
console.log('state:', state.current);
|
|
128
|
-
console.log('oben');
|
|
129
119
|
let elArray = [];
|
|
130
120
|
if (transitionEndData.current.mirror) {
|
|
131
121
|
elArray = [...transitionEndData.current.mirrorElArray, ...transitionEndData.current.elArray];
|
|
@@ -141,8 +131,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
141
131
|
target: 0,
|
|
142
132
|
duration: transitionEndData.current.duration
|
|
143
133
|
}).then(() => {
|
|
144
|
-
console.log('state:', state.current);
|
|
145
|
-
console.log('unten');
|
|
146
134
|
transitionEnd({
|
|
147
135
|
transitionEndObj: pop,
|
|
148
136
|
transitionEndHandler,
|
|
@@ -150,8 +138,6 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
150
138
|
});
|
|
151
139
|
container.current?.classList.remove('enter');
|
|
152
140
|
container.current?.classList.add('exit');
|
|
153
|
-
console.log('classList done');
|
|
154
|
-
console.log(parseFirstOpacity(elArray), 'true > 0, false <=0');
|
|
155
141
|
state.current = 'exiting';
|
|
156
142
|
setPlaybackRate({
|
|
157
143
|
elArray,
|
|
@@ -165,8 +151,8 @@ export function usePopState({ container, currentPathname, transitionEndData, tra
|
|
|
165
151
|
transitionProperty: transitionEndData.current.transitionProperty,
|
|
166
152
|
target: 1,
|
|
167
153
|
duration: transitionEndData.current.duration
|
|
168
|
-
}).catch(() => {
|
|
169
|
-
}).catch(() => {
|
|
154
|
+
}).catch(() => { });
|
|
155
|
+
}).catch(() => { });
|
|
170
156
|
return;
|
|
171
157
|
}
|
|
172
158
|
transitionEnd({
|