@ssgoi/react 0.0.5 → 0.0.7
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/index.cjs +1 -1
- package/dist/index.js +435 -431
- package/dist/transitions/index.cjs +1 -1
- package/dist/transitions/index.js +98 -98
- package/dist/{utils-BSgyev81.cjs → utils-DR41YsAh-CN_CfgYX.cjs} +1 -1
- package/dist/{utils-DR41YsAh.js → utils-DR41YsAh-mLT5vDuI.js} +4 -4
- package/dist/view-transitions/index.cjs +1 -1
- package/dist/view-transitions/index.js +177 -173
- package/package.json +1 -1
|
@@ -1,107 +1,109 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { n as x } from "../utils-DR41YsAh-mLT5vDuI.js";
|
|
2
|
+
const D = (t = {}) => {
|
|
3
|
+
var e, l;
|
|
4
|
+
const i = {
|
|
5
|
+
stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
|
|
6
|
+
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 30
|
|
6
7
|
};
|
|
7
8
|
return {
|
|
8
|
-
in: (
|
|
9
|
-
spring:
|
|
10
|
-
tick: (
|
|
11
|
-
|
|
9
|
+
in: (r) => ({
|
|
10
|
+
spring: i,
|
|
11
|
+
tick: (n) => {
|
|
12
|
+
r.style.opacity = n.toString();
|
|
12
13
|
}
|
|
13
14
|
}),
|
|
14
|
-
out: (
|
|
15
|
-
spring:
|
|
16
|
-
tick: (
|
|
17
|
-
|
|
15
|
+
out: (r) => ({
|
|
16
|
+
spring: i,
|
|
17
|
+
tick: (n) => {
|
|
18
|
+
r.style.opacity = n.toString();
|
|
18
19
|
},
|
|
19
|
-
prepare:
|
|
20
|
+
prepare: x
|
|
20
21
|
})
|
|
21
22
|
};
|
|
22
23
|
};
|
|
23
|
-
function
|
|
24
|
-
return t.querySelector(`[data-hero-key="${
|
|
24
|
+
function M(t, e) {
|
|
25
|
+
return t.querySelector(`[data-hero-key="${e}"]`);
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
27
|
+
function R(t, e) {
|
|
28
|
+
const l = t.getBoundingClientRect(), i = e.getBoundingClientRect();
|
|
28
29
|
return new DOMRect(
|
|
29
|
-
i.left -
|
|
30
|
-
i.top -
|
|
30
|
+
i.left - l.left,
|
|
31
|
+
i.top - l.top,
|
|
31
32
|
i.width,
|
|
32
33
|
i.height
|
|
33
34
|
);
|
|
34
35
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const H = (t = {}) => {
|
|
37
|
+
var e, l;
|
|
38
|
+
const i = {
|
|
39
|
+
stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
|
|
40
|
+
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 30
|
|
41
|
+
}, r = t.timeout ?? 300;
|
|
42
|
+
let n = null, s = null;
|
|
41
43
|
return {
|
|
42
|
-
in: async (a,
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
44
|
+
in: async (a, g) => {
|
|
45
|
+
const h = a, f = Array.from(h.querySelectorAll("[data-hero-key]"));
|
|
46
|
+
if (f.length === 0)
|
|
45
47
|
return {
|
|
46
|
-
spring:
|
|
48
|
+
spring: i,
|
|
47
49
|
tick: () => {
|
|
48
50
|
}
|
|
49
51
|
// No hero elements, skip animation
|
|
50
52
|
};
|
|
51
|
-
if (!await new Promise((
|
|
52
|
-
|
|
53
|
-
s = null,
|
|
54
|
-
},
|
|
55
|
-
}) || !
|
|
56
|
-
return
|
|
57
|
-
spring:
|
|
53
|
+
if (!await new Promise((c) => {
|
|
54
|
+
n ? c(!0) : (s = c, setTimeout(() => {
|
|
55
|
+
s = null, c(!1);
|
|
56
|
+
}, r));
|
|
57
|
+
}) || !n)
|
|
58
|
+
return n = null, {
|
|
59
|
+
spring: i,
|
|
58
60
|
tick: () => {
|
|
59
61
|
}
|
|
60
62
|
// No fromNode, skip animation
|
|
61
63
|
};
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
if (!
|
|
65
|
-
const d =
|
|
64
|
+
const p = f.map((c) => {
|
|
65
|
+
const u = c.getAttribute("data-hero-key");
|
|
66
|
+
if (!u) return null;
|
|
67
|
+
const d = M(n, u);
|
|
66
68
|
if (!d) return null;
|
|
67
|
-
const
|
|
69
|
+
const o = c, y = R(n, d), m = R(h, o), $ = y.left - m.left - g.scrollOffset.x, w = y.top - m.top - g.scrollOffset.y, A = y.width / m.width, v = y.height / m.height, S = o.style.transform, q = o.style.position, E = o.style.transformOrigin;
|
|
68
70
|
return {
|
|
69
|
-
toEl:
|
|
71
|
+
toEl: o,
|
|
70
72
|
dx: $,
|
|
71
73
|
dy: w,
|
|
72
|
-
dw:
|
|
73
|
-
dh:
|
|
74
|
-
originalTransform:
|
|
75
|
-
originalPosition:
|
|
76
|
-
originalTransformOrigin:
|
|
74
|
+
dw: A,
|
|
75
|
+
dh: v,
|
|
76
|
+
originalTransform: S,
|
|
77
|
+
originalPosition: q,
|
|
78
|
+
originalTransformOrigin: E
|
|
77
79
|
};
|
|
78
80
|
}).filter(Boolean);
|
|
79
|
-
return
|
|
80
|
-
spring:
|
|
81
|
+
return n = null, p.length === 0 ? {
|
|
82
|
+
spring: i,
|
|
81
83
|
tick: () => {
|
|
82
84
|
}
|
|
83
85
|
// No matching hero elements
|
|
84
86
|
} : {
|
|
85
|
-
spring:
|
|
87
|
+
spring: i,
|
|
86
88
|
prepare: () => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
p.forEach(({ toEl: c }) => {
|
|
90
|
+
c.style.position = "relative", c.style.transformOrigin = "top left";
|
|
89
91
|
});
|
|
90
92
|
},
|
|
91
|
-
tick: (
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
tick: (c) => {
|
|
94
|
+
p.forEach(({ toEl: u, dx: d, dy: o, dw: y, dh: m }) => {
|
|
95
|
+
u.style.transform = `translate(${(1 - c) * d}px,${(1 - c) * o}px) scale(${c + (1 - c) * y}, ${c + (1 - c) * m})`;
|
|
94
96
|
});
|
|
95
97
|
},
|
|
96
98
|
onEnd: () => {
|
|
97
|
-
|
|
99
|
+
p.forEach(
|
|
98
100
|
({
|
|
99
|
-
toEl:
|
|
100
|
-
originalTransform:
|
|
101
|
+
toEl: c,
|
|
102
|
+
originalTransform: u,
|
|
101
103
|
originalPosition: d,
|
|
102
|
-
originalTransformOrigin:
|
|
104
|
+
originalTransformOrigin: o
|
|
103
105
|
}) => {
|
|
104
|
-
|
|
106
|
+
c.style.transform = u, c.style.position = d, c.style.transformOrigin = o;
|
|
105
107
|
}
|
|
106
108
|
);
|
|
107
109
|
}
|
|
@@ -109,193 +111,195 @@ const L = (t = {}) => {
|
|
|
109
111
|
},
|
|
110
112
|
out: async (a) => ({
|
|
111
113
|
onStart: () => {
|
|
112
|
-
|
|
114
|
+
n = a, s && (s(!0), s = null);
|
|
113
115
|
},
|
|
114
|
-
prepare: (
|
|
115
|
-
|
|
116
|
+
prepare: (g) => {
|
|
117
|
+
x(g), g.style.opacity = "0";
|
|
116
118
|
}
|
|
117
119
|
})
|
|
118
120
|
};
|
|
119
121
|
};
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
+
function k(t, e) {
|
|
123
|
+
const l = t.getBoundingClientRect(), i = e.getBoundingClientRect();
|
|
122
124
|
return new DOMRect(
|
|
123
|
-
i.left -
|
|
124
|
-
i.top -
|
|
125
|
+
i.left - l.left,
|
|
126
|
+
i.top - l.top,
|
|
125
127
|
i.width,
|
|
126
128
|
i.height
|
|
127
129
|
);
|
|
128
130
|
}
|
|
129
131
|
function P({
|
|
130
132
|
detailRect: t,
|
|
131
|
-
galleryRect:
|
|
132
|
-
pageRect:
|
|
133
|
+
galleryRect: e,
|
|
134
|
+
pageRect: l,
|
|
133
135
|
scrollOffset: i
|
|
134
|
-
},
|
|
135
|
-
const
|
|
136
|
-
return
|
|
137
|
-
const
|
|
138
|
-
|
|
136
|
+
}, r) {
|
|
137
|
+
const n = e.left - t.left + (e.width - t.width) / 2 - i.x, s = e.top - t.top + (e.height - t.height) / 2 - i.y, a = e.width / t.width, g = e.height / t.height, h = Math.max(a, g), f = t.top / l.height * 100, p = (l.width - (t.left + t.width)) / l.width * 100, c = (l.height - (t.top + t.height)) / l.height * 100, u = t.left / l.width * 100;
|
|
138
|
+
return r.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (d) => {
|
|
139
|
+
const o = 1 - d, y = f * o, m = p * o, $ = c * o, w = u * o;
|
|
140
|
+
r.style.clipPath = `inset(${y}% ${m}% ${$}% ${w}%)`, r.style.transform = `translate(${n * o}px, ${s * o}px) scale(${1 + (h - 1) * o})`;
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
|
-
function
|
|
143
|
+
function B({
|
|
142
144
|
galleryRect: t,
|
|
143
|
-
detailRect:
|
|
144
|
-
scrollOffset:
|
|
145
|
+
detailRect: e,
|
|
146
|
+
scrollOffset: l
|
|
145
147
|
}, i) {
|
|
146
|
-
const
|
|
147
|
-
return (
|
|
148
|
+
const r = e.left - t.left + (e.width - t.width) / 2 + l.x, n = e.top - t.top + (e.height - t.height) / 2 + l.y, s = e.width / t.width, a = e.height / t.height, g = Math.max(s, a);
|
|
149
|
+
return (h) => {
|
|
148
150
|
i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
|
|
149
|
-
const
|
|
150
|
-
i.style.transform = `translate(${
|
|
151
|
+
const f = 1 - h;
|
|
152
|
+
i.style.transform = `translate(${r * f - l.x}px, ${n * f - l.y}px) scale(${1 + (g - 1) * f})`, i.style.opacity = `${1 - f}`;
|
|
151
153
|
};
|
|
152
154
|
}
|
|
153
|
-
function
|
|
155
|
+
function C({
|
|
154
156
|
galleryRect: t,
|
|
155
|
-
detailRect:
|
|
156
|
-
scrollOffset:
|
|
157
|
+
detailRect: e,
|
|
158
|
+
scrollOffset: l
|
|
157
159
|
}, i) {
|
|
158
|
-
const
|
|
159
|
-
return (
|
|
160
|
-
const
|
|
161
|
-
i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, i.style.transform = `translate(${
|
|
160
|
+
const r = e.left - t.left + (e.width - t.width) / 2 - l.x, n = e.top - t.top + (e.height - t.height) / 2 - l.y, s = e.width / t.width, a = e.height / t.height, g = Math.max(s, a);
|
|
161
|
+
return (h) => {
|
|
162
|
+
const f = 1 - h, p = h;
|
|
163
|
+
i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, i.style.transform = `translate(${r * f}px, ${n * f}px) scale(${1 + (g - 1) * f})`, i.style.opacity = `${p}`;
|
|
162
164
|
};
|
|
163
165
|
}
|
|
164
|
-
function
|
|
166
|
+
function T({
|
|
165
167
|
detailRect: t,
|
|
166
|
-
galleryRect:
|
|
167
|
-
pageRect:
|
|
168
|
+
galleryRect: e,
|
|
169
|
+
pageRect: l,
|
|
168
170
|
scrollOffset: i
|
|
169
|
-
},
|
|
170
|
-
const
|
|
171
|
-
return
|
|
172
|
-
const
|
|
173
|
-
|
|
171
|
+
}, r) {
|
|
172
|
+
const n = e.left - t.left + (e.width - t.width) / 2 + i.x, s = e.top - t.top + (e.height - t.height) / 2 + i.y, a = e.width / t.width, g = e.height / t.height, h = Math.min(a, g), f = t.top / l.height * 100, p = (l.width - (t.left + t.width)) / l.width * 100, c = (l.height - (t.top + t.height)) / l.height * 100, u = t.left / l.width * 100;
|
|
173
|
+
return r.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (d) => {
|
|
174
|
+
const o = 1 - d, y = f * o, m = p * o, $ = c * o, w = u * o;
|
|
175
|
+
r.style.clipPath = `inset(${y}% ${m}% ${$}% ${w}%)`, r.style.transform = `translate(${n * o - i.x}px, ${s * o - i.y}px) scale(${1 + (h - 1) * o})`;
|
|
174
176
|
};
|
|
175
177
|
}
|
|
176
|
-
function
|
|
178
|
+
function b(t, e, l) {
|
|
177
179
|
const i = t.querySelector(
|
|
178
180
|
"[data-pinterest-detail-key]"
|
|
179
|
-
),
|
|
181
|
+
), r = e.querySelector(
|
|
180
182
|
"[data-pinterest-detail-key]"
|
|
181
183
|
);
|
|
182
|
-
if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 ||
|
|
184
|
+
if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 || e.querySelectorAll("[data-pinterest-detail-key]").length > 1)
|
|
183
185
|
return null;
|
|
184
|
-
let
|
|
185
|
-
if (!i &&
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
if (!
|
|
189
|
-
|
|
190
|
-
`[data-pinterest-gallery-key="${
|
|
191
|
-
),
|
|
192
|
-
} else if (i && !
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
if (!
|
|
196
|
-
|
|
197
|
-
`[data-pinterest-gallery-key="${
|
|
198
|
-
),
|
|
186
|
+
let n = null, s = null, a = !1;
|
|
187
|
+
if (!i && r) {
|
|
188
|
+
s = r;
|
|
189
|
+
const p = s.getAttribute("data-pinterest-detail-key");
|
|
190
|
+
if (!p) return null;
|
|
191
|
+
n = t.querySelector(
|
|
192
|
+
`[data-pinterest-gallery-key="${p}"]`
|
|
193
|
+
), n && (a = !0);
|
|
194
|
+
} else if (i && !r) {
|
|
195
|
+
s = i;
|
|
196
|
+
const p = s.getAttribute("data-pinterest-detail-key");
|
|
197
|
+
if (!p) return null;
|
|
198
|
+
n = e.querySelector(
|
|
199
|
+
`[data-pinterest-gallery-key="${p}"]`
|
|
200
|
+
), n && (a = !1);
|
|
199
201
|
}
|
|
200
|
-
if (!
|
|
202
|
+
if (!n || !s)
|
|
201
203
|
return null;
|
|
202
|
-
const
|
|
203
|
-
return
|
|
204
|
+
const g = k(a ? t : e, n), h = k(a ? e : t, s), f = e.getBoundingClientRect();
|
|
205
|
+
return a ? {
|
|
204
206
|
inAnimation: P(
|
|
205
|
-
{ detailRect:
|
|
206
|
-
|
|
207
|
+
{ detailRect: h, galleryRect: g, pageRect: f, scrollOffset: l },
|
|
208
|
+
e
|
|
207
209
|
),
|
|
208
|
-
outAnimation:
|
|
209
|
-
{ galleryRect:
|
|
210
|
+
outAnimation: B(
|
|
211
|
+
{ galleryRect: g, detailRect: h, scrollOffset: l },
|
|
210
212
|
t
|
|
211
213
|
)
|
|
212
214
|
} : {
|
|
213
|
-
inAnimation:
|
|
214
|
-
{ galleryRect:
|
|
215
|
-
|
|
215
|
+
inAnimation: C(
|
|
216
|
+
{ galleryRect: g, detailRect: h, scrollOffset: l },
|
|
217
|
+
e
|
|
216
218
|
),
|
|
217
|
-
outAnimation:
|
|
218
|
-
{ detailRect:
|
|
219
|
+
outAnimation: T(
|
|
220
|
+
{ detailRect: h, galleryRect: g, pageRect: f, scrollOffset: l },
|
|
219
221
|
t
|
|
220
222
|
)
|
|
221
223
|
};
|
|
222
224
|
}
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
const I = (t = {}) => {
|
|
226
|
+
var e, l;
|
|
227
|
+
const i = {
|
|
228
|
+
stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 50,
|
|
229
|
+
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 10
|
|
230
|
+
}, r = t.timeout ?? 300;
|
|
231
|
+
let n = null, s = null, a = null;
|
|
229
232
|
return {
|
|
230
|
-
in: async (
|
|
231
|
-
const
|
|
232
|
-
return !await new Promise((
|
|
233
|
-
|
|
234
|
-
s = null,
|
|
235
|
-
},
|
|
236
|
-
}) || !
|
|
237
|
-
spring:
|
|
233
|
+
in: async (g, { scrollOffset: h }) => {
|
|
234
|
+
const f = g;
|
|
235
|
+
return !await new Promise((p) => {
|
|
236
|
+
n ? p(!0) : (s = p, setTimeout(() => {
|
|
237
|
+
s = null, p(!1);
|
|
238
|
+
}, r));
|
|
239
|
+
}) || !n ? (n = null, {
|
|
240
|
+
spring: i,
|
|
238
241
|
tick: () => {
|
|
239
242
|
}
|
|
240
|
-
}) : (a =
|
|
241
|
-
spring:
|
|
242
|
-
tick: (
|
|
243
|
-
a && a.inAnimation(
|
|
243
|
+
}) : (a = b(n, f, h), a ? (n = null, {
|
|
244
|
+
spring: i,
|
|
245
|
+
tick: (p) => {
|
|
246
|
+
a && a.inAnimation(p);
|
|
244
247
|
}
|
|
245
248
|
}) : {
|
|
246
|
-
spring:
|
|
249
|
+
spring: i,
|
|
247
250
|
tick: () => {
|
|
248
251
|
}
|
|
249
252
|
});
|
|
250
253
|
},
|
|
251
|
-
out: async (
|
|
252
|
-
spring:
|
|
254
|
+
out: async (g) => ({
|
|
255
|
+
spring: i,
|
|
253
256
|
onStart: () => {
|
|
254
|
-
|
|
257
|
+
n = g, s && (s(!0), s = null);
|
|
255
258
|
},
|
|
256
|
-
prepare: (
|
|
257
|
-
|
|
259
|
+
prepare: (h) => {
|
|
260
|
+
x(h), h.style.zIndex = "-1";
|
|
258
261
|
},
|
|
259
|
-
tick: (
|
|
260
|
-
a && a.outAnimation(
|
|
262
|
+
tick: (h) => {
|
|
263
|
+
a && a.outAnimation(h);
|
|
261
264
|
}
|
|
262
265
|
})
|
|
263
266
|
};
|
|
264
267
|
};
|
|
265
|
-
function
|
|
266
|
-
const
|
|
267
|
-
return Math.min(Math.max(
|
|
268
|
+
function O(t) {
|
|
269
|
+
const e = t.getBoundingClientRect(), l = t.clientHeight, i = 50 * (window.innerHeight - e.top) / l;
|
|
270
|
+
return Math.min(Math.max(i, 0), 100);
|
|
268
271
|
}
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
const F = (t = {}) => {
|
|
273
|
+
var e, l;
|
|
274
|
+
const i = {
|
|
275
|
+
stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
|
|
276
|
+
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 200
|
|
273
277
|
};
|
|
274
278
|
return {
|
|
275
|
-
in: (
|
|
276
|
-
const
|
|
279
|
+
in: (r) => {
|
|
280
|
+
const n = O(r);
|
|
277
281
|
return {
|
|
278
|
-
spring:
|
|
282
|
+
spring: i,
|
|
279
283
|
tick: (s) => {
|
|
280
|
-
|
|
284
|
+
r.style.clipPath = `circle(${s * 100}% at 50% ${n}%)`;
|
|
281
285
|
}
|
|
282
286
|
};
|
|
283
287
|
},
|
|
284
|
-
out: (
|
|
285
|
-
const
|
|
288
|
+
out: (r) => {
|
|
289
|
+
const n = O(r);
|
|
286
290
|
return {
|
|
287
|
-
spring:
|
|
291
|
+
spring: i,
|
|
288
292
|
tick: (s) => {
|
|
289
|
-
|
|
293
|
+
r.style.clipPath = `circle(${s * 100}% at 50% ${n}%)`, r.style.zIndex = "100";
|
|
290
294
|
},
|
|
291
|
-
prepare:
|
|
295
|
+
prepare: x
|
|
292
296
|
};
|
|
293
297
|
}
|
|
294
298
|
};
|
|
295
299
|
};
|
|
296
300
|
export {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
+
D as fade,
|
|
302
|
+
H as hero,
|
|
303
|
+
I as pinterest,
|
|
304
|
+
F as ripple
|
|
301
305
|
};
|