react-spring-carousel 3.0.0-beta-2.0.492 → 3.0.0-beta-2.0.495
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.es.js +356 -356
- package/dist/index.umd.js +7 -7
- package/dist/types.d.ts +1 -0
- package/dist/useSpringCarousel.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import
|
|
4
|
-
function
|
|
1
|
+
import { jsxs as Mt, jsx as J } from "react/jsx-runtime";
|
|
2
|
+
import { useSpring as Et } from "@react-spring/web";
|
|
3
|
+
import Q, { useRef as C, useEffect as R, useState as Vt } from "react";
|
|
4
|
+
function Rt(e, t, r) {
|
|
5
5
|
return Math.max(t, Math.min(e, r));
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const w = {
|
|
8
8
|
toVector(e, t) {
|
|
9
9
|
return e === void 0 && (e = t), Array.isArray(e) ? e : [e, e];
|
|
10
10
|
},
|
|
@@ -21,17 +21,17 @@ const b = {
|
|
|
21
21
|
e[0] -= t[0], e[1] -= t[1];
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function lt(e, t, r) {
|
|
25
25
|
return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(e, r * 5) : e * t * r / (t + r * e);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return n === 0 ?
|
|
27
|
+
function ft(e, t, r, n = 0.15) {
|
|
28
|
+
return n === 0 ? Rt(e, t, r) : e < t ? -lt(t - e, r - t, n) + t : e > r ? +lt(e - r, r - t, n) + r : e;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function jt(e, [t, r], [n, s]) {
|
|
31
31
|
const [[o, a], [c, l]] = e;
|
|
32
|
-
return [
|
|
32
|
+
return [ft(t, o, a, n), ft(r, c, l, s)];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Bt(e, t) {
|
|
35
35
|
if (typeof e != "object" || e === null) return e;
|
|
36
36
|
var r = e[Symbol.toPrimitive];
|
|
37
37
|
if (r !== void 0) {
|
|
@@ -41,19 +41,19 @@ function jt(e, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return (t === "string" ? String : Number)(e);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
var t =
|
|
44
|
+
function Ut(e) {
|
|
45
|
+
var t = Bt(e, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return t =
|
|
48
|
+
function S(e, t, r) {
|
|
49
|
+
return t = Ut(t), t in e ? Object.defineProperty(e, t, {
|
|
50
50
|
value: r,
|
|
51
51
|
enumerable: !0,
|
|
52
52
|
configurable: !0,
|
|
53
53
|
writable: !0
|
|
54
54
|
}) : e[t] = r, e;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function dt(e, t) {
|
|
57
57
|
var r = Object.keys(e);
|
|
58
58
|
if (Object.getOwnPropertySymbols) {
|
|
59
59
|
var n = Object.getOwnPropertySymbols(e);
|
|
@@ -66,15 +66,15 @@ function ft(e, t) {
|
|
|
66
66
|
function p(e) {
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var r = arguments[t] != null ? arguments[t] : {};
|
|
69
|
-
t % 2 ?
|
|
70
|
-
|
|
71
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) :
|
|
69
|
+
t % 2 ? dt(Object(r), !0).forEach(function(n) {
|
|
70
|
+
S(e, n, r[n]);
|
|
71
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : dt(Object(r)).forEach(function(n) {
|
|
72
72
|
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
return e;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const Tt = {
|
|
78
78
|
pointer: {
|
|
79
79
|
start: "down",
|
|
80
80
|
change: "move",
|
|
@@ -96,63 +96,63 @@ const Et = {
|
|
|
96
96
|
end: "end"
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
function
|
|
99
|
+
function ht(e) {
|
|
100
100
|
return e ? e[0].toUpperCase() + e.slice(1) : "";
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
104
|
-
return e && !
|
|
102
|
+
const Kt = ["enter", "leave"];
|
|
103
|
+
function Gt(e = !1, t) {
|
|
104
|
+
return e && !Kt.includes(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
const n =
|
|
108
|
-
return "on" +
|
|
106
|
+
function zt(e, t = "", r = !1) {
|
|
107
|
+
const n = Tt[e], s = n && n[t] || t;
|
|
108
|
+
return "on" + ht(e) + ht(s) + (Gt(r, s) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
110
|
+
const Wt = ["gotpointercapture", "lostpointercapture"];
|
|
111
|
+
function Yt(e) {
|
|
112
112
|
let t = e.substring(2).toLowerCase();
|
|
113
113
|
const r = !!~t.indexOf("passive");
|
|
114
114
|
r && (t = t.replace("passive", ""));
|
|
115
|
-
const n =
|
|
115
|
+
const n = Wt.includes(t) ? "capturecapture" : "capture", s = !!~t.indexOf(n);
|
|
116
116
|
return s && (t = t.replace("capture", "")), {
|
|
117
117
|
device: t,
|
|
118
118
|
capture: s,
|
|
119
119
|
passive: r
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
const r =
|
|
122
|
+
function Ft(e, t = "") {
|
|
123
|
+
const r = Tt[e], n = r && r[t] || t;
|
|
124
124
|
return e + n;
|
|
125
125
|
}
|
|
126
126
|
function W(e) {
|
|
127
127
|
return "touches" in e;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function St(e) {
|
|
130
130
|
return W(e) ? "touch" : "pointerType" in e ? e.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function Ht(e) {
|
|
133
133
|
return Array.from(e.touches).filter((t) => {
|
|
134
134
|
var r, n;
|
|
135
135
|
return t.target === e.currentTarget || ((r = e.currentTarget) === null || r === void 0 || (n = r.contains) === null || n === void 0 ? void 0 : n.call(r, t.target));
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Xt(e) {
|
|
139
139
|
return e.type === "touchend" || e.type === "touchcancel" ? e.changedTouches : e.targetTouches;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return W(e) ?
|
|
141
|
+
function xt(e) {
|
|
142
|
+
return W(e) ? Xt(e)[0] : e;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function qt(e) {
|
|
145
|
+
return Ht(e).map((t) => t.identifier);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
const t =
|
|
147
|
+
function Z(e) {
|
|
148
|
+
const t = xt(e);
|
|
149
149
|
return W(e) ? t.identifier : t.pointerId;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const t =
|
|
151
|
+
function pt(e) {
|
|
152
|
+
const t = xt(e);
|
|
153
153
|
return [t.clientX, t.clientY];
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function Jt(e) {
|
|
156
156
|
const t = {};
|
|
157
157
|
if ("buttons" in e && (t.buttons = e.buttons), "shiftKey" in e) {
|
|
158
158
|
const {
|
|
@@ -173,21 +173,21 @@ function qt(e) {
|
|
|
173
173
|
function z(e, ...t) {
|
|
174
174
|
return typeof e == "function" ? e(...t) : e;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function Qt() {
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return e.length === 0 ?
|
|
178
|
+
function Zt(...e) {
|
|
179
|
+
return e.length === 0 ? Qt : e.length === 1 ? e[0] : function() {
|
|
180
180
|
let t;
|
|
181
181
|
for (const r of e)
|
|
182
182
|
t = r.apply(this, arguments) || t;
|
|
183
183
|
return t;
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function mt(e, t) {
|
|
187
187
|
return Object.assign({}, t, e || {});
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
class
|
|
189
|
+
const te = 32;
|
|
190
|
+
class ee {
|
|
191
191
|
constructor(t, r, n) {
|
|
192
192
|
this.ctrl = t, this.args = r, this.key = n, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
|
|
193
193
|
}
|
|
@@ -244,32 +244,32 @@ class te {
|
|
|
244
244
|
} = this;
|
|
245
245
|
r.args = this.args;
|
|
246
246
|
let o = 0;
|
|
247
|
-
if (t && (r.event = t, n.preventDefault && t.cancelable && r.event.preventDefault(), r.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s,
|
|
248
|
-
const
|
|
249
|
-
|
|
247
|
+
if (t && (r.event = t, n.preventDefault && t.cancelable && r.event.preventDefault(), r.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s, Jt(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, o = t.timeStamp - r.timeStamp, r.timeStamp = t.timeStamp, r.elapsedTime = r.timeStamp - r.startTime), r._active) {
|
|
248
|
+
const O = r._delta.map(Math.abs);
|
|
249
|
+
w.addTo(r._distance, O);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
|
-
const [a, c] = r._movement, [l,
|
|
252
|
+
const [a, c] = r._movement, [l, d] = n.threshold, {
|
|
253
253
|
_step: u,
|
|
254
254
|
values: v
|
|
255
255
|
} = r;
|
|
256
|
-
if (n.hasCustomTransform ? (u[0] === !1 && (u[0] = Math.abs(a) >= l && v[0]), u[1] === !1 && (u[1] = Math.abs(c) >=
|
|
256
|
+
if (n.hasCustomTransform ? (u[0] === !1 && (u[0] = Math.abs(a) >= l && v[0]), u[1] === !1 && (u[1] = Math.abs(c) >= d && v[1])) : (u[0] === !1 && (u[0] = Math.abs(a) >= l && Math.sign(a) * l), u[1] === !1 && (u[1] = Math.abs(c) >= d && Math.sign(c) * d)), r.intentional = u[0] !== !1 || u[1] !== !1, !r.intentional) return;
|
|
257
257
|
const m = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
|
-
const [
|
|
260
|
-
m[0] = u[0] !== !1 ?
|
|
259
|
+
const [O, h] = v;
|
|
260
|
+
m[0] = u[0] !== !1 ? O - u[0] : 0, m[1] = u[1] !== !1 ? h - u[1] : 0;
|
|
261
261
|
} else
|
|
262
262
|
m[0] = u[0] !== !1 ? a - u[0] : 0, m[1] = u[1] !== !1 ? c - u[1] : 0;
|
|
263
263
|
this.restrictToAxis && !r._blocked && this.restrictToAxis(m);
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const [
|
|
267
|
-
r.overflow = [
|
|
268
|
-
const
|
|
269
|
-
if (r.offset =
|
|
270
|
-
r.delta =
|
|
271
|
-
const
|
|
272
|
-
|
|
264
|
+
const E = r.offset, k = r._active && !r._blocked || r.active;
|
|
265
|
+
k && (r.first = r._active && !r.active, r.last = !r._active && r.active, r.active = s[this.ingKey] = r._active, t && (r.first && ("bounds" in n && (r._bounds = z(n.bounds, r)), this.setup && this.setup()), r.movement = m, this.computeOffset()));
|
|
266
|
+
const [P, y] = r.offset, [[$, L], [b, x]] = r._bounds;
|
|
267
|
+
r.overflow = [P < $ ? -1 : P > L ? 1 : 0, y < b ? -1 : y > x ? 1 : 0], r._movementBound[0] = r.overflow[0] ? r._movementBound[0] === !1 ? r._movement[0] : r._movementBound[0] : !1, r._movementBound[1] = r.overflow[1] ? r._movementBound[1] === !1 ? r._movement[1] : r._movementBound[1] : !1;
|
|
268
|
+
const N = r._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
+
if (r.offset = jt(r._bounds, r.offset, N), r.delta = w.sub(r.offset, E), this.computeMovement(), k && (!r.last || o > te)) {
|
|
270
|
+
r.delta = w.sub(r.offset, E);
|
|
271
|
+
const O = r.delta.map(Math.abs);
|
|
272
|
+
w.addTo(r.distance, O), r.direction = r.delta.map(Math.sign), r._direction = r._delta.map(Math.sign), !r.first && o > 0 && (r.velocity = [O[0] / o, O[1] / o], r.timeDelta = o);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
emit() {
|
|
@@ -284,16 +284,16 @@ class te {
|
|
|
284
284
|
this.eventStore.clean(), this.timeoutStore.clean();
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function re([e, t], r) {
|
|
288
288
|
const n = Math.abs(e), s = Math.abs(t);
|
|
289
289
|
if (n > s && n > r)
|
|
290
290
|
return "x";
|
|
291
291
|
if (s > n && s > r)
|
|
292
292
|
return "y";
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class ne extends ee {
|
|
295
295
|
constructor(...t) {
|
|
296
|
-
super(...t),
|
|
296
|
+
super(...t), S(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
298
298
|
reset() {
|
|
299
299
|
super.reset(), this.state.axis = void 0;
|
|
@@ -302,16 +302,16 @@ class re extends te {
|
|
|
302
302
|
this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
|
|
303
303
|
}
|
|
304
304
|
computeOffset() {
|
|
305
|
-
this.state.offset =
|
|
305
|
+
this.state.offset = w.add(this.state.lastOffset, this.state.movement);
|
|
306
306
|
}
|
|
307
307
|
computeMovement() {
|
|
308
|
-
this.state.movement =
|
|
308
|
+
this.state.movement = w.sub(this.state.offset, this.state.lastOffset);
|
|
309
309
|
}
|
|
310
310
|
axisIntent(t) {
|
|
311
311
|
const r = this.state, n = this.config;
|
|
312
312
|
if (!r.axis && t) {
|
|
313
|
-
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[
|
|
314
|
-
r.axis =
|
|
313
|
+
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[St(t)] : n.axisThreshold;
|
|
314
|
+
r.axis = re(r._movement, s);
|
|
315
315
|
}
|
|
316
316
|
r._blocked = (n.lockDirection || !!n.axis) && !r.axis || !!n.axis && n.axis !== r.axis;
|
|
317
317
|
}
|
|
@@ -327,7 +327,7 @@ class re extends te {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const gt = (e) => e, vt = 0.15, nt = {
|
|
331
331
|
enabled(e = !0) {
|
|
332
332
|
return e;
|
|
333
333
|
},
|
|
@@ -343,33 +343,33 @@ const mt = (e) => e, gt = 0.15, rt = {
|
|
|
343
343
|
rubberband(e = 0) {
|
|
344
344
|
switch (e) {
|
|
345
345
|
case !0:
|
|
346
|
-
return [
|
|
346
|
+
return [vt, vt];
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
350
|
-
return
|
|
350
|
+
return w.toVector(e);
|
|
351
351
|
}
|
|
352
352
|
},
|
|
353
353
|
from(e) {
|
|
354
354
|
if (typeof e == "function") return e;
|
|
355
|
-
if (e != null) return
|
|
355
|
+
if (e != null) return w.toVector(e);
|
|
356
356
|
},
|
|
357
357
|
transform(e, t, r) {
|
|
358
358
|
const n = e || r.shared.transform;
|
|
359
359
|
if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
|
|
360
|
-
const s = n ||
|
|
360
|
+
const s = n || gt;
|
|
361
361
|
return (o) => {
|
|
362
362
|
const a = s(o);
|
|
363
363
|
return (!isFinite(a[0]) || !isFinite(a[1])) && console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`), a;
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
return n ||
|
|
366
|
+
return n || gt;
|
|
367
367
|
},
|
|
368
368
|
threshold(e) {
|
|
369
|
-
return
|
|
369
|
+
return w.toVector(e, 0);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
372
|
+
process.env.NODE_ENV === "development" && Object.assign(nt, {
|
|
373
373
|
domTarget(e) {
|
|
374
374
|
if (e !== void 0)
|
|
375
375
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -386,13 +386,13 @@ process.env.NODE_ENV === "development" && Object.assign(rt, {
|
|
|
386
386
|
return NaN;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
const
|
|
389
|
+
const se = 0, j = p(p({}, nt), {}, {
|
|
390
390
|
axis(e, t, {
|
|
391
391
|
axis: r
|
|
392
392
|
}) {
|
|
393
393
|
if (this.lockDirection = r === "lock", !this.lockDirection) return r;
|
|
394
394
|
},
|
|
395
|
-
axisThreshold(e =
|
|
395
|
+
axisThreshold(e = se) {
|
|
396
396
|
return e;
|
|
397
397
|
},
|
|
398
398
|
bounds(e = {}) {
|
|
@@ -410,15 +410,15 @@ const ne = 0, j = p(p({}, rt), {}, {
|
|
|
410
410
|
} = e;
|
|
411
411
|
return [[t, r], [n, s]];
|
|
412
412
|
}
|
|
413
|
-
}),
|
|
413
|
+
}), yt = {
|
|
414
414
|
ArrowRight: (e, t = 1) => [e * t, 0],
|
|
415
415
|
ArrowLeft: (e, t = 1) => [-1 * e * t, 0],
|
|
416
416
|
ArrowUp: (e, t = 1) => [0, -1 * e * t],
|
|
417
417
|
ArrowDown: (e, t = 1) => [0, e * t]
|
|
418
418
|
};
|
|
419
|
-
class
|
|
419
|
+
class ie extends ne {
|
|
420
420
|
constructor(...t) {
|
|
421
|
-
super(...t),
|
|
421
|
+
super(...t), S(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
423
423
|
reset() {
|
|
424
424
|
super.reset();
|
|
@@ -453,7 +453,7 @@ class se extends re {
|
|
|
453
453
|
const r = this.config, n = this.state;
|
|
454
454
|
if (t.buttons != null && (Array.isArray(r.pointerButtons) ? !r.pointerButtons.includes(t.buttons) : r.pointerButtons !== -1 && r.pointerButtons !== t.buttons)) return;
|
|
455
455
|
const s = this.ctrl.setEventIds(t);
|
|
456
|
-
r.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId =
|
|
456
|
+
r.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = Z(t), n._pointerActive = !0, this.computeValues(pt(t)), this.computeInitial(), r.preventScrollAxis && St(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : r.delay > 0 ? (this.setupDelayTrigger(t), r.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
|
|
457
457
|
}
|
|
458
458
|
startPointerDrag(t) {
|
|
459
459
|
const r = this.state;
|
|
@@ -462,10 +462,10 @@ class se extends re {
|
|
|
462
462
|
pointerMove(t) {
|
|
463
463
|
const r = this.state, n = this.config;
|
|
464
464
|
if (!r._pointerActive) return;
|
|
465
|
-
const s =
|
|
465
|
+
const s = Z(t);
|
|
466
466
|
if (r._pointerId !== void 0 && s !== r._pointerId) return;
|
|
467
|
-
const o =
|
|
468
|
-
if (document.pointerLockElement === t.target ? r._delta = [t.movementX, t.movementY] : (r._delta =
|
|
467
|
+
const o = pt(t);
|
|
468
|
+
if (document.pointerLockElement === t.target ? r._delta = [t.movementX, t.movementY] : (r._delta = w.sub(o, r._values), this.computeValues(o)), w.addTo(r._movement, r._delta), this.compute(t), r._delayed && r.intentional) {
|
|
469
469
|
this.timeoutStore.remove("dragDelay"), r.active = !1, this.startPointerDrag(t);
|
|
470
470
|
return;
|
|
471
471
|
}
|
|
@@ -491,17 +491,17 @@ class se extends re {
|
|
|
491
491
|
}
|
|
492
492
|
const r = this.state, n = this.config;
|
|
493
493
|
if (!r._active || !r._pointerActive) return;
|
|
494
|
-
const s =
|
|
494
|
+
const s = Z(t);
|
|
495
495
|
if (r._pointerId !== void 0 && s !== r._pointerId) return;
|
|
496
496
|
this.state._pointerActive = !1, this.setActive(), this.compute(t);
|
|
497
497
|
const [o, a] = r._distance;
|
|
498
498
|
if (r.tap = o <= n.tapsThreshold && a <= n.tapsThreshold, r.tap && n.filterTaps)
|
|
499
499
|
r._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [c, l] = r._delta, [
|
|
502
|
-
if (r.elapsedTime <
|
|
503
|
-
const
|
|
504
|
-
|
|
501
|
+
const [c, l] = r._delta, [d, u] = r._movement, [v, m] = n.swipe.velocity, [E, k] = n.swipe.distance, P = n.swipe.duration;
|
|
502
|
+
if (r.elapsedTime < P) {
|
|
503
|
+
const y = Math.abs(c / r.timeDelta), $ = Math.abs(l / r.timeDelta);
|
|
504
|
+
y > v && Math.abs(d) > E && (r.swipe[0] = Math.sign(c)), $ > m && Math.abs(u) > k && (r.swipe[1] = Math.sign(l));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -528,7 +528,7 @@ class se extends re {
|
|
|
528
528
|
this.state._preventScroll && t.cancelable && t.preventDefault();
|
|
529
529
|
}
|
|
530
530
|
setupScrollPrevention(t) {
|
|
531
|
-
this.state._preventScroll = !1,
|
|
531
|
+
this.state._preventScroll = !1, oe(t);
|
|
532
532
|
const r = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
|
533
533
|
passive: !1
|
|
534
534
|
});
|
|
@@ -540,14 +540,14 @@ class se extends re {
|
|
|
540
540
|
}, this.config.delay);
|
|
541
541
|
}
|
|
542
542
|
keyDown(t) {
|
|
543
|
-
const r =
|
|
543
|
+
const r = yt[t.key];
|
|
544
544
|
if (r) {
|
|
545
545
|
const n = this.state, s = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
546
|
-
this.start(t), n._delta = r(this.config.keyboardDisplacement, s), n._keyboardActive = !0,
|
|
546
|
+
this.start(t), n._delta = r(this.config.keyboardDisplacement, s), n._keyboardActive = !0, w.addTo(n._movement, n._delta), this.compute(t), this.emit();
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
keyUp(t) {
|
|
550
|
-
t.key in
|
|
550
|
+
t.key in yt && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
|
|
551
551
|
}
|
|
552
552
|
bind(t) {
|
|
553
553
|
const r = this.config.device;
|
|
@@ -557,41 +557,41 @@ class se extends re {
|
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function oe(e) {
|
|
561
561
|
"persist" in e && typeof e.persist == "function" && e.persist();
|
|
562
562
|
}
|
|
563
563
|
const B = typeof window < "u" && window.document && window.document.createElement;
|
|
564
|
-
function
|
|
564
|
+
function It() {
|
|
565
565
|
return B && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
|
-
function oe() {
|
|
568
|
-
return xt() || B && window.navigator.maxTouchPoints > 1;
|
|
569
|
-
}
|
|
570
567
|
function ae() {
|
|
571
|
-
return B &&
|
|
568
|
+
return It() || B && window.navigator.maxTouchPoints > 1;
|
|
572
569
|
}
|
|
573
570
|
function ce() {
|
|
574
|
-
return B && "
|
|
571
|
+
return B && "onpointerdown" in window;
|
|
575
572
|
}
|
|
576
573
|
function ue() {
|
|
574
|
+
return B && "exitPointerLock" in window.document;
|
|
575
|
+
}
|
|
576
|
+
function le() {
|
|
577
577
|
try {
|
|
578
578
|
return "constructor" in GestureEvent;
|
|
579
579
|
} catch {
|
|
580
580
|
return !1;
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
-
const
|
|
583
|
+
const D = {
|
|
584
584
|
isBrowser: B,
|
|
585
|
-
gesture:
|
|
586
|
-
touch:
|
|
587
|
-
touchscreen:
|
|
588
|
-
pointer:
|
|
589
|
-
pointerLock:
|
|
590
|
-
},
|
|
585
|
+
gesture: le(),
|
|
586
|
+
touch: It(),
|
|
587
|
+
touchscreen: ae(),
|
|
588
|
+
pointer: ce(),
|
|
589
|
+
pointerLock: ue()
|
|
590
|
+
}, fe = 250, de = 180, he = 0.5, pe = 50, me = 250, ge = 10, bt = {
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
},
|
|
594
|
+
}, kt = p(p({}, j), {}, {
|
|
595
595
|
device(e, t, {
|
|
596
596
|
pointer: {
|
|
597
597
|
touch: r = !1,
|
|
@@ -599,12 +599,12 @@ const O = {
|
|
|
599
599
|
mouse: s = !1
|
|
600
600
|
} = {}
|
|
601
601
|
}) {
|
|
602
|
-
return this.pointerLock = n &&
|
|
602
|
+
return this.pointerLock = n && D.pointerLock, D.touch && r ? "touch" : this.pointerLock ? "mouse" : D.pointer && !s ? "pointer" : D.touch ? "touch" : "mouse";
|
|
603
603
|
},
|
|
604
604
|
preventScrollAxis(e, t, {
|
|
605
605
|
preventScroll: r
|
|
606
606
|
}) {
|
|
607
|
-
if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && e ?
|
|
607
|
+
if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && e ? fe : void 0, !(!D.touchscreen || r === !1))
|
|
608
608
|
return e || (r !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
610
|
pointerCapture(e, t, {
|
|
@@ -621,24 +621,24 @@ const O = {
|
|
|
621
621
|
tapsThreshold: n = 3,
|
|
622
622
|
axis: s = void 0
|
|
623
623
|
}) {
|
|
624
|
-
const o =
|
|
624
|
+
const o = w.toVector(e, r ? n : s ? 1 : 0);
|
|
625
625
|
return this.filterTaps = r, this.tapsThreshold = n, o;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
628
|
-
velocity: e =
|
|
629
|
-
distance: t =
|
|
630
|
-
duration: r =
|
|
628
|
+
velocity: e = he,
|
|
629
|
+
distance: t = pe,
|
|
630
|
+
duration: r = me
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
|
-
velocity: this.transform(
|
|
634
|
-
distance: this.transform(
|
|
633
|
+
velocity: this.transform(w.toVector(e)),
|
|
634
|
+
distance: this.transform(w.toVector(t)),
|
|
635
635
|
duration: r
|
|
636
636
|
};
|
|
637
637
|
},
|
|
638
638
|
delay(e = 0) {
|
|
639
639
|
switch (e) {
|
|
640
640
|
case !0:
|
|
641
|
-
return
|
|
641
|
+
return de;
|
|
642
642
|
case !1:
|
|
643
643
|
return 0;
|
|
644
644
|
default:
|
|
@@ -646,13 +646,13 @@ const O = {
|
|
|
646
646
|
}
|
|
647
647
|
},
|
|
648
648
|
axisThreshold(e) {
|
|
649
|
-
return e ? p(p({},
|
|
649
|
+
return e ? p(p({}, bt), e) : bt;
|
|
650
650
|
},
|
|
651
|
-
keyboardDisplacement(e =
|
|
651
|
+
keyboardDisplacement(e = ge) {
|
|
652
652
|
return e;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
655
|
+
process.env.NODE_ENV === "development" && Object.assign(kt, {
|
|
656
656
|
useTouch(e) {
|
|
657
657
|
if (e !== void 0)
|
|
658
658
|
throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");
|
|
@@ -679,18 +679,18 @@ process.env.NODE_ENV === "development" && Object.assign(It, {
|
|
|
679
679
|
return NaN;
|
|
680
680
|
}
|
|
681
681
|
});
|
|
682
|
-
p(p({},
|
|
682
|
+
p(p({}, nt), {}, {
|
|
683
683
|
device(e, t, {
|
|
684
684
|
shared: r,
|
|
685
685
|
pointer: {
|
|
686
686
|
touch: n = !1
|
|
687
687
|
} = {}
|
|
688
688
|
}) {
|
|
689
|
-
if (r.target && !
|
|
690
|
-
if (
|
|
691
|
-
if (
|
|
692
|
-
if (
|
|
693
|
-
if (
|
|
689
|
+
if (r.target && !D.touch && D.gesture) return "gesture";
|
|
690
|
+
if (D.touch && n) return "touch";
|
|
691
|
+
if (D.touchscreen) {
|
|
692
|
+
if (D.pointer) return "pointer";
|
|
693
|
+
if (D.touch) return "touch";
|
|
694
694
|
}
|
|
695
695
|
},
|
|
696
696
|
bounds(e, t, {
|
|
@@ -698,13 +698,13 @@ p(p({}, rt), {}, {
|
|
|
698
698
|
angleBounds: n = {}
|
|
699
699
|
}) {
|
|
700
700
|
const s = (a) => {
|
|
701
|
-
const c =
|
|
701
|
+
const c = mt(z(r, a), {
|
|
702
702
|
min: -1 / 0,
|
|
703
703
|
max: 1 / 0
|
|
704
704
|
});
|
|
705
705
|
return [c.min, c.max];
|
|
706
706
|
}, o = (a) => {
|
|
707
|
-
const c =
|
|
707
|
+
const c = mt(z(n, a), {
|
|
708
708
|
min: -1 / 0,
|
|
709
709
|
max: 1 / 0
|
|
710
710
|
});
|
|
@@ -713,7 +713,7 @@ p(p({}, rt), {}, {
|
|
|
713
713
|
return typeof r != "function" && typeof n != "function" ? [s(), o()] : (a) => [s(a), o(a)];
|
|
714
714
|
},
|
|
715
715
|
threshold(e, t, r) {
|
|
716
|
-
return this.lockDirection = r.axis === "lock",
|
|
716
|
+
return this.lockDirection = r.axis === "lock", w.toVector(e, this.lockDirection ? [0.1, 3] : 0);
|
|
717
717
|
},
|
|
718
718
|
modifierKey(e) {
|
|
719
719
|
return e === void 0 ? "ctrlKey" : e;
|
|
@@ -728,25 +728,25 @@ p(p({}, j), {}, {
|
|
|
728
728
|
p(p({}, j), {}, {
|
|
729
729
|
mouseOnly: (e = !0) => e
|
|
730
730
|
});
|
|
731
|
-
const
|
|
732
|
-
function
|
|
733
|
-
|
|
731
|
+
const Ct = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Map();
|
|
732
|
+
function ve(e) {
|
|
733
|
+
Ct.set(e.key, e.engine), rt.set(e.key, e.resolver);
|
|
734
734
|
}
|
|
735
|
-
const
|
|
735
|
+
const ye = {
|
|
736
736
|
key: "drag",
|
|
737
|
-
engine:
|
|
738
|
-
resolver:
|
|
737
|
+
engine: ie,
|
|
738
|
+
resolver: kt
|
|
739
739
|
};
|
|
740
|
-
function
|
|
740
|
+
function be(e, t) {
|
|
741
741
|
if (e == null) return {};
|
|
742
742
|
var r = {}, n = Object.keys(e), s, o;
|
|
743
743
|
for (o = 0; o < n.length; o++)
|
|
744
744
|
s = n[o], !(t.indexOf(s) >= 0) && (r[s] = e[s]);
|
|
745
745
|
return r;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function _e(e, t) {
|
|
748
748
|
if (e == null) return {};
|
|
749
|
-
var r =
|
|
749
|
+
var r = be(e, t), n, s;
|
|
750
750
|
if (Object.getOwnPropertySymbols) {
|
|
751
751
|
var o = Object.getOwnPropertySymbols(e);
|
|
752
752
|
for (s = 0; s < o.length; s++)
|
|
@@ -754,7 +754,7 @@ function be(e, t) {
|
|
|
754
754
|
}
|
|
755
755
|
return r;
|
|
756
756
|
}
|
|
757
|
-
const
|
|
757
|
+
const we = {
|
|
758
758
|
target(e) {
|
|
759
759
|
if (e)
|
|
760
760
|
return () => "current" in e ? e.current : e;
|
|
@@ -762,7 +762,7 @@ const _e = {
|
|
|
762
762
|
enabled(e = !0) {
|
|
763
763
|
return e;
|
|
764
764
|
},
|
|
765
|
-
window(e =
|
|
765
|
+
window(e = D.isBrowser ? window : void 0) {
|
|
766
766
|
return e;
|
|
767
767
|
},
|
|
768
768
|
eventOptions({
|
|
@@ -777,7 +777,7 @@ const _e = {
|
|
|
777
777
|
transform(e) {
|
|
778
778
|
return e;
|
|
779
779
|
}
|
|
780
|
-
},
|
|
780
|
+
}, Ee = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
781
781
|
function G(e = {}, t) {
|
|
782
782
|
const r = {};
|
|
783
783
|
for (const [n, s] of Object.entries(t))
|
|
@@ -798,32 +798,32 @@ function G(e = {}, t) {
|
|
|
798
798
|
}
|
|
799
799
|
return r;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function Te(e, t, r = {}) {
|
|
802
802
|
const n = e, {
|
|
803
803
|
target: s,
|
|
804
804
|
eventOptions: o,
|
|
805
805
|
window: a,
|
|
806
806
|
enabled: c,
|
|
807
807
|
transform: l
|
|
808
|
-
} = n,
|
|
808
|
+
} = n, d = _e(n, Ee);
|
|
809
809
|
if (r.shared = G({
|
|
810
810
|
target: s,
|
|
811
811
|
eventOptions: o,
|
|
812
812
|
window: a,
|
|
813
813
|
enabled: c,
|
|
814
814
|
transform: l
|
|
815
|
-
},
|
|
816
|
-
const u =
|
|
815
|
+
}, we), t) {
|
|
816
|
+
const u = rt.get(t);
|
|
817
817
|
r[t] = G(p({
|
|
818
818
|
shared: r.shared
|
|
819
|
-
},
|
|
819
|
+
}, d), u);
|
|
820
820
|
} else
|
|
821
|
-
for (const u in
|
|
822
|
-
const v =
|
|
821
|
+
for (const u in d) {
|
|
822
|
+
const v = rt.get(u);
|
|
823
823
|
if (v)
|
|
824
824
|
r[u] = G(p({
|
|
825
825
|
shared: r.shared
|
|
826
|
-
},
|
|
826
|
+
}, d[u]), v);
|
|
827
827
|
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(u)) {
|
|
828
828
|
if (u === "domTarget")
|
|
829
829
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -832,15 +832,15 @@ function Ee(e, t, r = {}) {
|
|
|
832
832
|
}
|
|
833
833
|
return r;
|
|
834
834
|
}
|
|
835
|
-
class
|
|
835
|
+
class Dt {
|
|
836
836
|
constructor(t, r) {
|
|
837
|
-
|
|
837
|
+
S(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = r;
|
|
838
838
|
}
|
|
839
839
|
add(t, r, n, s, o) {
|
|
840
|
-
const a = this._listeners, c =
|
|
841
|
-
t.addEventListener(c, s,
|
|
840
|
+
const a = this._listeners, c = Ft(r, n), l = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, d = p(p({}, l), o);
|
|
841
|
+
t.addEventListener(c, s, d);
|
|
842
842
|
const u = () => {
|
|
843
|
-
t.removeEventListener(c, s,
|
|
843
|
+
t.removeEventListener(c, s, d), a.delete(u);
|
|
844
844
|
};
|
|
845
845
|
return a.add(u), u;
|
|
846
846
|
}
|
|
@@ -848,9 +848,9 @@ class Ct {
|
|
|
848
848
|
this._listeners.forEach((t) => t()), this._listeners.clear();
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
class
|
|
851
|
+
class Se {
|
|
852
852
|
constructor() {
|
|
853
|
-
|
|
853
|
+
S(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
855
855
|
add(t, r, n = 140, ...s) {
|
|
856
856
|
this.remove(t), this._timeouts.set(t, window.setTimeout(r, n, ...s));
|
|
@@ -863,20 +863,20 @@ class Te {
|
|
|
863
863
|
this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
class
|
|
866
|
+
class xe {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
|
|
868
|
+
S(this, "gestures", /* @__PURE__ */ new Set()), S(this, "_targetEventStore", new Dt(this)), S(this, "gestureEventStores", {}), S(this, "gestureTimeoutStores", {}), S(this, "handlers", {}), S(this, "config", {}), S(this, "pointerIds", /* @__PURE__ */ new Set()), S(this, "touchIds", /* @__PURE__ */ new Set()), S(this, "state", {
|
|
869
869
|
shared: {
|
|
870
870
|
shiftKey: !1,
|
|
871
871
|
metaKey: !1,
|
|
872
872
|
ctrlKey: !1,
|
|
873
873
|
altKey: !1
|
|
874
874
|
}
|
|
875
|
-
}),
|
|
875
|
+
}), Ie(this, t);
|
|
876
876
|
}
|
|
877
877
|
setEventIds(t) {
|
|
878
878
|
if (W(t))
|
|
879
|
-
return this.touchIds = new Set(
|
|
879
|
+
return this.touchIds = new Set(qt(t)), this.touchIds;
|
|
880
880
|
if ("pointerId" in t)
|
|
881
881
|
return t.type === "pointerup" || t.type === "pointercancel" ? this.pointerIds.delete(t.pointerId) : t.type === "pointerdown" && this.pointerIds.add(t.pointerId), this.pointerIds;
|
|
882
882
|
}
|
|
@@ -884,7 +884,7 @@ class Se {
|
|
|
884
884
|
this.handlers = t, this.nativeHandlers = r;
|
|
885
885
|
}
|
|
886
886
|
applyConfig(t, r) {
|
|
887
|
-
this.config =
|
|
887
|
+
this.config = Te(t, r, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -900,13 +900,13 @@ class Se {
|
|
|
900
900
|
if (!(r.target && (s = r.target(), !s))) {
|
|
901
901
|
if (r.enabled) {
|
|
902
902
|
for (const a of this.gestures) {
|
|
903
|
-
const c = this.config[a], l =
|
|
903
|
+
const c = this.config[a], l = _t(n, c.eventOptions, !!s);
|
|
904
904
|
if (c.enabled) {
|
|
905
|
-
const
|
|
906
|
-
new
|
|
905
|
+
const d = Ct.get(a);
|
|
906
|
+
new d(this, t, a).bind(l);
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
const o =
|
|
909
|
+
const o = _t(n, r.eventOptions, !!s);
|
|
910
910
|
for (const a in this.nativeHandlers)
|
|
911
911
|
o(a, "", (c) => this.nativeHandlers[a](p(p({}, this.state.shared), {}, {
|
|
912
912
|
event: c,
|
|
@@ -914,14 +914,14 @@ class Se {
|
|
|
914
914
|
})), void 0, !0);
|
|
915
915
|
}
|
|
916
916
|
for (const o in n)
|
|
917
|
-
n[o] =
|
|
917
|
+
n[o] = Zt(...n[o]);
|
|
918
918
|
if (!s) return n;
|
|
919
919
|
for (const o in n) {
|
|
920
920
|
const {
|
|
921
921
|
device: a,
|
|
922
922
|
capture: c,
|
|
923
923
|
passive: l
|
|
924
|
-
} =
|
|
924
|
+
} = Yt(o);
|
|
925
925
|
this._targetEventStore.add(s, a, "", n[o], {
|
|
926
926
|
capture: c,
|
|
927
927
|
passive: l
|
|
@@ -930,42 +930,42 @@ class Se {
|
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
function
|
|
934
|
-
e.gestures.add(t), e.gestureEventStores[t] = new
|
|
933
|
+
function V(e, t) {
|
|
934
|
+
e.gestures.add(t), e.gestureEventStores[t] = new Dt(e, t), e.gestureTimeoutStores[t] = new Se();
|
|
935
935
|
}
|
|
936
|
-
function
|
|
937
|
-
t.drag &&
|
|
936
|
+
function Ie(e, t) {
|
|
937
|
+
t.drag && V(e, "drag"), t.wheel && V(e, "wheel"), t.scroll && V(e, "scroll"), t.move && V(e, "move"), t.pinch && V(e, "pinch"), t.hover && V(e, "hover");
|
|
938
938
|
}
|
|
939
|
-
const
|
|
940
|
-
var l,
|
|
941
|
-
const u = (l = a.capture) !== null && l !== void 0 ? l : t.capture, v = (
|
|
942
|
-
let m = c ? n :
|
|
939
|
+
const _t = (e, t, r) => (n, s, o, a = {}, c = !1) => {
|
|
940
|
+
var l, d;
|
|
941
|
+
const u = (l = a.capture) !== null && l !== void 0 ? l : t.capture, v = (d = a.passive) !== null && d !== void 0 ? d : t.passive;
|
|
942
|
+
let m = c ? n : zt(n, s, u);
|
|
943
943
|
r && v && (m += "Passive"), e[m] = e[m] || [], e[m].push(o);
|
|
944
944
|
};
|
|
945
|
-
function
|
|
946
|
-
const s =
|
|
947
|
-
if (s.applyHandlers(e, n), s.applyConfig(t, r),
|
|
945
|
+
function ke(e, t = {}, r, n) {
|
|
946
|
+
const s = Q.useMemo(() => new xe(e), []);
|
|
947
|
+
if (s.applyHandlers(e, n), s.applyConfig(t, r), Q.useEffect(s.effect.bind(s)), Q.useEffect(() => s.clean.bind(s), []), t.target === void 0)
|
|
948
948
|
return s.bind.bind(s);
|
|
949
949
|
}
|
|
950
|
-
function
|
|
951
|
-
return
|
|
950
|
+
function Ce(e, t) {
|
|
951
|
+
return ve(ye), ke({
|
|
952
952
|
drag: e
|
|
953
953
|
}, t || {}, "drag");
|
|
954
954
|
}
|
|
955
|
-
const
|
|
956
|
-
function
|
|
957
|
-
const e =
|
|
955
|
+
const tt = "RSC::Event";
|
|
956
|
+
function De() {
|
|
957
|
+
const e = C(null);
|
|
958
958
|
function t(n) {
|
|
959
|
-
|
|
959
|
+
R(() => {
|
|
960
960
|
e.current || (e.current = document.createElement("div"));
|
|
961
961
|
function s(o) {
|
|
962
962
|
n(o.detail);
|
|
963
963
|
}
|
|
964
964
|
if (e.current)
|
|
965
|
-
return e.current.addEventListener(
|
|
965
|
+
return e.current.addEventListener(tt, s, !1), () => {
|
|
966
966
|
var o;
|
|
967
967
|
(o = e.current) == null || o.removeEventListener(
|
|
968
|
-
|
|
968
|
+
tt,
|
|
969
969
|
s,
|
|
970
970
|
!1
|
|
971
971
|
);
|
|
@@ -974,7 +974,7 @@ function Ce() {
|
|
|
974
974
|
}
|
|
975
975
|
function r(n) {
|
|
976
976
|
if (e.current) {
|
|
977
|
-
const s = new CustomEvent(
|
|
977
|
+
const s = new CustomEvent(tt, {
|
|
978
978
|
detail: n
|
|
979
979
|
});
|
|
980
980
|
e.current.dispatchEvent(s);
|
|
@@ -985,11 +985,11 @@ function Ce() {
|
|
|
985
985
|
emitEvent: r
|
|
986
986
|
};
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function Pe(e) {
|
|
989
989
|
let t = e.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, "");
|
|
990
990
|
return t = t.replace(/[\n\t]+/g, " "), t = t.replace(/\s*([{}:;,])\s*/g, "$1"), t = t.replace(/\s+}/g, "}"), t = t.replace(/{\s+/g, "{"), t = t.replace(/\s+/g, " "), t.trim();
|
|
991
991
|
}
|
|
992
|
-
function
|
|
992
|
+
function Me({
|
|
993
993
|
init: e = !0,
|
|
994
994
|
items: t,
|
|
995
995
|
withLoop: r = !1,
|
|
@@ -999,22 +999,20 @@ function Le({
|
|
|
999
999
|
carouselAxis: a = "x",
|
|
1000
1000
|
startingPosition: c = "start",
|
|
1001
1001
|
enableGestures: l = !0,
|
|
1002
|
-
slideWhenDragThresholdIsReached:
|
|
1002
|
+
slideWhenDragThresholdIsReached: d = !0,
|
|
1003
1003
|
onInit: u,
|
|
1004
|
-
initialActiveItem: v = 0
|
|
1004
|
+
initialActiveItem: v = 0,
|
|
1005
|
+
slideType: m = "item"
|
|
1005
1006
|
}) {
|
|
1006
|
-
const [
|
|
1007
|
+
const [E, k] = Vt(!1), P = C(e), y = C(null), $ = C(null), L = C(0), b = C(0), x = C(!r), N = C(!1), O = C(0), h = C(0), [Y, F] = Et(
|
|
1007
1008
|
() => ({
|
|
1008
1009
|
value: 0,
|
|
1009
1010
|
onChange({ value: i }) {
|
|
1010
|
-
|
|
1011
|
+
$.current.style.transform = `translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`;
|
|
1011
1012
|
}
|
|
1012
1013
|
}),
|
|
1013
1014
|
[a]
|
|
1014
|
-
)
|
|
1015
|
-
M(() => {
|
|
1016
|
-
}, []);
|
|
1017
|
-
const Dt = r ? [
|
|
1015
|
+
), Pt = r ? [
|
|
1018
1016
|
...t.map((i) => ({
|
|
1019
1017
|
...i,
|
|
1020
1018
|
id: `prev-repeated-item-${i.id}`,
|
|
@@ -1026,121 +1024,121 @@ function Le({
|
|
|
1026
1024
|
id: `next-repeated-item-${i.id}`,
|
|
1027
1025
|
isClonedItem: !0
|
|
1028
1026
|
}))
|
|
1029
|
-
] : t, { useListenToCustomEvent:
|
|
1030
|
-
function
|
|
1031
|
-
const { totalGutterCssVar: i } =
|
|
1027
|
+
] : t, { useListenToCustomEvent: st, emitEvent: U } = De();
|
|
1028
|
+
function $t() {
|
|
1029
|
+
const { totalGutterCssVar: i } = it();
|
|
1032
1030
|
return i;
|
|
1033
1031
|
}
|
|
1034
|
-
function
|
|
1035
|
-
if (
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1032
|
+
function Ot() {
|
|
1033
|
+
if (y.current) {
|
|
1034
|
+
const f = window.getComputedStyle(
|
|
1035
|
+
y.current
|
|
1038
1036
|
).getPropertyValue(`--${n}-items-per-slide`).trim();
|
|
1039
|
-
return Number(
|
|
1037
|
+
return Number(f) || 1;
|
|
1040
1038
|
}
|
|
1041
1039
|
return 1;
|
|
1042
1040
|
}
|
|
1043
|
-
function
|
|
1044
|
-
|
|
1041
|
+
function H(i) {
|
|
1042
|
+
P.current && (N.current || M({
|
|
1045
1043
|
type: "next",
|
|
1046
1044
|
toIndex: i,
|
|
1047
1045
|
actionType: "click"
|
|
1048
1046
|
}));
|
|
1049
1047
|
}
|
|
1050
|
-
function
|
|
1051
|
-
|
|
1048
|
+
function X(i) {
|
|
1049
|
+
P.current && (x.current || M({
|
|
1052
1050
|
type: "prev",
|
|
1053
1051
|
toIndex: i,
|
|
1054
1052
|
actionType: "click"
|
|
1055
1053
|
}));
|
|
1056
1054
|
}
|
|
1057
|
-
function
|
|
1055
|
+
function M({
|
|
1058
1056
|
type: i,
|
|
1059
|
-
shouldAnimate:
|
|
1060
|
-
toIndex:
|
|
1061
|
-
actionType:
|
|
1057
|
+
shouldAnimate: f = !0,
|
|
1058
|
+
toIndex: _,
|
|
1059
|
+
actionType: T
|
|
1062
1060
|
}) {
|
|
1063
|
-
var
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
-
let g =
|
|
1067
|
-
if (i === "next" && (
|
|
1068
|
-
const K =
|
|
1069
|
-
r ?
|
|
1061
|
+
var at, ct;
|
|
1062
|
+
const A = !f;
|
|
1063
|
+
x.current = !1, N.current = !1;
|
|
1064
|
+
let g = Y.value.get(), I = 0;
|
|
1065
|
+
if (i === "next" && (h.current += 1), i === "prev" && (h.current === 0 ? h.current = t.length - 1 : h.current -= 1), _ !== void 0 && (h.current = _), i === "next") {
|
|
1066
|
+
const K = q(
|
|
1067
|
+
r ? b.current * (t.length * 2) : 0
|
|
1070
1068
|
);
|
|
1071
|
-
|
|
1069
|
+
I = -(h.current * b.current), r && h.current === t.length && (h.current = 0, g = g + b.current * t.length, I = 0), !r && (Math.abs(I) >= K || h.current === t.length - 1) && (N.current = !0, I = -K);
|
|
1072
1070
|
}
|
|
1073
|
-
i === "prev" && (
|
|
1071
|
+
i === "prev" && (I = -(h.current * b.current), h.current === t.length - 1 && (g = g - t.length * b.current), !r && I >= 0 && (x.current = !0, I = 0)), L.current = I, T === "resize" ? (I = -(h.current * b.current), U({
|
|
1074
1072
|
eventName: "onResize",
|
|
1075
|
-
sliceActionType:
|
|
1073
|
+
sliceActionType: T,
|
|
1076
1074
|
slideDirection: i,
|
|
1077
1075
|
currentItem: {
|
|
1078
|
-
index:
|
|
1079
|
-
id: ((
|
|
1080
|
-
startReached:
|
|
1081
|
-
endReached:
|
|
1076
|
+
index: h.current,
|
|
1077
|
+
id: ((at = t.at(h.current)) == null ? void 0 : at.id) ?? "",
|
|
1078
|
+
startReached: x.current,
|
|
1079
|
+
endReached: N.current
|
|
1082
1080
|
}
|
|
1083
1081
|
})) : U({
|
|
1084
1082
|
eventName: "onSlideStartChange",
|
|
1085
|
-
sliceActionType:
|
|
1083
|
+
sliceActionType: T,
|
|
1086
1084
|
slideDirection: i,
|
|
1087
1085
|
nextItem: {
|
|
1088
|
-
index:
|
|
1089
|
-
id: ((
|
|
1090
|
-
startReached:
|
|
1091
|
-
endReached:
|
|
1086
|
+
index: h.current,
|
|
1087
|
+
id: ((ct = t.at(h.current)) == null ? void 0 : ct.id) ?? "",
|
|
1088
|
+
startReached: x.current,
|
|
1089
|
+
endReached: N.current
|
|
1092
1090
|
}
|
|
1093
|
-
}),
|
|
1094
|
-
immediate:
|
|
1091
|
+
}), F.start({
|
|
1092
|
+
immediate: A,
|
|
1095
1093
|
from: {
|
|
1096
1094
|
value: g
|
|
1097
1095
|
},
|
|
1098
1096
|
to: {
|
|
1099
|
-
value:
|
|
1097
|
+
value: I
|
|
1100
1098
|
},
|
|
1101
1099
|
onRest({ finished: K }) {
|
|
1102
|
-
var
|
|
1100
|
+
var ut;
|
|
1103
1101
|
K && U({
|
|
1104
1102
|
eventName: "onSlideChangeComplete",
|
|
1105
|
-
sliceActionType:
|
|
1103
|
+
sliceActionType: T,
|
|
1106
1104
|
slideDirection: i,
|
|
1107
1105
|
currentItem: {
|
|
1108
|
-
index:
|
|
1109
|
-
id: ((
|
|
1110
|
-
startReached:
|
|
1111
|
-
endReached:
|
|
1106
|
+
index: h.current,
|
|
1107
|
+
id: ((ut = t.at(h.current)) == null ? void 0 : ut.id) ?? "",
|
|
1108
|
+
startReached: x.current,
|
|
1109
|
+
endReached: N.current
|
|
1112
1110
|
}
|
|
1113
1111
|
});
|
|
1114
1112
|
}
|
|
1115
1113
|
});
|
|
1116
1114
|
}
|
|
1117
|
-
function
|
|
1118
|
-
const i =
|
|
1119
|
-
let
|
|
1120
|
-
return
|
|
1121
|
-
}
|
|
1122
|
-
function
|
|
1123
|
-
const
|
|
1124
|
-
return
|
|
1125
|
-
}
|
|
1126
|
-
function
|
|
1127
|
-
let i = 0,
|
|
1128
|
-
if (
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
),
|
|
1132
|
-
|
|
1133
|
-
|
|
1115
|
+
function At() {
|
|
1116
|
+
const i = m === "item" ? $.current.children[0] : y.current;
|
|
1117
|
+
let f = 0;
|
|
1118
|
+
return f = i.getBoundingClientRect()[a === "x" ? "width" : "height"] + $t(), f;
|
|
1119
|
+
}
|
|
1120
|
+
function q(i) {
|
|
1121
|
+
const f = y.current;
|
|
1122
|
+
return f[a === "x" ? "scrollWidth" : "scrollHeight"] - f.getBoundingClientRect()[a === "x" ? "width" : "height"] - i;
|
|
1123
|
+
}
|
|
1124
|
+
function it() {
|
|
1125
|
+
let i = 0, f = 0;
|
|
1126
|
+
if (y.current) {
|
|
1127
|
+
const _ = window.getComputedStyle(
|
|
1128
|
+
y.current
|
|
1129
|
+
), T = _.getPropertyValue(`--${n}-start-end-gutter`).trim();
|
|
1130
|
+
T.includes("px") && (i = Number(
|
|
1131
|
+
T.replace("px", "")
|
|
1134
1132
|
));
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1133
|
+
const A = _.getPropertyValue(`--${n}-gutter`).trim();
|
|
1134
|
+
A.includes("px") && (f = Number(A.replace("px", "")));
|
|
1137
1135
|
}
|
|
1138
|
-
return { totalStartEndGutterCssVar: i, totalGutterCssVar:
|
|
1136
|
+
return { totalStartEndGutterCssVar: i, totalGutterCssVar: f };
|
|
1139
1137
|
}
|
|
1140
|
-
|
|
1141
|
-
function i(
|
|
1142
|
-
const g =
|
|
1143
|
-
switch (
|
|
1138
|
+
R(() => {
|
|
1139
|
+
function i(A) {
|
|
1140
|
+
const g = Ot();
|
|
1141
|
+
switch (A) {
|
|
1144
1142
|
case "start":
|
|
1145
1143
|
return 0;
|
|
1146
1144
|
case "middle-start":
|
|
@@ -1155,100 +1153,102 @@ function Le({
|
|
|
1155
1153
|
return 0;
|
|
1156
1154
|
}
|
|
1157
1155
|
}
|
|
1158
|
-
function
|
|
1159
|
-
|
|
1160
|
-
const { totalStartEndGutterCssVar:
|
|
1156
|
+
function f() {
|
|
1157
|
+
b.current = At(), console.log(b.current), O.current = b.current / 4;
|
|
1158
|
+
const { totalStartEndGutterCssVar: A } = it();
|
|
1161
1159
|
let g = 0;
|
|
1162
|
-
r && (g =
|
|
1160
|
+
r && (g = b.current * t.length), g -= b.current * i(c), g -= A / 2, y.current.style.setProperty(
|
|
1163
1161
|
`--${n}-offset-modifier`,
|
|
1164
1162
|
`${-g}px`
|
|
1165
1163
|
);
|
|
1166
1164
|
}
|
|
1167
|
-
function
|
|
1168
|
-
|
|
1165
|
+
function _() {
|
|
1166
|
+
y.current && (f(), k(!0));
|
|
1169
1167
|
}
|
|
1170
|
-
function
|
|
1171
|
-
|
|
1168
|
+
function T() {
|
|
1169
|
+
_(), M({
|
|
1172
1170
|
type: "resize",
|
|
1173
|
-
toIndex:
|
|
1171
|
+
toIndex: h.current,
|
|
1174
1172
|
shouldAnimate: !1,
|
|
1175
1173
|
actionType: "resize"
|
|
1176
1174
|
});
|
|
1177
1175
|
}
|
|
1178
1176
|
if (e)
|
|
1179
|
-
return
|
|
1180
|
-
window.removeEventListener("resize",
|
|
1177
|
+
return P.current = !0, _(), window.addEventListener("resize", T), () => {
|
|
1178
|
+
window.removeEventListener("resize", T);
|
|
1181
1179
|
};
|
|
1182
|
-
}, [e, r, n, a, s, c]),
|
|
1183
|
-
e && v !==
|
|
1180
|
+
}, [e, r, n, a, s, c]), R(() => {
|
|
1181
|
+
e && v !== h.current && M({
|
|
1184
1182
|
type: "next",
|
|
1185
1183
|
toIndex: v,
|
|
1186
1184
|
actionType: "resize",
|
|
1187
1185
|
shouldAnimate: !1
|
|
1188
1186
|
});
|
|
1189
|
-
}, [e, v])
|
|
1190
|
-
|
|
1187
|
+
}, [e, v]), R(() => {
|
|
1188
|
+
E && u && u();
|
|
1189
|
+
}, [E, u]);
|
|
1190
|
+
const ot = l, Nt = Ce(
|
|
1191
1191
|
(i) => {
|
|
1192
|
-
if (!
|
|
1192
|
+
if (!P.current)
|
|
1193
1193
|
return;
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1194
|
+
const f = i.dragging, _ = i.offset[a === "x" ? 0 : 1], T = i.movement[a === "x" ? 0 : 1], A = T > O.current, g = T < -O.current, I = i.velocity;
|
|
1195
|
+
f && (U({
|
|
1196
1196
|
...i,
|
|
1197
1197
|
eventName: "onDrag",
|
|
1198
1198
|
slideActionType: "drag"
|
|
1199
|
-
}),
|
|
1200
|
-
value:
|
|
1199
|
+
}), F.start({
|
|
1200
|
+
value: _,
|
|
1201
1201
|
immediate: !0,
|
|
1202
1202
|
config: {
|
|
1203
|
-
velocity:
|
|
1203
|
+
velocity: I
|
|
1204
1204
|
}
|
|
1205
|
-
}),
|
|
1205
|
+
}), d && (A || g) && i.cancel()), i.last && (A ? (M({
|
|
1206
1206
|
actionType: "drag",
|
|
1207
1207
|
type: "prev"
|
|
1208
|
-
}), i.cancel()) : g ? (
|
|
1208
|
+
}), i.cancel()) : g ? (M({
|
|
1209
1209
|
actionType: "drag",
|
|
1210
1210
|
type: "next"
|
|
1211
|
-
}), i.cancel()) : (
|
|
1212
|
-
value:
|
|
1211
|
+
}), i.cancel()) : (F.start({
|
|
1212
|
+
value: L.current,
|
|
1213
1213
|
config: {
|
|
1214
|
-
velocity:
|
|
1214
|
+
velocity: I
|
|
1215
1215
|
}
|
|
1216
1216
|
}), i.cancel()));
|
|
1217
1217
|
},
|
|
1218
1218
|
{
|
|
1219
|
-
enabled:
|
|
1219
|
+
enabled: ot,
|
|
1220
1220
|
axis: a,
|
|
1221
1221
|
rubberband: !r,
|
|
1222
1222
|
...r ? {} : {
|
|
1223
1223
|
bounds: () => ({
|
|
1224
1224
|
right: 0,
|
|
1225
|
-
left: -
|
|
1226
|
-
top: -
|
|
1225
|
+
left: -q(0),
|
|
1226
|
+
top: -q(0),
|
|
1227
1227
|
bottom: 0
|
|
1228
1228
|
})
|
|
1229
1229
|
},
|
|
1230
|
-
from: () => [
|
|
1230
|
+
from: () => [Y.value.get(), Y.value.get()]
|
|
1231
1231
|
}
|
|
1232
1232
|
);
|
|
1233
|
-
function
|
|
1234
|
-
var
|
|
1235
|
-
return typeof i == "number" ?
|
|
1233
|
+
function Lt(i) {
|
|
1234
|
+
var f, _;
|
|
1235
|
+
return typeof i == "number" ? h.current === i : ((f = t.find((T) => T.id === i)) == null ? void 0 : f.id) === ((_ = t[h.current]) == null ? void 0 : _.id);
|
|
1236
1236
|
}
|
|
1237
1237
|
return {
|
|
1238
|
-
carouselFragment: /* @__PURE__ */
|
|
1238
|
+
carouselFragment: /* @__PURE__ */ Mt(
|
|
1239
1239
|
"div",
|
|
1240
1240
|
{
|
|
1241
|
-
ref:
|
|
1241
|
+
ref: y,
|
|
1242
1242
|
className: "ReactSpringCarouselContainer",
|
|
1243
1243
|
"data-part": "Container",
|
|
1244
1244
|
"data-part-internal": `${n}-Container`,
|
|
1245
|
-
...
|
|
1245
|
+
...Nt(),
|
|
1246
1246
|
children: [
|
|
1247
|
-
/* @__PURE__ */
|
|
1247
|
+
/* @__PURE__ */ J(
|
|
1248
1248
|
"style",
|
|
1249
1249
|
{
|
|
1250
1250
|
dangerouslySetInnerHTML: {
|
|
1251
|
-
__html:
|
|
1251
|
+
__html: Pe(`
|
|
1252
1252
|
[data-part-internal="${n}-Container"] {
|
|
1253
1253
|
display: flex;
|
|
1254
1254
|
width: 100%;
|
|
@@ -1261,14 +1261,14 @@ function Le({
|
|
|
1261
1261
|
--${n}-scroll-y-value: ${a === "y" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
|
|
1262
1262
|
--${n}-gutter: 0px;
|
|
1263
1263
|
--${n}-start-end-gutter: 0px;
|
|
1264
|
-
touch-action: ${
|
|
1264
|
+
touch-action: ${ot ? a === "x" ? "pan-y" : "pan-x" : "auto"};
|
|
1265
1265
|
}
|
|
1266
1266
|
[data-part-internal="${n}-Track"] {
|
|
1267
1267
|
display: flex;
|
|
1268
1268
|
position: relative;
|
|
1269
1269
|
--initial-offset-modifier: calc(calc(-100% - var(--${n}-gutter) + calc(var(--${n}-start-end-gutter) / 2 / ${t.length} * var(--${n}-items-per-slide)) + var(--${n}-start-end-gutter)) * ${t.length} / var(--${n}-items-per-slide));
|
|
1270
|
-
left: ${r && a === "x" && !
|
|
1271
|
-
top: ${r && a === "y" && !
|
|
1270
|
+
left: ${r && a === "x" && !E ? "var(--initial-offset-modifier)" : "0px"};
|
|
1271
|
+
top: ${r && a === "y" && !E ? "var(--initial-offset-modifier)" : "0px"};
|
|
1272
1272
|
flex-direction: ${a === "x" ? "row" : "column"};
|
|
1273
1273
|
width: 100%;
|
|
1274
1274
|
height: 100%;
|
|
@@ -1279,7 +1279,7 @@ function Le({
|
|
|
1279
1279
|
display: flex;
|
|
1280
1280
|
flex: 1 0 calc(100% / var(--${n}-items-per-slide) - calc(var(--${n}-gutter) * (var(--${n}-items-per-slide) - 1)) / var(--${n}-items-per-slide) - calc(var(--${n}-start-end-gutter) / var(--${n}-items-per-slide)));
|
|
1281
1281
|
}
|
|
1282
|
-
${s && s.length > 0 ? s.sort((i,
|
|
1282
|
+
${s && s.length > 0 ? s.sort((i, f) => i.breakpoint - f.breakpoint).map(
|
|
1283
1283
|
(i) => `
|
|
1284
1284
|
@media ${i.media || `(min-width: ${i.breakpoint}px)`} {
|
|
1285
1285
|
[data-part-internal="${n}-Container"] {
|
|
@@ -1289,7 +1289,7 @@ function Le({
|
|
|
1289
1289
|
}
|
|
1290
1290
|
`
|
|
1291
1291
|
).join("") : ""}
|
|
1292
|
-
${o && o.length > 0 ? o.sort((i,
|
|
1292
|
+
${o && o.length > 0 ? o.sort((i, f) => i.breakpoint - f.breakpoint).map(
|
|
1293
1293
|
(i) => `
|
|
1294
1294
|
@media ${i.media || `(min-width: ${i.breakpoint}px)`} {
|
|
1295
1295
|
[data-part-internal="${n}-Container"] {
|
|
@@ -1302,17 +1302,17 @@ function Le({
|
|
|
1302
1302
|
}
|
|
1303
1303
|
}
|
|
1304
1304
|
),
|
|
1305
|
-
/* @__PURE__ */
|
|
1305
|
+
/* @__PURE__ */ J(
|
|
1306
1306
|
"div",
|
|
1307
1307
|
{
|
|
1308
|
-
ref:
|
|
1308
|
+
ref: $,
|
|
1309
1309
|
className: "ReactSpringCarouselTrack",
|
|
1310
1310
|
"data-part": "Track",
|
|
1311
1311
|
"data-part-internal": `${n}-Track`,
|
|
1312
1312
|
onScroll: () => {
|
|
1313
|
-
|
|
1313
|
+
x.current = !1, N.current = !1;
|
|
1314
1314
|
},
|
|
1315
|
-
children:
|
|
1315
|
+
children: Pt.map((i, f) => /* @__PURE__ */ J(
|
|
1316
1316
|
"div",
|
|
1317
1317
|
{
|
|
1318
1318
|
className: "ReactSpringCarouselItem",
|
|
@@ -1320,22 +1320,22 @@ function Le({
|
|
|
1320
1320
|
"data-part-internal": `${n}-Item`,
|
|
1321
1321
|
"data-id": i.id,
|
|
1322
1322
|
children: typeof i.renderItem == "function" ? i.renderItem({
|
|
1323
|
-
useListenToCustomEvent:
|
|
1324
|
-
index:
|
|
1323
|
+
useListenToCustomEvent: st,
|
|
1324
|
+
index: f,
|
|
1325
1325
|
isClonedItem: !!i.isClonedItem,
|
|
1326
|
-
isActiveItem:
|
|
1326
|
+
isActiveItem: Lt
|
|
1327
1327
|
}) : i.renderItem
|
|
1328
1328
|
},
|
|
1329
|
-
`${i.id}-${
|
|
1329
|
+
`${i.id}-${f}`
|
|
1330
1330
|
))
|
|
1331
1331
|
}
|
|
1332
1332
|
)
|
|
1333
1333
|
]
|
|
1334
1334
|
}
|
|
1335
1335
|
),
|
|
1336
|
-
useListenToCustomEvent:
|
|
1337
|
-
slideToNextItem: () =>
|
|
1338
|
-
slideToPrevItem: () =>
|
|
1336
|
+
useListenToCustomEvent: st,
|
|
1337
|
+
slideToNextItem: () => H(),
|
|
1338
|
+
slideToPrevItem: () => X(),
|
|
1339
1339
|
slideToItem: (i) => {
|
|
1340
1340
|
if (typeof i == "number") {
|
|
1341
1341
|
if (!t[i]) {
|
|
@@ -1344,35 +1344,35 @@ function Le({
|
|
|
1344
1344
|
);
|
|
1345
1345
|
return;
|
|
1346
1346
|
}
|
|
1347
|
-
i >
|
|
1347
|
+
i > h.current ? H(i) : X(i);
|
|
1348
1348
|
}
|
|
1349
1349
|
if (typeof i == "string") {
|
|
1350
|
-
const
|
|
1351
|
-
if (
|
|
1350
|
+
const f = t.findIndex((_) => _.id === i);
|
|
1351
|
+
if (f < 0) {
|
|
1352
1352
|
console.warn(
|
|
1353
1353
|
`The item you're trying to slide doesn't exist. id: ${i}`
|
|
1354
1354
|
);
|
|
1355
1355
|
return;
|
|
1356
1356
|
}
|
|
1357
|
-
|
|
1357
|
+
f > h.current ? H(f) : X(f);
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
1360
1360
|
};
|
|
1361
1361
|
}
|
|
1362
|
-
function
|
|
1362
|
+
function $e(e) {
|
|
1363
1363
|
let t = 0;
|
|
1364
1364
|
const r = getComputedStyle(e).getPropertyValue("gap");
|
|
1365
1365
|
return r.includes("px") && (t = Number(r.replace("px", ""))), t;
|
|
1366
1366
|
}
|
|
1367
|
-
function
|
|
1367
|
+
function wt(e) {
|
|
1368
1368
|
return e.scrollWidth - e.clientWidth;
|
|
1369
1369
|
}
|
|
1370
|
-
function
|
|
1371
|
-
const t = e.children[0], r =
|
|
1370
|
+
function et(e) {
|
|
1371
|
+
const t = e.children[0], r = $e(e);
|
|
1372
1372
|
return t.getBoundingClientRect().width + r;
|
|
1373
1373
|
}
|
|
1374
|
-
function
|
|
1375
|
-
const r =
|
|
1374
|
+
function Ve({ container: e, onReach: t }) {
|
|
1375
|
+
const r = C("start"), n = C(0), [, s] = Et(() => ({
|
|
1376
1376
|
x: 0
|
|
1377
1377
|
}));
|
|
1378
1378
|
function o(c) {
|
|
@@ -1392,30 +1392,30 @@ function Me({ container: e, onReach: t }) {
|
|
|
1392
1392
|
if (!e.current || c === "next" && r.current === "end" || c === "prev" && r.current === "start")
|
|
1393
1393
|
return;
|
|
1394
1394
|
let l = 0;
|
|
1395
|
-
if (c === "next" && (n.current += 1), c === "prev" && (n.current -= 1), l = n.current *
|
|
1396
|
-
const
|
|
1397
|
-
l >
|
|
1395
|
+
if (c === "next" && (n.current += 1), c === "prev" && (n.current -= 1), l = n.current * et(e.current), c === "next") {
|
|
1396
|
+
const d = wt(e.current);
|
|
1397
|
+
l > d && (r.current = "end", l = d, t && t("end"));
|
|
1398
1398
|
}
|
|
1399
1399
|
c === "prev" && l <= 0 && (r.current = "start", n.current = 0, l = 0, t && t("start")), o(l);
|
|
1400
1400
|
}
|
|
1401
|
-
return
|
|
1401
|
+
return R(() => {
|
|
1402
1402
|
function c() {
|
|
1403
|
-
var
|
|
1404
|
-
const
|
|
1405
|
-
index:
|
|
1406
|
-
start:
|
|
1407
|
-
end:
|
|
1408
|
-
})),
|
|
1409
|
-
(
|
|
1403
|
+
var L;
|
|
1404
|
+
const E = et(e.current), k = ((L = [...e.current.children].at(0)) == null ? void 0 : L.getBoundingClientRect().width) || 0, P = Array(e.current.childElementCount).fill(0).map((b, x) => ({
|
|
1405
|
+
index: x,
|
|
1406
|
+
start: E * x,
|
|
1407
|
+
end: E * (x + 1)
|
|
1408
|
+
})), y = e.current.scrollLeft + k, $ = P.find(
|
|
1409
|
+
(b) => y >= b.start && y < b.end
|
|
1410
1410
|
);
|
|
1411
|
-
n.current = (
|
|
1411
|
+
n.current = ($ == null ? void 0 : $.index) || 0;
|
|
1412
1412
|
}
|
|
1413
1413
|
function l() {
|
|
1414
1414
|
s.stop();
|
|
1415
1415
|
}
|
|
1416
|
-
function
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1416
|
+
function d(E) {
|
|
1417
|
+
const k = E.target;
|
|
1418
|
+
k.scrollLeft === 0 ? (n.current = 0, r.current = "start", t && t("start")) : k.scrollLeft >= wt(k) ? (r.current = "end", t && t("end")) : r.current !== "idle" && (r.current = "idle", t && t("idle"));
|
|
1419
1419
|
}
|
|
1420
1420
|
let u, v = 0;
|
|
1421
1421
|
function m() {
|
|
@@ -1426,13 +1426,13 @@ function Me({ container: e, onReach: t }) {
|
|
|
1426
1426
|
if (e.current)
|
|
1427
1427
|
return e.current.addEventListener("wheel", l, {
|
|
1428
1428
|
passive: !0
|
|
1429
|
-
}), e.current.addEventListener("scroll",
|
|
1430
|
-
e.current && (e.current.removeEventListener("scroll", m), e.current.removeEventListener("scroll",
|
|
1429
|
+
}), e.current.addEventListener("scroll", d), e.current.addEventListener("scroll", m), () => {
|
|
1430
|
+
e.current && (e.current.removeEventListener("scroll", m), e.current.removeEventListener("scroll", d), e.current.removeEventListener("wheel", l));
|
|
1431
1431
|
};
|
|
1432
|
-
}, [e, t]),
|
|
1432
|
+
}, [e, t]), R(() => {
|
|
1433
1433
|
if (e.current) {
|
|
1434
1434
|
const c = new ResizeObserver(() => {
|
|
1435
|
-
o(n.current *
|
|
1435
|
+
o(n.current * et(e.current));
|
|
1436
1436
|
});
|
|
1437
1437
|
return c.observe(e.current), () => {
|
|
1438
1438
|
c.disconnect();
|
|
@@ -1448,6 +1448,6 @@ function Me({ container: e, onReach: t }) {
|
|
|
1448
1448
|
};
|
|
1449
1449
|
}
|
|
1450
1450
|
export {
|
|
1451
|
-
|
|
1452
|
-
|
|
1451
|
+
Me as useSpringCarousel,
|
|
1452
|
+
Ve as useSpringScroll
|
|
1453
1453
|
};
|