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