react-spring-carousel 3.0.0-beta-2.1.5 → 3.0.0-beta-2.1.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.es.js +461 -411
- package/dist/index.umd.js +5 -5
- package/dist/useSpringCarousel.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as ne, jsx as
|
|
2
|
-
import { useSpringRef as ie, useSpring as
|
|
3
|
-
import
|
|
1
|
+
import { jsxs as ne, jsx as Z } from "react/jsx-runtime";
|
|
2
|
+
import { useSpringRef as ie, useSpring as Lt } from "@react-spring/web";
|
|
3
|
+
import pt, { useRef as I, useEffect as q, useCallback as Vt, useMemo as gt, useReducer as se } from "react";
|
|
4
4
|
function oe(r, t, e) {
|
|
5
5
|
return Math.max(t, Math.min(r, e));
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const D = {
|
|
8
8
|
toVector(r, t) {
|
|
9
9
|
return r === void 0 && (r = t), Array.isArray(r) ? r : [r, r];
|
|
10
10
|
},
|
|
@@ -21,15 +21,15 @@ const S = {
|
|
|
21
21
|
r[0] -= t[0], r[1] -= t[1];
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function Et(r, t, e) {
|
|
25
25
|
return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(r, e * 5) : r * t * e / (t + e * r);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return n === 0 ? oe(r, t, e) : r < t ? -
|
|
27
|
+
function St(r, t, e, n = 0.15) {
|
|
28
|
+
return n === 0 ? oe(r, t, e) : r < t ? -Et(t - r, e - t, n) + t : r > e ? +Et(r - e, e - t, n) + e : r;
|
|
29
29
|
}
|
|
30
30
|
function ae(r, [t, e], [n, i]) {
|
|
31
31
|
const [[a, o], [u, c]] = r;
|
|
32
|
-
return [
|
|
32
|
+
return [St(t, a, o, n), St(e, u, c, i)];
|
|
33
33
|
}
|
|
34
34
|
function ce(r, t) {
|
|
35
35
|
if (typeof r != "object" || r === null) return r;
|
|
@@ -45,7 +45,7 @@ function ue(r) {
|
|
|
45
45
|
var t = ce(r, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function O(r, t, e) {
|
|
49
49
|
return t = ue(t), t in r ? Object.defineProperty(r, t, {
|
|
50
50
|
value: e,
|
|
51
51
|
enumerable: !0,
|
|
@@ -53,7 +53,7 @@ function D(r, t, e) {
|
|
|
53
53
|
writable: !0
|
|
54
54
|
}) : r[t] = e, r;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function kt(r, t) {
|
|
57
57
|
var e = Object.keys(r);
|
|
58
58
|
if (Object.getOwnPropertySymbols) {
|
|
59
59
|
var n = Object.getOwnPropertySymbols(r);
|
|
@@ -63,18 +63,18 @@ function Dt(r, t) {
|
|
|
63
63
|
}
|
|
64
64
|
return e;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function b(r) {
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var e = arguments[t] != null ? arguments[t] : {};
|
|
69
|
-
t % 2 ?
|
|
70
|
-
|
|
71
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) :
|
|
69
|
+
t % 2 ? kt(Object(e), !0).forEach(function(n) {
|
|
70
|
+
O(r, n, e[n]);
|
|
71
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : kt(Object(e)).forEach(function(n) {
|
|
72
72
|
Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
return r;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const Bt = {
|
|
78
78
|
pointer: {
|
|
79
79
|
start: "down",
|
|
80
80
|
change: "move",
|
|
@@ -96,7 +96,7 @@ const jt = {
|
|
|
96
96
|
end: "end"
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
function
|
|
99
|
+
function Ct(r) {
|
|
100
100
|
return r ? r[0].toUpperCase() + r.slice(1) : "";
|
|
101
101
|
}
|
|
102
102
|
const le = ["enter", "leave"];
|
|
@@ -104,8 +104,8 @@ function fe(r = !1, t) {
|
|
|
104
104
|
return r && !le.includes(t);
|
|
105
105
|
}
|
|
106
106
|
function de(r, t = "", e = !1) {
|
|
107
|
-
const n =
|
|
108
|
-
return "on" +
|
|
107
|
+
const n = Bt[r], i = n && n[t] || t;
|
|
108
|
+
return "on" + Ct(r) + Ct(i) + (fe(e, i) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
110
|
const he = ["gotpointercapture", "lostpointercapture"];
|
|
111
111
|
function pe(r) {
|
|
@@ -120,14 +120,14 @@ function pe(r) {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
function ge(r, t = "") {
|
|
123
|
-
const e =
|
|
123
|
+
const e = Bt[r], n = e && e[t] || t;
|
|
124
124
|
return r + n;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function ot(r) {
|
|
127
127
|
return "touches" in r;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
return
|
|
129
|
+
function jt(r) {
|
|
130
|
+
return ot(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
132
|
function me(r) {
|
|
133
133
|
return Array.from(r.touches).filter((t) => {
|
|
@@ -139,16 +139,16 @@ function ve(r) {
|
|
|
139
139
|
return r.type === "touchend" || r.type === "touchcancel" ? r.changedTouches : r.targetTouches;
|
|
140
140
|
}
|
|
141
141
|
function Ut(r) {
|
|
142
|
-
return
|
|
142
|
+
return ot(r) ? ve(r)[0] : r;
|
|
143
143
|
}
|
|
144
144
|
function ye(r) {
|
|
145
145
|
return me(r).map((t) => t.identifier);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function mt(r) {
|
|
148
148
|
const t = Ut(r);
|
|
149
|
-
return
|
|
149
|
+
return ot(r) ? t.identifier : t.pointerId;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function Dt(r) {
|
|
152
152
|
const t = Ut(r);
|
|
153
153
|
return [t.clientX, t.clientY];
|
|
154
154
|
}
|
|
@@ -170,7 +170,7 @@ function be(r) {
|
|
|
170
170
|
}
|
|
171
171
|
return t;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function st(r, ...t) {
|
|
174
174
|
return typeof r == "function" ? r(...t) : r;
|
|
175
175
|
}
|
|
176
176
|
function _e() {
|
|
@@ -183,11 +183,11 @@ function we(...r) {
|
|
|
183
183
|
return t;
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function At(r, t) {
|
|
187
187
|
return Object.assign({}, t, r || {});
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
class
|
|
189
|
+
const xe = 32;
|
|
190
|
+
class Te {
|
|
191
191
|
constructor(t, e, n) {
|
|
192
192
|
this.ctrl = t, this.args = e, this.key = n, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
|
|
193
193
|
}
|
|
@@ -226,7 +226,7 @@ class xe {
|
|
|
226
226
|
}
|
|
227
227
|
start(t) {
|
|
228
228
|
const e = this.state, n = this.config;
|
|
229
|
-
e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = n.from ?
|
|
229
|
+
e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = n.from ? st(n.from, e) : e.offset, e.offset = e.lastOffset, e.startTime = e.timeStamp = t.timeStamp);
|
|
230
230
|
}
|
|
231
231
|
computeValues(t) {
|
|
232
232
|
const e = this.state;
|
|
@@ -245,37 +245,37 @@ class xe {
|
|
|
245
245
|
e.args = this.args;
|
|
246
246
|
let a = 0;
|
|
247
247
|
if (t && (e.event = t, n.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, i.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, i.locked = !!document.pointerLockElement, Object.assign(i, be(t)), i.down = i.pressed = i.buttons % 2 === 1 || i.touches > 0, a = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
|
|
248
|
-
const
|
|
249
|
-
|
|
248
|
+
const p = e._delta.map(Math.abs);
|
|
249
|
+
D.addTo(e._distance, p);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
|
-
const [o, u] = e._movement, [c,
|
|
252
|
+
const [o, u] = e._movement, [c, d] = n.threshold, {
|
|
253
253
|
_step: f,
|
|
254
|
-
values:
|
|
254
|
+
values: v
|
|
255
255
|
} = e;
|
|
256
|
-
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(o) >= c &&
|
|
257
|
-
const
|
|
256
|
+
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(o) >= c && v[0]), f[1] === !1 && (f[1] = Math.abs(u) >= d && v[1])) : (f[0] === !1 && (f[0] = Math.abs(o) >= c && Math.sign(o) * c), f[1] === !1 && (f[1] = Math.abs(u) >= d && Math.sign(u) * d)), e.intentional = f[0] !== !1 || f[1] !== !1, !e.intentional) return;
|
|
257
|
+
const h = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
|
-
const [
|
|
260
|
-
|
|
259
|
+
const [p, F] = v;
|
|
260
|
+
h[0] = f[0] !== !1 ? p - f[0] : 0, h[1] = f[1] !== !1 ? F - f[1] : 0;
|
|
261
261
|
} else
|
|
262
|
-
|
|
263
|
-
this.restrictToAxis && !e._blocked && this.restrictToAxis(
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const [
|
|
267
|
-
e.overflow = [
|
|
268
|
-
const
|
|
269
|
-
if (e.offset = ae(e._bounds, e.offset,
|
|
270
|
-
e.delta =
|
|
271
|
-
const
|
|
272
|
-
|
|
262
|
+
h[0] = f[0] !== !1 ? o - f[0] : 0, h[1] = f[1] !== !1 ? u - f[1] : 0;
|
|
263
|
+
this.restrictToAxis && !e._blocked && this.restrictToAxis(h);
|
|
264
|
+
const C = e.offset, E = e._active && !e._blocked || e.active;
|
|
265
|
+
E && (e.first = e._active && !e.active, e.last = !e._active && e.active, e.active = i[this.ingKey] = e._active, t && (e.first && ("bounds" in n && (e._bounds = st(n.bounds, e)), this.setup && this.setup()), e.movement = h, this.computeOffset()));
|
|
266
|
+
const [A, _] = e.offset, [[S, w], [k, x]] = e._bounds;
|
|
267
|
+
e.overflow = [A < S ? -1 : A > w ? 1 : 0, _ < k ? -1 : _ > x ? 1 : 0], e._movementBound[0] = e.overflow[0] ? e._movementBound[0] === !1 ? e._movement[0] : e._movementBound[0] : !1, e._movementBound[1] = e.overflow[1] ? e._movementBound[1] === !1 ? e._movement[1] : e._movementBound[1] : !1;
|
|
268
|
+
const U = e._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
+
if (e.offset = ae(e._bounds, e.offset, U), e.delta = D.sub(e.offset, C), this.computeMovement(), E && (!e.last || a > xe)) {
|
|
270
|
+
e.delta = D.sub(e.offset, C);
|
|
271
|
+
const p = e.delta.map(Math.abs);
|
|
272
|
+
D.addTo(e.distance, p), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && a > 0 && (e.velocity = [p[0] / a, p[1] / a], e.timeDelta = a);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
emit() {
|
|
276
276
|
const t = this.state, e = this.shared, n = this.config;
|
|
277
277
|
if (t._active || this.clean(), (t._blocked || !t.intentional) && !t._force && !n.triggerAllEvents) return;
|
|
278
|
-
const i = this.handler(
|
|
278
|
+
const i = this.handler(b(b(b({}, e), t), {}, {
|
|
279
279
|
[this.aliasKey]: t.values
|
|
280
280
|
}));
|
|
281
281
|
i !== void 0 && (t.memo = i);
|
|
@@ -291,9 +291,9 @@ function Ie([r, t], e) {
|
|
|
291
291
|
if (i > n && i > e)
|
|
292
292
|
return "y";
|
|
293
293
|
}
|
|
294
|
-
class Ee extends
|
|
294
|
+
class Ee extends Te {
|
|
295
295
|
constructor(...t) {
|
|
296
|
-
super(...t),
|
|
296
|
+
super(...t), O(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
298
298
|
reset() {
|
|
299
299
|
super.reset(), this.state.axis = void 0;
|
|
@@ -302,15 +302,15 @@ class Ee extends xe {
|
|
|
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 = D.add(this.state.lastOffset, this.state.movement);
|
|
306
306
|
}
|
|
307
307
|
computeMovement() {
|
|
308
|
-
this.state.movement =
|
|
308
|
+
this.state.movement = D.sub(this.state.offset, this.state.lastOffset);
|
|
309
309
|
}
|
|
310
310
|
axisIntent(t) {
|
|
311
311
|
const e = this.state, n = this.config;
|
|
312
312
|
if (!e.axis && t) {
|
|
313
|
-
const i = typeof n.axisThreshold == "object" ? n.axisThreshold[
|
|
313
|
+
const i = typeof n.axisThreshold == "object" ? n.axisThreshold[jt(t)] : n.axisThreshold;
|
|
314
314
|
e.axis = Ie(e._movement, i);
|
|
315
315
|
}
|
|
316
316
|
e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
|
|
@@ -327,12 +327,12 @@ class Ee extends xe {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const $t = (r) => r, Ot = 0.15, bt = {
|
|
331
331
|
enabled(r = !0) {
|
|
332
332
|
return r;
|
|
333
333
|
},
|
|
334
334
|
eventOptions(r, t, e) {
|
|
335
|
-
return
|
|
335
|
+
return b(b({}, e.shared.eventOptions), r);
|
|
336
336
|
},
|
|
337
337
|
preventDefault(r = !1) {
|
|
338
338
|
return r;
|
|
@@ -343,33 +343,33 @@ const Pt = (r) => r, Rt = 0.15, mt = {
|
|
|
343
343
|
rubberband(r = 0) {
|
|
344
344
|
switch (r) {
|
|
345
345
|
case !0:
|
|
346
|
-
return [
|
|
346
|
+
return [Ot, Ot];
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
350
|
-
return
|
|
350
|
+
return D.toVector(r);
|
|
351
351
|
}
|
|
352
352
|
},
|
|
353
353
|
from(r) {
|
|
354
354
|
if (typeof r == "function") return r;
|
|
355
|
-
if (r != null) return
|
|
355
|
+
if (r != null) return D.toVector(r);
|
|
356
356
|
},
|
|
357
357
|
transform(r, t, e) {
|
|
358
358
|
const n = r || e.shared.transform;
|
|
359
359
|
if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
|
|
360
|
-
const i = n ||
|
|
360
|
+
const i = n || $t;
|
|
361
361
|
return (a) => {
|
|
362
362
|
const o = i(a);
|
|
363
363
|
return (!isFinite(o[0]) || !isFinite(o[1])) && console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${o[0]},${[1]}]`), o;
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
return n ||
|
|
366
|
+
return n || $t;
|
|
367
367
|
},
|
|
368
368
|
threshold(r) {
|
|
369
|
-
return
|
|
369
|
+
return D.toVector(r, 0);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
372
|
+
process.env.NODE_ENV === "development" && Object.assign(bt, {
|
|
373
373
|
domTarget(r) {
|
|
374
374
|
if (r !== void 0)
|
|
375
375
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -386,7 +386,7 @@ process.env.NODE_ENV === "development" && Object.assign(mt, {
|
|
|
386
386
|
return NaN;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
const Se = 0,
|
|
389
|
+
const Se = 0, tt = b(b({}, bt), {}, {
|
|
390
390
|
axis(r, t, {
|
|
391
391
|
axis: e
|
|
392
392
|
}) {
|
|
@@ -397,7 +397,7 @@ const Se = 0, Q = v(v({}, mt), {}, {
|
|
|
397
397
|
},
|
|
398
398
|
bounds(r = {}) {
|
|
399
399
|
if (typeof r == "function")
|
|
400
|
-
return (a) =>
|
|
400
|
+
return (a) => tt.bounds(r(a));
|
|
401
401
|
if ("current" in r)
|
|
402
402
|
return () => r.current;
|
|
403
403
|
if (typeof HTMLElement == "function" && r instanceof HTMLElement)
|
|
@@ -410,7 +410,7 @@ const Se = 0, Q = v(v({}, mt), {}, {
|
|
|
410
410
|
} = r;
|
|
411
411
|
return [[t, e], [n, i]];
|
|
412
412
|
}
|
|
413
|
-
}),
|
|
413
|
+
}), Pt = {
|
|
414
414
|
ArrowRight: (r, t = 1) => [r * t, 0],
|
|
415
415
|
ArrowLeft: (r, t = 1) => [-1 * r * t, 0],
|
|
416
416
|
ArrowUp: (r, t = 1) => [0, -1 * r * t],
|
|
@@ -418,7 +418,7 @@ const Se = 0, Q = v(v({}, mt), {}, {
|
|
|
418
418
|
};
|
|
419
419
|
class ke extends Ee {
|
|
420
420
|
constructor(...t) {
|
|
421
|
-
super(...t),
|
|
421
|
+
super(...t), O(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
423
423
|
reset() {
|
|
424
424
|
super.reset();
|
|
@@ -434,7 +434,7 @@ class ke extends Ee {
|
|
|
434
434
|
top: e.top - n.top + t.offset[1],
|
|
435
435
|
bottom: e.bottom - n.bottom + t.offset[1]
|
|
436
436
|
};
|
|
437
|
-
t._bounds =
|
|
437
|
+
t._bounds = tt.bounds(i);
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
cancel() {
|
|
@@ -453,7 +453,7 @@ class ke extends Ee {
|
|
|
453
453
|
const e = this.config, n = this.state;
|
|
454
454
|
if (t.buttons != null && (Array.isArray(e.pointerButtons) ? !e.pointerButtons.includes(t.buttons) : e.pointerButtons !== -1 && e.pointerButtons !== t.buttons)) return;
|
|
455
455
|
const i = this.ctrl.setEventIds(t);
|
|
456
|
-
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(i && i.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId =
|
|
456
|
+
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(i && i.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = mt(t), n._pointerActive = !0, this.computeValues(Dt(t)), this.computeInitial(), e.preventScrollAxis && jt(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : e.delay > 0 ? (this.setupDelayTrigger(t), e.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
|
|
457
457
|
}
|
|
458
458
|
startPointerDrag(t) {
|
|
459
459
|
const e = this.state;
|
|
@@ -462,10 +462,10 @@ class ke extends Ee {
|
|
|
462
462
|
pointerMove(t) {
|
|
463
463
|
const e = this.state, n = this.config;
|
|
464
464
|
if (!e._pointerActive) return;
|
|
465
|
-
const i =
|
|
465
|
+
const i = mt(t);
|
|
466
466
|
if (e._pointerId !== void 0 && i !== e._pointerId) return;
|
|
467
|
-
const a =
|
|
468
|
-
if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta =
|
|
467
|
+
const a = Dt(t);
|
|
468
|
+
if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = D.sub(a, e._values), this.computeValues(a)), D.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
|
|
469
469
|
this.timeoutStore.remove("dragDelay"), e.active = !1, this.startPointerDrag(t);
|
|
470
470
|
return;
|
|
471
471
|
}
|
|
@@ -491,17 +491,17 @@ class ke extends Ee {
|
|
|
491
491
|
}
|
|
492
492
|
const e = this.state, n = this.config;
|
|
493
493
|
if (!e._active || !e._pointerActive) return;
|
|
494
|
-
const i =
|
|
494
|
+
const i = mt(t);
|
|
495
495
|
if (e._pointerId !== void 0 && i !== e._pointerId) return;
|
|
496
496
|
this.state._pointerActive = !1, this.setActive(), this.compute(t);
|
|
497
497
|
const [a, o] = e._distance;
|
|
498
498
|
if (e.tap = a <= n.tapsThreshold && o <= n.tapsThreshold, e.tap && n.filterTaps)
|
|
499
499
|
e._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [u, c] = e._delta, [
|
|
502
|
-
if (e.elapsedTime <
|
|
503
|
-
const
|
|
504
|
-
|
|
501
|
+
const [u, c] = e._delta, [d, f] = e._movement, [v, h] = n.swipe.velocity, [C, E] = n.swipe.distance, A = n.swipe.duration;
|
|
502
|
+
if (e.elapsedTime < A) {
|
|
503
|
+
const _ = Math.abs(u / e.timeDelta), S = Math.abs(c / e.timeDelta);
|
|
504
|
+
_ > v && Math.abs(d) > C && (e.swipe[0] = Math.sign(u)), S > h && Math.abs(f) > E && (e.swipe[1] = Math.sign(c));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -540,14 +540,14 @@ class ke extends Ee {
|
|
|
540
540
|
}, this.config.delay);
|
|
541
541
|
}
|
|
542
542
|
keyDown(t) {
|
|
543
|
-
const e =
|
|
543
|
+
const e = Pt[t.key];
|
|
544
544
|
if (e) {
|
|
545
545
|
const n = this.state, i = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
546
|
-
this.start(t), n._delta = e(this.config.keyboardDisplacement, i), n._keyboardActive = !0,
|
|
546
|
+
this.start(t), n._delta = e(this.config.keyboardDisplacement, i), n._keyboardActive = !0, D.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 Pt && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
|
|
551
551
|
}
|
|
552
552
|
bind(t) {
|
|
553
553
|
const e = this.config.device;
|
|
@@ -560,18 +560,18 @@ class ke extends Ee {
|
|
|
560
560
|
function Ce(r) {
|
|
561
561
|
"persist" in r && typeof r.persist == "function" && r.persist();
|
|
562
562
|
}
|
|
563
|
-
const
|
|
564
|
-
function
|
|
565
|
-
return
|
|
563
|
+
const et = typeof window < "u" && window.document && window.document.createElement;
|
|
564
|
+
function zt() {
|
|
565
|
+
return et && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
567
|
function De() {
|
|
568
|
-
return
|
|
568
|
+
return zt() || et && window.navigator.maxTouchPoints > 1;
|
|
569
569
|
}
|
|
570
570
|
function Ae() {
|
|
571
|
-
return
|
|
571
|
+
return et && "onpointerdown" in window;
|
|
572
572
|
}
|
|
573
573
|
function $e() {
|
|
574
|
-
return
|
|
574
|
+
return et && "exitPointerLock" in window.document;
|
|
575
575
|
}
|
|
576
576
|
function Oe() {
|
|
577
577
|
try {
|
|
@@ -580,18 +580,18 @@ function Oe() {
|
|
|
580
580
|
return !1;
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
-
const
|
|
584
|
-
isBrowser:
|
|
583
|
+
const M = {
|
|
584
|
+
isBrowser: et,
|
|
585
585
|
gesture: Oe(),
|
|
586
|
-
touch:
|
|
586
|
+
touch: zt(),
|
|
587
587
|
touchscreen: De(),
|
|
588
588
|
pointer: Ae(),
|
|
589
589
|
pointerLock: $e()
|
|
590
|
-
}, Pe = 250, Re = 180, Ne = 0.5, Me = 50, Le = 250, Ve = 10,
|
|
590
|
+
}, Pe = 250, Re = 180, Ne = 0.5, Me = 50, Le = 250, Ve = 10, Rt = {
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
},
|
|
594
|
+
}, Kt = b(b({}, tt), {}, {
|
|
595
595
|
device(r, t, {
|
|
596
596
|
pointer: {
|
|
597
597
|
touch: e = !1,
|
|
@@ -599,12 +599,12 @@ const $ = {
|
|
|
599
599
|
mouse: i = !1
|
|
600
600
|
} = {}
|
|
601
601
|
}) {
|
|
602
|
-
return this.pointerLock = n &&
|
|
602
|
+
return this.pointerLock = n && M.pointerLock, M.touch && e ? "touch" : this.pointerLock ? "mouse" : M.pointer && !i ? "pointer" : M.touch ? "touch" : "mouse";
|
|
603
603
|
},
|
|
604
604
|
preventScrollAxis(r, t, {
|
|
605
605
|
preventScroll: e
|
|
606
606
|
}) {
|
|
607
|
-
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? Pe : void 0, !(
|
|
607
|
+
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? Pe : void 0, !(!M.touchscreen || e === !1))
|
|
608
608
|
return r || (e !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
610
|
pointerCapture(r, t, {
|
|
@@ -621,7 +621,7 @@ const $ = {
|
|
|
621
621
|
tapsThreshold: n = 3,
|
|
622
622
|
axis: i = void 0
|
|
623
623
|
}) {
|
|
624
|
-
const a =
|
|
624
|
+
const a = D.toVector(r, e ? n : i ? 1 : 0);
|
|
625
625
|
return this.filterTaps = e, this.tapsThreshold = n, a;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
@@ -630,8 +630,8 @@ const $ = {
|
|
|
630
630
|
duration: e = Le
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
|
-
velocity: this.transform(
|
|
634
|
-
distance: this.transform(
|
|
633
|
+
velocity: this.transform(D.toVector(r)),
|
|
634
|
+
distance: this.transform(D.toVector(t)),
|
|
635
635
|
duration: e
|
|
636
636
|
};
|
|
637
637
|
},
|
|
@@ -646,13 +646,13 @@ const $ = {
|
|
|
646
646
|
}
|
|
647
647
|
},
|
|
648
648
|
axisThreshold(r) {
|
|
649
|
-
return r ?
|
|
649
|
+
return r ? b(b({}, Rt), r) : Rt;
|
|
650
650
|
},
|
|
651
651
|
keyboardDisplacement(r = Ve) {
|
|
652
652
|
return r;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
655
|
+
process.env.NODE_ENV === "development" && Object.assign(Kt, {
|
|
656
656
|
useTouch(r) {
|
|
657
657
|
if (r !== 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(Ft, {
|
|
|
679
679
|
return NaN;
|
|
680
680
|
}
|
|
681
681
|
});
|
|
682
|
-
|
|
682
|
+
b(b({}, bt), {}, {
|
|
683
683
|
device(r, t, {
|
|
684
684
|
shared: e,
|
|
685
685
|
pointer: {
|
|
686
686
|
touch: n = !1
|
|
687
687
|
} = {}
|
|
688
688
|
}) {
|
|
689
|
-
if (e.target &&
|
|
690
|
-
if (
|
|
691
|
-
if (
|
|
692
|
-
if (
|
|
693
|
-
if (
|
|
689
|
+
if (e.target && !M.touch && M.gesture) return "gesture";
|
|
690
|
+
if (M.touch && n) return "touch";
|
|
691
|
+
if (M.touchscreen) {
|
|
692
|
+
if (M.pointer) return "pointer";
|
|
693
|
+
if (M.touch) return "touch";
|
|
694
694
|
}
|
|
695
695
|
},
|
|
696
696
|
bounds(r, t, {
|
|
@@ -698,13 +698,13 @@ v(v({}, mt), {}, {
|
|
|
698
698
|
angleBounds: n = {}
|
|
699
699
|
}) {
|
|
700
700
|
const i = (o) => {
|
|
701
|
-
const u =
|
|
701
|
+
const u = At(st(e, o), {
|
|
702
702
|
min: -1 / 0,
|
|
703
703
|
max: 1 / 0
|
|
704
704
|
});
|
|
705
705
|
return [u.min, u.max];
|
|
706
706
|
}, a = (o) => {
|
|
707
|
-
const u =
|
|
707
|
+
const u = At(st(n, o), {
|
|
708
708
|
min: -1 / 0,
|
|
709
709
|
max: 1 / 0
|
|
710
710
|
});
|
|
@@ -713,7 +713,7 @@ v(v({}, mt), {}, {
|
|
|
713
713
|
return typeof e != "function" && typeof n != "function" ? [i(), a()] : (o) => [i(o), a(o)];
|
|
714
714
|
},
|
|
715
715
|
threshold(r, t, e) {
|
|
716
|
-
return this.lockDirection = e.axis === "lock",
|
|
716
|
+
return this.lockDirection = e.axis === "lock", D.toVector(r, this.lockDirection ? [0.1, 3] : 0);
|
|
717
717
|
},
|
|
718
718
|
modifierKey(r) {
|
|
719
719
|
return r === void 0 ? "ctrlKey" : r;
|
|
@@ -722,31 +722,31 @@ v(v({}, mt), {}, {
|
|
|
722
722
|
return r;
|
|
723
723
|
}
|
|
724
724
|
});
|
|
725
|
-
|
|
725
|
+
b(b({}, tt), {}, {
|
|
726
726
|
mouseOnly: (r = !0) => r
|
|
727
727
|
});
|
|
728
|
-
|
|
728
|
+
b(b({}, tt), {}, {
|
|
729
729
|
mouseOnly: (r = !0) => r
|
|
730
730
|
});
|
|
731
|
-
const
|
|
731
|
+
const Ft = /* @__PURE__ */ new Map(), yt = /* @__PURE__ */ new Map();
|
|
732
732
|
function Be(r) {
|
|
733
|
-
|
|
733
|
+
Ft.set(r.key, r.engine), yt.set(r.key, r.resolver);
|
|
734
734
|
}
|
|
735
735
|
const je = {
|
|
736
736
|
key: "drag",
|
|
737
737
|
engine: ke,
|
|
738
|
-
resolver:
|
|
738
|
+
resolver: Kt
|
|
739
739
|
};
|
|
740
|
-
function
|
|
740
|
+
function Ue(r, t) {
|
|
741
741
|
if (r == null) return {};
|
|
742
742
|
var e = {}, n = Object.keys(r), i, a;
|
|
743
743
|
for (a = 0; a < n.length; a++)
|
|
744
744
|
i = n[a], !(t.indexOf(i) >= 0) && (e[i] = r[i]);
|
|
745
745
|
return e;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function ze(r, t) {
|
|
748
748
|
if (r == null) return {};
|
|
749
|
-
var e =
|
|
749
|
+
var e = Ue(r, t), n, i;
|
|
750
750
|
if (Object.getOwnPropertySymbols) {
|
|
751
751
|
var a = Object.getOwnPropertySymbols(r);
|
|
752
752
|
for (i = 0; i < a.length; i++)
|
|
@@ -762,7 +762,7 @@ const Ke = {
|
|
|
762
762
|
enabled(r = !0) {
|
|
763
763
|
return r;
|
|
764
764
|
},
|
|
765
|
-
window(r =
|
|
765
|
+
window(r = M.isBrowser ? window : void 0) {
|
|
766
766
|
return r;
|
|
767
767
|
},
|
|
768
768
|
eventOptions({
|
|
@@ -778,7 +778,7 @@ const Ke = {
|
|
|
778
778
|
return r;
|
|
779
779
|
}
|
|
780
780
|
}, Fe = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
781
|
-
function
|
|
781
|
+
function it(r = {}, t) {
|
|
782
782
|
const e = {};
|
|
783
783
|
for (const [n, i] of Object.entries(t))
|
|
784
784
|
switch (typeof i) {
|
|
@@ -790,7 +790,7 @@ function rt(r = {}, t) {
|
|
|
790
790
|
e[n] = i.call(e, r[n], n, r);
|
|
791
791
|
break;
|
|
792
792
|
case "object":
|
|
793
|
-
e[n] =
|
|
793
|
+
e[n] = it(r[n], i);
|
|
794
794
|
break;
|
|
795
795
|
case "boolean":
|
|
796
796
|
i && (e[n] = r[n]);
|
|
@@ -805,25 +805,25 @@ function Ge(r, t, e = {}) {
|
|
|
805
805
|
window: o,
|
|
806
806
|
enabled: u,
|
|
807
807
|
transform: c
|
|
808
|
-
} = n,
|
|
809
|
-
if (e.shared =
|
|
808
|
+
} = n, d = ze(n, Fe);
|
|
809
|
+
if (e.shared = it({
|
|
810
810
|
target: i,
|
|
811
811
|
eventOptions: a,
|
|
812
812
|
window: o,
|
|
813
813
|
enabled: u,
|
|
814
814
|
transform: c
|
|
815
815
|
}, Ke), t) {
|
|
816
|
-
const f =
|
|
817
|
-
e[t] =
|
|
816
|
+
const f = yt.get(t);
|
|
817
|
+
e[t] = it(b({
|
|
818
818
|
shared: e.shared
|
|
819
|
-
},
|
|
819
|
+
}, d), f);
|
|
820
820
|
} else
|
|
821
|
-
for (const f in
|
|
822
|
-
const
|
|
823
|
-
if (
|
|
824
|
-
e[f] =
|
|
821
|
+
for (const f in d) {
|
|
822
|
+
const v = yt.get(f);
|
|
823
|
+
if (v)
|
|
824
|
+
e[f] = it(b({
|
|
825
825
|
shared: e.shared
|
|
826
|
-
},
|
|
826
|
+
}, d[f]), v);
|
|
827
827
|
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(f)) {
|
|
828
828
|
if (f === "domTarget")
|
|
829
829
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -832,15 +832,15 @@ function Ge(r, t, e = {}) {
|
|
|
832
832
|
}
|
|
833
833
|
return e;
|
|
834
834
|
}
|
|
835
|
-
class
|
|
835
|
+
class Gt {
|
|
836
836
|
constructor(t, e) {
|
|
837
|
-
|
|
837
|
+
O(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
|
|
838
838
|
}
|
|
839
839
|
add(t, e, n, i, a) {
|
|
840
|
-
const o = this._listeners, u = ge(e, n), c = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {},
|
|
841
|
-
t.addEventListener(u, i,
|
|
840
|
+
const o = this._listeners, u = ge(e, n), c = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, d = b(b({}, c), a);
|
|
841
|
+
t.addEventListener(u, i, d);
|
|
842
842
|
const f = () => {
|
|
843
|
-
t.removeEventListener(u, i,
|
|
843
|
+
t.removeEventListener(u, i, d), o.delete(f);
|
|
844
844
|
};
|
|
845
845
|
return o.add(f), f;
|
|
846
846
|
}
|
|
@@ -850,7 +850,7 @@ class Wt {
|
|
|
850
850
|
}
|
|
851
851
|
class We {
|
|
852
852
|
constructor() {
|
|
853
|
-
|
|
853
|
+
O(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
855
855
|
add(t, e, n = 140, ...i) {
|
|
856
856
|
this.remove(t), this._timeouts.set(t, window.setTimeout(e, n, ...i));
|
|
@@ -865,7 +865,7 @@ class We {
|
|
|
865
865
|
}
|
|
866
866
|
class Ye {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
|
|
868
|
+
O(this, "gestures", /* @__PURE__ */ new Set()), O(this, "_targetEventStore", new Gt(this)), O(this, "gestureEventStores", {}), O(this, "gestureTimeoutStores", {}), O(this, "handlers", {}), O(this, "config", {}), O(this, "pointerIds", /* @__PURE__ */ new Set()), O(this, "touchIds", /* @__PURE__ */ new Set()), O(this, "state", {
|
|
869
869
|
shared: {
|
|
870
870
|
shiftKey: !1,
|
|
871
871
|
metaKey: !1,
|
|
@@ -875,7 +875,7 @@ class Ye {
|
|
|
875
875
|
}), He(this, t);
|
|
876
876
|
}
|
|
877
877
|
setEventIds(t) {
|
|
878
|
-
if (
|
|
878
|
+
if (ot(t))
|
|
879
879
|
return this.touchIds = new Set(ye(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;
|
|
@@ -900,15 +900,15 @@ class Ye {
|
|
|
900
900
|
if (!(e.target && (i = e.target(), !i))) {
|
|
901
901
|
if (e.enabled) {
|
|
902
902
|
for (const o of this.gestures) {
|
|
903
|
-
const u = this.config[o], c =
|
|
903
|
+
const u = this.config[o], c = Nt(n, u.eventOptions, !!i);
|
|
904
904
|
if (u.enabled) {
|
|
905
|
-
const
|
|
906
|
-
new
|
|
905
|
+
const d = Ft.get(o);
|
|
906
|
+
new d(this, t, o).bind(c);
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
const a =
|
|
909
|
+
const a = Nt(n, e.eventOptions, !!i);
|
|
910
910
|
for (const o in this.nativeHandlers)
|
|
911
|
-
a(o, "", (u) => this.nativeHandlers[o](
|
|
911
|
+
a(o, "", (u) => this.nativeHandlers[o](b(b({}, this.state.shared), {}, {
|
|
912
912
|
event: u,
|
|
913
913
|
args: t
|
|
914
914
|
})), void 0, !0);
|
|
@@ -931,20 +931,20 @@ class Ye {
|
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
933
|
function X(r, t) {
|
|
934
|
-
r.gestures.add(t), r.gestureEventStores[t] = new
|
|
934
|
+
r.gestures.add(t), r.gestureEventStores[t] = new Gt(r, t), r.gestureTimeoutStores[t] = new We();
|
|
935
935
|
}
|
|
936
936
|
function He(r, t) {
|
|
937
937
|
t.drag && X(r, "drag"), t.wheel && X(r, "wheel"), t.scroll && X(r, "scroll"), t.move && X(r, "move"), t.pinch && X(r, "pinch"), t.hover && X(r, "hover");
|
|
938
938
|
}
|
|
939
|
-
const
|
|
940
|
-
var c,
|
|
941
|
-
const f = (c = o.capture) !== null && c !== void 0 ? c : t.capture,
|
|
942
|
-
let
|
|
943
|
-
e &&
|
|
939
|
+
const Nt = (r, t, e) => (n, i, a, o = {}, u = !1) => {
|
|
940
|
+
var c, d;
|
|
941
|
+
const f = (c = o.capture) !== null && c !== void 0 ? c : t.capture, v = (d = o.passive) !== null && d !== void 0 ? d : t.passive;
|
|
942
|
+
let h = u ? n : de(n, i, f);
|
|
943
|
+
e && v && (h += "Passive"), r[h] = r[h] || [], r[h].push(a);
|
|
944
944
|
};
|
|
945
945
|
function Xe(r, t = {}, e, n) {
|
|
946
|
-
const i =
|
|
947
|
-
if (i.applyHandlers(r, n), i.applyConfig(t, e),
|
|
946
|
+
const i = pt.useMemo(() => new Ye(r), []);
|
|
947
|
+
if (i.applyHandlers(r, n), i.applyConfig(t, e), pt.useEffect(i.effect.bind(i)), pt.useEffect(() => i.clean.bind(i), []), t.target === void 0)
|
|
948
948
|
return i.bind.bind(i);
|
|
949
949
|
}
|
|
950
950
|
function qe(r, t) {
|
|
@@ -962,30 +962,30 @@ function Je(r) {
|
|
|
962
962
|
scrollAmount: o,
|
|
963
963
|
totalAvailable: u
|
|
964
964
|
} = r;
|
|
965
|
-
let c = r.currentActive,
|
|
965
|
+
let c = r.currentActive, d = r.fromValueRaw, f = !1, v = !1;
|
|
966
966
|
t === "next" && (c += 1), t === "prev" && (c = c === 0 ? i - 1 : c - 1), n !== void 0 && (c = n);
|
|
967
|
-
let
|
|
968
|
-
t === "next" && (
|
|
969
|
-
const
|
|
967
|
+
let h = 0;
|
|
968
|
+
t === "next" && (h = -(c * o), a && c === i && (c = 0, d = d + o * i, h = 0), !a && (Math.abs(h) >= u || c === i - 1) && (v = !0, h = -u)), t === "prev" && (h = -(c * o), c === i - 1 && (d = d - i * o), !a && h >= 0 && (f = !0, h = 0)), e === "resize" && (h = -(c * o), a || (c === 0 && (f = !0), (c === i - 1 || Math.abs(h) >= u) && (v = !0, Math.abs(h) >= u && u > 0 && (h = -u))));
|
|
969
|
+
const C = a ? c % i : c, E = a ? i + c % i : c;
|
|
970
970
|
return {
|
|
971
971
|
newActive: c,
|
|
972
|
-
fromValue:
|
|
973
|
-
toValue:
|
|
972
|
+
fromValue: d,
|
|
973
|
+
toValue: h,
|
|
974
974
|
startReached: f,
|
|
975
|
-
endReached:
|
|
976
|
-
logicalIndex:
|
|
977
|
-
realTrackIndex:
|
|
975
|
+
endReached: v,
|
|
976
|
+
logicalIndex: C,
|
|
977
|
+
realTrackIndex: E
|
|
978
978
|
};
|
|
979
979
|
}
|
|
980
|
-
function
|
|
980
|
+
function Q(r, t, e) {
|
|
981
981
|
return t === "x" ? `translate3d(calc(${r}px + var(--${e}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${r}px + var(--${e}-offset-modifier)), 0px)`;
|
|
982
982
|
}
|
|
983
983
|
function Qe() {
|
|
984
|
-
const r =
|
|
984
|
+
const r = I(
|
|
985
985
|
null
|
|
986
986
|
);
|
|
987
987
|
r.current === null && (r.current = /* @__PURE__ */ new Set());
|
|
988
|
-
const t =
|
|
988
|
+
const t = I(null);
|
|
989
989
|
return t.current === null && (t.current = {
|
|
990
990
|
useListenToCustomEvent(e) {
|
|
991
991
|
q(() => {
|
|
@@ -1001,7 +1001,7 @@ function Qe() {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
}), t.current;
|
|
1003
1003
|
}
|
|
1004
|
-
function
|
|
1004
|
+
function sr({
|
|
1005
1005
|
init: r = !0,
|
|
1006
1006
|
items: t,
|
|
1007
1007
|
withLoop: e = !1,
|
|
@@ -1011,17 +1011,17 @@ function ir({
|
|
|
1011
1011
|
carouselAxis: o = "x",
|
|
1012
1012
|
startingPosition: u = "start",
|
|
1013
1013
|
enableGestures: c = !0,
|
|
1014
|
-
slideWhenDragThresholdIsReached:
|
|
1014
|
+
slideWhenDragThresholdIsReached: d = !0,
|
|
1015
1015
|
slideType: f = "item",
|
|
1016
|
-
initialActiveItem:
|
|
1017
|
-
renderWindow:
|
|
1018
|
-
renderPlaceholder:
|
|
1016
|
+
initialActiveItem: v = 0,
|
|
1017
|
+
renderWindow: h,
|
|
1018
|
+
renderPlaceholder: C
|
|
1019
1019
|
}) {
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1024
|
-
const
|
|
1020
|
+
const E = I(r), A = I(null), _ = I(null), S = I(0), w = I(0), k = I(!e), x = I(!1), U = I(0), p = I(0), F = I(0), R = I(t);
|
|
1021
|
+
R.current = t;
|
|
1022
|
+
const J = I(e);
|
|
1023
|
+
J.current = e;
|
|
1024
|
+
const rt = I(!1), B = I(null), L = I(null), V = I(null), z = I(null), G = I({ width: 0, height: 0 });
|
|
1025
1025
|
function _t(s) {
|
|
1026
1026
|
if (s === void 0) return 0;
|
|
1027
1027
|
if (typeof s == "number")
|
|
@@ -1031,41 +1031,41 @@ function ir({
|
|
|
1031
1031
|
const l = t.findIndex((g) => g.id === s);
|
|
1032
1032
|
return l < 0 ? (console.warn(`initialActiveItem: item with id "${s}" doesn't exist.`), 0) : l;
|
|
1033
1033
|
}
|
|
1034
|
-
const
|
|
1034
|
+
const nt = ie(), at = Lt({
|
|
1035
1035
|
value: 0,
|
|
1036
|
-
ref:
|
|
1036
|
+
ref: nt,
|
|
1037
1037
|
onChange({ value: s }) {
|
|
1038
|
-
|
|
1038
|
+
_.current.style.transform = Q(
|
|
1039
1039
|
s.value,
|
|
1040
1040
|
o,
|
|
1041
1041
|
n
|
|
1042
1042
|
);
|
|
1043
1043
|
}
|
|
1044
|
-
}),
|
|
1045
|
-
function
|
|
1044
|
+
}), Wt = e ? t.length * 3 : t.length, { useListenToCustomEvent: wt, emitEvent: W } = Qe();
|
|
1045
|
+
function xt(s) {
|
|
1046
1046
|
if (!s || s.length === 0) return null;
|
|
1047
1047
|
let l = null, g = -1 / 0;
|
|
1048
|
-
for (const
|
|
1049
|
-
(
|
|
1048
|
+
for (const y of s)
|
|
1049
|
+
(y.media ? window.matchMedia(y.media).matches : window.innerWidth >= y.breakpoint) && y.breakpoint >= g && (l = y, g = y.breakpoint);
|
|
1050
1050
|
return l;
|
|
1051
1051
|
}
|
|
1052
|
-
function
|
|
1052
|
+
function Tt() {
|
|
1053
1053
|
const { totalGutterCssVar: s } = It();
|
|
1054
1054
|
return s;
|
|
1055
1055
|
}
|
|
1056
|
-
function
|
|
1057
|
-
const s =
|
|
1056
|
+
function Yt() {
|
|
1057
|
+
const s = xt(a);
|
|
1058
1058
|
return (s == null ? void 0 : s.itemsPerSlide) || 1;
|
|
1059
1059
|
}
|
|
1060
|
-
function
|
|
1061
|
-
|
|
1060
|
+
function ct(s) {
|
|
1061
|
+
E.current && (x.current || Y({
|
|
1062
1062
|
type: "next",
|
|
1063
1063
|
toIndex: s,
|
|
1064
1064
|
actionType: "click"
|
|
1065
1065
|
}));
|
|
1066
1066
|
}
|
|
1067
|
-
function
|
|
1068
|
-
|
|
1067
|
+
function ut(s) {
|
|
1068
|
+
E.current && (k.current || Y({
|
|
1069
1069
|
type: "prev",
|
|
1070
1070
|
toIndex: s,
|
|
1071
1071
|
actionType: "click"
|
|
@@ -1075,252 +1075,252 @@ function ir({
|
|
|
1075
1075
|
type: s,
|
|
1076
1076
|
shouldAnimate: l = !0,
|
|
1077
1077
|
toIndex: g,
|
|
1078
|
-
actionType:
|
|
1078
|
+
actionType: y
|
|
1079
1079
|
}) {
|
|
1080
|
-
var
|
|
1081
|
-
const
|
|
1082
|
-
|
|
1080
|
+
var K, j;
|
|
1081
|
+
const $ = !l;
|
|
1082
|
+
k.current = !1, x.current = !1;
|
|
1083
1083
|
const m = Je({
|
|
1084
1084
|
type: s,
|
|
1085
|
-
actionType:
|
|
1085
|
+
actionType: y,
|
|
1086
1086
|
toIndex: g,
|
|
1087
|
-
currentActive:
|
|
1087
|
+
currentActive: p.current,
|
|
1088
1088
|
itemsLength: t.length,
|
|
1089
1089
|
withLoop: e,
|
|
1090
|
-
scrollAmount:
|
|
1091
|
-
totalAvailable: s === "next" ||
|
|
1092
|
-
e ?
|
|
1090
|
+
scrollAmount: w.current,
|
|
1091
|
+
totalAvailable: s === "next" || y === "resize" ? lt(
|
|
1092
|
+
e ? w.current * (t.length * 2) : 0
|
|
1093
1093
|
) : 0,
|
|
1094
|
-
fromValueRaw:
|
|
1095
|
-
})
|
|
1096
|
-
|
|
1094
|
+
fromValueRaw: at.value.get()
|
|
1095
|
+
});
|
|
1096
|
+
F.current = $ ? m.newActive : p.current, p.current = m.newActive, k.current = m.startReached, x.current = m.endReached, S.current = m.toValue, W(y === "resize" ? {
|
|
1097
1097
|
eventName: "onResize",
|
|
1098
|
-
sliceActionType:
|
|
1098
|
+
sliceActionType: y,
|
|
1099
1099
|
slideDirection: s,
|
|
1100
1100
|
currentItem: {
|
|
1101
|
-
id: ((
|
|
1101
|
+
id: ((K = R.current.at(m.logicalIndex)) == null ? void 0 : K.id) ?? "",
|
|
1102
1102
|
index: m.logicalIndex,
|
|
1103
1103
|
trackIndex: m.realTrackIndex,
|
|
1104
|
-
startReached:
|
|
1105
|
-
endReached:
|
|
1104
|
+
startReached: k.current,
|
|
1105
|
+
endReached: x.current
|
|
1106
1106
|
}
|
|
1107
1107
|
} : {
|
|
1108
1108
|
eventName: "onSlideStartChange",
|
|
1109
|
-
sliceActionType:
|
|
1109
|
+
sliceActionType: y,
|
|
1110
1110
|
slideDirection: s,
|
|
1111
1111
|
nextItem: {
|
|
1112
1112
|
index: m.logicalIndex,
|
|
1113
|
-
id: ((
|
|
1113
|
+
id: ((j = R.current.at(m.logicalIndex)) == null ? void 0 : j.id) ?? "",
|
|
1114
1114
|
trackIndex: m.realTrackIndex,
|
|
1115
|
-
startReached:
|
|
1116
|
-
endReached:
|
|
1115
|
+
startReached: k.current,
|
|
1116
|
+
endReached: x.current
|
|
1117
1117
|
}
|
|
1118
|
-
}),
|
|
1118
|
+
}), $ && _.current && (_.current.style.transform = Q(
|
|
1119
1119
|
m.toValue,
|
|
1120
1120
|
o,
|
|
1121
1121
|
n
|
|
1122
|
-
)),
|
|
1123
|
-
immediate:
|
|
1122
|
+
)), nt.start({
|
|
1123
|
+
immediate: $,
|
|
1124
1124
|
from: { value: m.fromValue },
|
|
1125
1125
|
to: { value: m.toValue },
|
|
1126
|
-
onChange({ value:
|
|
1127
|
-
|
|
1128
|
-
|
|
1126
|
+
onChange({ value: H }) {
|
|
1127
|
+
_.current.style.transform = Q(
|
|
1128
|
+
H.value,
|
|
1129
1129
|
o,
|
|
1130
1130
|
n
|
|
1131
1131
|
);
|
|
1132
1132
|
},
|
|
1133
|
-
onRest({ finished:
|
|
1134
|
-
var
|
|
1135
|
-
if (
|
|
1136
|
-
const
|
|
1137
|
-
W({
|
|
1133
|
+
onRest({ finished: H }) {
|
|
1134
|
+
var P;
|
|
1135
|
+
if (H) {
|
|
1136
|
+
const T = R.current, N = T.length, dt = e ? p.current % N : p.current, ht = e ? (dt % N + N) % N : dt, re = e ? N + ht : p.current;
|
|
1137
|
+
F.current = p.current, W({
|
|
1138
1138
|
eventName: "onSlideChangeComplete",
|
|
1139
|
-
sliceActionType:
|
|
1139
|
+
sliceActionType: y,
|
|
1140
1140
|
slideDirection: s,
|
|
1141
1141
|
currentItem: {
|
|
1142
|
-
index:
|
|
1143
|
-
id: ((
|
|
1144
|
-
trackIndex:
|
|
1145
|
-
startReached:
|
|
1146
|
-
endReached:
|
|
1142
|
+
index: ht,
|
|
1143
|
+
id: ((P = T.at(ht)) == null ? void 0 : P.id) ?? "",
|
|
1144
|
+
trackIndex: re,
|
|
1145
|
+
startReached: k.current,
|
|
1146
|
+
endReached: x.current
|
|
1147
1147
|
}
|
|
1148
1148
|
});
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
1151
|
});
|
|
1152
1152
|
}
|
|
1153
|
-
function
|
|
1154
|
-
const s =
|
|
1153
|
+
function Ht() {
|
|
1154
|
+
const s = _.current;
|
|
1155
1155
|
let l = 0;
|
|
1156
|
-
return f === "item" ? l = s.children[0].getBoundingClientRect()[o === "x" ? "width" : "height"] +
|
|
1156
|
+
return f === "item" ? l = s.children[0].getBoundingClientRect()[o === "x" ? "width" : "height"] + Tt() : l = s.getBoundingClientRect()[o === "x" ? "width" : "height"] + Tt(), l;
|
|
1157
1157
|
}
|
|
1158
|
-
function
|
|
1159
|
-
const l =
|
|
1158
|
+
function lt(s) {
|
|
1159
|
+
const l = _.current;
|
|
1160
1160
|
return l[o === "x" ? "scrollWidth" : "scrollHeight"] - l.getBoundingClientRect()[o === "x" ? "width" : "height"] - s;
|
|
1161
1161
|
}
|
|
1162
1162
|
function It() {
|
|
1163
|
-
const s =
|
|
1163
|
+
const s = xt(i);
|
|
1164
1164
|
return {
|
|
1165
1165
|
totalGutterCssVar: (s == null ? void 0 : s.gutter) || 0,
|
|
1166
1166
|
totalStartEndGutterCssVar: ((s == null ? void 0 : s.startEndGutter) || 0) * 2
|
|
1167
1167
|
};
|
|
1168
1168
|
}
|
|
1169
1169
|
q(() => {
|
|
1170
|
-
function s(
|
|
1171
|
-
const
|
|
1172
|
-
switch (
|
|
1170
|
+
function s(P) {
|
|
1171
|
+
const T = Yt();
|
|
1172
|
+
switch (P) {
|
|
1173
1173
|
case "start":
|
|
1174
1174
|
return 0;
|
|
1175
1175
|
case "middle-start":
|
|
1176
|
-
return Math.floor((
|
|
1176
|
+
return Math.floor((T - 1) * 0.25);
|
|
1177
1177
|
case "center":
|
|
1178
|
-
return Math.floor((
|
|
1178
|
+
return Math.floor((T - 1) * 0.5);
|
|
1179
1179
|
case "middle-end":
|
|
1180
|
-
return Math.floor((
|
|
1180
|
+
return Math.floor((T - 1) * 0.75);
|
|
1181
1181
|
case "end":
|
|
1182
|
-
return
|
|
1182
|
+
return T - 1;
|
|
1183
1183
|
default:
|
|
1184
1184
|
return 0;
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
1187
1187
|
function l() {
|
|
1188
|
-
|
|
1189
|
-
const { totalStartEndGutterCssVar:
|
|
1190
|
-
let
|
|
1191
|
-
e && (
|
|
1188
|
+
w.current = Ht(), U.current = w.current / 4;
|
|
1189
|
+
const { totalStartEndGutterCssVar: P } = It();
|
|
1190
|
+
let T = 0;
|
|
1191
|
+
e && (T = w.current * t.length), T -= w.current * s(u), T -= P / 2, A.current.style.setProperty(
|
|
1192
1192
|
`--${n}-offset-modifier`,
|
|
1193
|
-
`${-
|
|
1194
|
-
);
|
|
1193
|
+
`${-T}px`
|
|
1194
|
+
), e && _.current && (o === "x" ? _.current.style.left = "0px" : _.current.style.top = "0px");
|
|
1195
1195
|
}
|
|
1196
|
-
function g(
|
|
1197
|
-
if (
|
|
1198
|
-
const
|
|
1199
|
-
W({ eventName: "onInit", index:
|
|
1196
|
+
function g(P) {
|
|
1197
|
+
if (A.current && (l(), P)) {
|
|
1198
|
+
const T = _t(v), N = e ? t.length + T % t.length : T;
|
|
1199
|
+
W({ eventName: "onInit", index: T, trackIndex: N });
|
|
1200
1200
|
}
|
|
1201
1201
|
}
|
|
1202
|
-
function
|
|
1202
|
+
function y() {
|
|
1203
1203
|
g(), Y({
|
|
1204
1204
|
type: "resize",
|
|
1205
|
-
toIndex:
|
|
1205
|
+
toIndex: p.current,
|
|
1206
1206
|
shouldAnimate: !1,
|
|
1207
1207
|
actionType: "resize"
|
|
1208
1208
|
});
|
|
1209
1209
|
}
|
|
1210
|
-
function
|
|
1211
|
-
|
|
1210
|
+
function $() {
|
|
1211
|
+
V.current !== null && (clearTimeout(V.current), V.current = null), z.current !== null && (cancelAnimationFrame(z.current), z.current = null);
|
|
1212
1212
|
}
|
|
1213
|
-
function m(
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
if (!
|
|
1218
|
-
const
|
|
1219
|
-
(
|
|
1220
|
-
width:
|
|
1221
|
-
height:
|
|
1222
|
-
},
|
|
1223
|
-
|
|
1213
|
+
function m(P) {
|
|
1214
|
+
z.current === null && (z.current = requestAnimationFrame(() => {
|
|
1215
|
+
z.current = null;
|
|
1216
|
+
const T = A.current;
|
|
1217
|
+
if (!T) return;
|
|
1218
|
+
const N = T.getBoundingClientRect();
|
|
1219
|
+
(N.width !== G.current.width || N.height !== G.current.height) && (G.current = {
|
|
1220
|
+
width: N.width,
|
|
1221
|
+
height: N.height
|
|
1222
|
+
}, y()), P && (V.current = window.setTimeout(() => {
|
|
1223
|
+
V.current = null, m(!1);
|
|
1224
1224
|
}, 400));
|
|
1225
1225
|
}));
|
|
1226
1226
|
}
|
|
1227
|
-
function
|
|
1228
|
-
|
|
1227
|
+
function K() {
|
|
1228
|
+
$(), m(!0);
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1231
|
-
|
|
1232
|
-
|
|
1230
|
+
function j() {
|
|
1231
|
+
$(), V.current = window.setTimeout(() => {
|
|
1232
|
+
V.current = null, G.current = { width: 0, height: 0 }, m(!0);
|
|
1233
1233
|
}, 250);
|
|
1234
1234
|
}
|
|
1235
1235
|
function H() {
|
|
1236
|
-
document.visibilityState === "visible" && (
|
|
1236
|
+
document.visibilityState === "visible" && ($(), G.current = { width: 0, height: 0 }, m(!0));
|
|
1237
1237
|
}
|
|
1238
1238
|
if (r) {
|
|
1239
|
-
if (
|
|
1240
|
-
|
|
1241
|
-
else if (g(!0),
|
|
1242
|
-
const
|
|
1239
|
+
if (E.current = !0, rt.current)
|
|
1240
|
+
y();
|
|
1241
|
+
else if (g(!0), rt.current = !0, A.current) {
|
|
1242
|
+
const T = A.current.getBoundingClientRect();
|
|
1243
1243
|
G.current = {
|
|
1244
|
-
width:
|
|
1245
|
-
height:
|
|
1244
|
+
width: T.width,
|
|
1245
|
+
height: T.height
|
|
1246
1246
|
};
|
|
1247
1247
|
}
|
|
1248
|
-
const
|
|
1249
|
-
return
|
|
1250
|
-
|
|
1248
|
+
const P = window.visualViewport ?? window;
|
|
1249
|
+
return P.addEventListener("resize", K), window.addEventListener("orientationchange", j), document.addEventListener("visibilitychange", H), () => {
|
|
1250
|
+
P.removeEventListener("resize", K), window.removeEventListener(
|
|
1251
1251
|
"orientationchange",
|
|
1252
|
-
|
|
1252
|
+
j
|
|
1253
1253
|
), document.removeEventListener(
|
|
1254
1254
|
"visibilitychange",
|
|
1255
1255
|
H
|
|
1256
|
-
),
|
|
1256
|
+
), $();
|
|
1257
1257
|
};
|
|
1258
1258
|
}
|
|
1259
1259
|
}, [r, n, o, e]), q(() => {
|
|
1260
|
-
const s = _t(
|
|
1261
|
-
r && s !==
|
|
1260
|
+
const s = _t(v), l = t.length, g = e ? p.current % l : p.current, y = e && l > 0 ? (g % l + l) % l : g;
|
|
1261
|
+
r && s !== y && Y({
|
|
1262
1262
|
type: "next",
|
|
1263
1263
|
toIndex: s,
|
|
1264
1264
|
actionType: "resize",
|
|
1265
1265
|
shouldAnimate: !1
|
|
1266
1266
|
});
|
|
1267
|
-
}, [r,
|
|
1268
|
-
const
|
|
1269
|
-
function
|
|
1270
|
-
if (
|
|
1271
|
-
const s =
|
|
1272
|
-
|
|
1267
|
+
}, [r, v]);
|
|
1268
|
+
const ft = c;
|
|
1269
|
+
function Xt() {
|
|
1270
|
+
if (L.current !== null && (cancelAnimationFrame(L.current), L.current = null), B.current) {
|
|
1271
|
+
const s = B.current;
|
|
1272
|
+
B.current = null, W(s);
|
|
1273
1273
|
}
|
|
1274
1274
|
}
|
|
1275
|
-
function
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
const l =
|
|
1279
|
-
|
|
1275
|
+
function qt(s) {
|
|
1276
|
+
B.current = s, L.current === null && (L.current = requestAnimationFrame(() => {
|
|
1277
|
+
L.current = null;
|
|
1278
|
+
const l = B.current;
|
|
1279
|
+
B.current = null, l && W(l);
|
|
1280
1280
|
}));
|
|
1281
1281
|
}
|
|
1282
1282
|
q(
|
|
1283
1283
|
() => () => {
|
|
1284
|
-
|
|
1284
|
+
L.current !== null && (cancelAnimationFrame(L.current), L.current = null), B.current = null;
|
|
1285
1285
|
},
|
|
1286
1286
|
[]
|
|
1287
1287
|
);
|
|
1288
|
-
const
|
|
1288
|
+
const Jt = qe(
|
|
1289
1289
|
(s) => {
|
|
1290
|
-
if (!
|
|
1290
|
+
if (!E.current)
|
|
1291
1291
|
return;
|
|
1292
|
-
const l = s.dragging, g = s.offset[o === "x" ? 0 : 1],
|
|
1293
|
-
l && (
|
|
1292
|
+
const l = s.dragging, g = s.offset[o === "x" ? 0 : 1], y = s.movement[o === "x" ? 0 : 1], $ = y > U.current, m = y < -U.current, K = s.velocity;
|
|
1293
|
+
l && (qt({
|
|
1294
1294
|
...s,
|
|
1295
1295
|
eventName: "onDrag",
|
|
1296
1296
|
slideActionType: "drag"
|
|
1297
|
-
}),
|
|
1297
|
+
}), nt.start({
|
|
1298
1298
|
value: g,
|
|
1299
1299
|
immediate: !0,
|
|
1300
1300
|
config: {
|
|
1301
|
-
velocity:
|
|
1301
|
+
velocity: K
|
|
1302
1302
|
},
|
|
1303
|
-
onChange({ value:
|
|
1304
|
-
|
|
1305
|
-
|
|
1303
|
+
onChange({ value: j }) {
|
|
1304
|
+
_.current.style.transform = Q(
|
|
1305
|
+
j.value,
|
|
1306
1306
|
o,
|
|
1307
1307
|
n
|
|
1308
1308
|
);
|
|
1309
1309
|
}
|
|
1310
|
-
}),
|
|
1310
|
+
}), d && ($ || m) && s.cancel()), s.last && (Xt(), $ ? (Y({
|
|
1311
1311
|
actionType: "drag",
|
|
1312
1312
|
type: "prev"
|
|
1313
1313
|
}), s.cancel()) : m ? (Y({
|
|
1314
1314
|
actionType: "drag",
|
|
1315
1315
|
type: "next"
|
|
1316
|
-
}), s.cancel()) : (
|
|
1317
|
-
value:
|
|
1316
|
+
}), s.cancel()) : (nt.start({
|
|
1317
|
+
value: S.current,
|
|
1318
1318
|
config: {
|
|
1319
|
-
velocity:
|
|
1319
|
+
velocity: K
|
|
1320
1320
|
},
|
|
1321
|
-
onChange({ value:
|
|
1322
|
-
|
|
1323
|
-
|
|
1321
|
+
onChange({ value: j }) {
|
|
1322
|
+
_.current.style.transform = Q(
|
|
1323
|
+
j.value,
|
|
1324
1324
|
o,
|
|
1325
1325
|
n
|
|
1326
1326
|
);
|
|
@@ -1328,38 +1328,38 @@ function ir({
|
|
|
1328
1328
|
}), s.cancel()));
|
|
1329
1329
|
},
|
|
1330
1330
|
{
|
|
1331
|
-
enabled:
|
|
1331
|
+
enabled: ft,
|
|
1332
1332
|
axis: o,
|
|
1333
1333
|
rubberband: !e,
|
|
1334
1334
|
...e ? {} : {
|
|
1335
1335
|
bounds: () => ({
|
|
1336
1336
|
right: 0,
|
|
1337
|
-
left: -
|
|
1338
|
-
top: -
|
|
1337
|
+
left: -lt(0),
|
|
1338
|
+
top: -lt(0),
|
|
1339
1339
|
bottom: 0
|
|
1340
1340
|
})
|
|
1341
1341
|
},
|
|
1342
|
-
from: () => [
|
|
1342
|
+
from: () => [at.value.get(), at.value.get()]
|
|
1343
1343
|
}
|
|
1344
|
-
),
|
|
1344
|
+
), Qt = Vt((s) => {
|
|
1345
1345
|
var m;
|
|
1346
|
-
const l =
|
|
1347
|
-
if (typeof s == "number") return
|
|
1348
|
-
const
|
|
1349
|
-
return s === ((m = l[
|
|
1350
|
-
}, []),
|
|
1346
|
+
const l = R.current, y = J.current ? l.length + p.current % l.length : p.current;
|
|
1347
|
+
if (typeof s == "number") return y === s;
|
|
1348
|
+
const $ = p.current % l.length;
|
|
1349
|
+
return s === ((m = l[$]) == null ? void 0 : m.id);
|
|
1350
|
+
}, []), Zt = gt(
|
|
1351
1351
|
() => Array.from({ length: t.length }, (s, l) => () => {
|
|
1352
|
-
const g = e ?
|
|
1352
|
+
const g = e ? p.current % t.length : p.current;
|
|
1353
1353
|
return e ? l === (g + 1) % t.length : g + 1 >= t.length ? !1 : l === g + 1;
|
|
1354
1354
|
}),
|
|
1355
1355
|
[t.length, e]
|
|
1356
|
-
),
|
|
1356
|
+
), te = gt(
|
|
1357
1357
|
() => Array.from({ length: t.length }, (s, l) => () => {
|
|
1358
|
-
const g = e ?
|
|
1358
|
+
const g = e ? p.current % t.length : p.current;
|
|
1359
1359
|
return e ? l === (g - 1 + t.length) % t.length : g - 1 < 0 ? !1 : l === g - 1;
|
|
1360
1360
|
}),
|
|
1361
1361
|
[t.length, e]
|
|
1362
|
-
),
|
|
1362
|
+
), ee = gt(
|
|
1363
1363
|
() => `
|
|
1364
1364
|
[data-part-internal="${n}-Container"] {
|
|
1365
1365
|
display: flex;
|
|
@@ -1373,14 +1373,14 @@ function ir({
|
|
|
1373
1373
|
--${n}-scroll-y-value: ${o === "y" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
|
|
1374
1374
|
--${n}-gutter: 0px;
|
|
1375
1375
|
--${n}-start-end-gutter: 0px;
|
|
1376
|
-
touch-action: ${
|
|
1376
|
+
touch-action: ${ft ? o === "x" ? "pan-y" : "pan-x" : "auto"};
|
|
1377
1377
|
}
|
|
1378
1378
|
[data-part-internal="${n}-Track"] {
|
|
1379
1379
|
display: flex;
|
|
1380
1380
|
position: relative;
|
|
1381
1381
|
--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));
|
|
1382
|
-
left: ${e && o === "x"
|
|
1383
|
-
top: ${e && o === "y"
|
|
1382
|
+
left: ${e && o === "x" ? "var(--initial-offset-modifier)" : "0px"};
|
|
1383
|
+
top: ${e && o === "y" ? "var(--initial-offset-modifier)" : "0px"};
|
|
1384
1384
|
flex-direction: ${o === "x" ? "row" : "column"};
|
|
1385
1385
|
width: 100%;
|
|
1386
1386
|
height: 100%;
|
|
@@ -1414,10 +1414,9 @@ function ir({
|
|
|
1414
1414
|
[
|
|
1415
1415
|
n,
|
|
1416
1416
|
o,
|
|
1417
|
-
|
|
1417
|
+
ft,
|
|
1418
1418
|
t.length,
|
|
1419
1419
|
e,
|
|
1420
|
-
x,
|
|
1421
1420
|
i,
|
|
1422
1421
|
a
|
|
1423
1422
|
]
|
|
@@ -1426,69 +1425,39 @@ function ir({
|
|
|
1426
1425
|
carouselFragment: /* @__PURE__ */ ne(
|
|
1427
1426
|
"div",
|
|
1428
1427
|
{
|
|
1429
|
-
ref:
|
|
1428
|
+
ref: A,
|
|
1430
1429
|
className: "ReactSpringCarouselContainer",
|
|
1431
1430
|
"data-part": "Container",
|
|
1432
1431
|
"data-part-internal": `${n}-Container`,
|
|
1433
|
-
...
|
|
1432
|
+
...Jt(),
|
|
1434
1433
|
children: [
|
|
1435
|
-
/* @__PURE__ */
|
|
1436
|
-
/* @__PURE__ */
|
|
1437
|
-
|
|
1434
|
+
/* @__PURE__ */ Z("style", { dangerouslySetInnerHTML: { __html: ee } }),
|
|
1435
|
+
/* @__PURE__ */ Z(
|
|
1436
|
+
Ze,
|
|
1438
1437
|
{
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
className: "ReactSpringCarouselItem",
|
|
1455
|
-
"data-part": "Item",
|
|
1456
|
-
"data-part-internal": `${n}-Item`,
|
|
1457
|
-
"data-id": p.id,
|
|
1458
|
-
"aria-hidden": "true",
|
|
1459
|
-
children: T == null ? void 0 : T({ item: p, index: l, isClonedItem: I })
|
|
1460
|
-
},
|
|
1461
|
-
`${p.id}-${l}`
|
|
1462
|
-
);
|
|
1463
|
-
}
|
|
1464
|
-
const m = te[g], L = ee[g];
|
|
1465
|
-
return /* @__PURE__ */ et(
|
|
1466
|
-
"div",
|
|
1467
|
-
{
|
|
1468
|
-
className: "ReactSpringCarouselItem",
|
|
1469
|
-
"data-part": "Item",
|
|
1470
|
-
"data-part-internal": `${n}-Item`,
|
|
1471
|
-
"data-id": p.id,
|
|
1472
|
-
children: typeof p.renderItem == "function" ? p.renderItem({
|
|
1473
|
-
useListenToCustomEvent: wt,
|
|
1474
|
-
index: l,
|
|
1475
|
-
isClonedItem: I,
|
|
1476
|
-
isActiveItem: Zt,
|
|
1477
|
-
isNextItem: m,
|
|
1478
|
-
isPrevItem: L
|
|
1479
|
-
}) : p.renderItem
|
|
1480
|
-
},
|
|
1481
|
-
`${p.id}-${l}`
|
|
1482
|
-
);
|
|
1483
|
-
})
|
|
1438
|
+
id: n,
|
|
1439
|
+
trackRef: _,
|
|
1440
|
+
items: t,
|
|
1441
|
+
trackLength: Wt,
|
|
1442
|
+
withLoop: e,
|
|
1443
|
+
renderWindow: h,
|
|
1444
|
+
renderPlaceholder: C,
|
|
1445
|
+
activeItemRef: p,
|
|
1446
|
+
previousActiveRef: F,
|
|
1447
|
+
isNextItemFns: Zt,
|
|
1448
|
+
isPrevItemFns: te,
|
|
1449
|
+
handleIsActiveItem: Qt,
|
|
1450
|
+
useListenToCustomEvent: wt,
|
|
1451
|
+
startReachedRef: k,
|
|
1452
|
+
endReachedRef: x
|
|
1484
1453
|
}
|
|
1485
1454
|
)
|
|
1486
1455
|
]
|
|
1487
1456
|
}
|
|
1488
1457
|
),
|
|
1489
1458
|
useListenToCustomEvent: wt,
|
|
1490
|
-
slideToNextItem: () =>
|
|
1491
|
-
slideToPrevItem: () =>
|
|
1459
|
+
slideToNextItem: () => ct(),
|
|
1460
|
+
slideToPrevItem: () => ut(),
|
|
1492
1461
|
slideToItem: (s) => {
|
|
1493
1462
|
if (typeof s == "number") {
|
|
1494
1463
|
if (!t[s]) {
|
|
@@ -1497,7 +1466,7 @@ function ir({
|
|
|
1497
1466
|
);
|
|
1498
1467
|
return;
|
|
1499
1468
|
}
|
|
1500
|
-
s >
|
|
1469
|
+
s > p.current ? ct(s) : ut(s);
|
|
1501
1470
|
}
|
|
1502
1471
|
if (typeof s == "string") {
|
|
1503
1472
|
const l = t.findIndex((g) => g.id === s);
|
|
@@ -1507,25 +1476,106 @@ function ir({
|
|
|
1507
1476
|
);
|
|
1508
1477
|
return;
|
|
1509
1478
|
}
|
|
1510
|
-
l >
|
|
1479
|
+
l > p.current ? ct(l) : ut(l);
|
|
1511
1480
|
}
|
|
1512
1481
|
}
|
|
1513
1482
|
};
|
|
1514
1483
|
}
|
|
1515
|
-
function Ze(
|
|
1484
|
+
function Ze({
|
|
1485
|
+
id: r,
|
|
1486
|
+
trackRef: t,
|
|
1487
|
+
items: e,
|
|
1488
|
+
trackLength: n,
|
|
1489
|
+
withLoop: i,
|
|
1490
|
+
renderWindow: a,
|
|
1491
|
+
renderPlaceholder: o,
|
|
1492
|
+
activeItemRef: u,
|
|
1493
|
+
previousActiveRef: c,
|
|
1494
|
+
isNextItemFns: d,
|
|
1495
|
+
isPrevItemFns: f,
|
|
1496
|
+
handleIsActiveItem: v,
|
|
1497
|
+
useListenToCustomEvent: h,
|
|
1498
|
+
startReachedRef: C,
|
|
1499
|
+
endReachedRef: E
|
|
1500
|
+
}) {
|
|
1501
|
+
const [, A] = se((S) => S + 1, 0), _ = Vt(
|
|
1502
|
+
(S) => {
|
|
1503
|
+
a !== void 0 && (S.eventName === "onSlideStartChange" || S.eventName === "onSlideChangeComplete" || S.eventName === "onResize") && A();
|
|
1504
|
+
},
|
|
1505
|
+
[a]
|
|
1506
|
+
);
|
|
1507
|
+
return h(_), /* @__PURE__ */ Z(
|
|
1508
|
+
"div",
|
|
1509
|
+
{
|
|
1510
|
+
ref: t,
|
|
1511
|
+
className: "ReactSpringCarouselTrack",
|
|
1512
|
+
"data-part": "Track",
|
|
1513
|
+
"data-part-internal": `${r}-Track`,
|
|
1514
|
+
onScroll: () => {
|
|
1515
|
+
C.current = !1, E.current = !1;
|
|
1516
|
+
},
|
|
1517
|
+
children: Array.from({ length: n }, (S, w) => {
|
|
1518
|
+
const k = i ? w % e.length : w, x = e[k], U = i && (w < e.length || w >= e.length * 2);
|
|
1519
|
+
if (a !== void 0) {
|
|
1520
|
+
const R = e.length, J = (V) => {
|
|
1521
|
+
if (!i || R === 0) return V;
|
|
1522
|
+
const z = V % R;
|
|
1523
|
+
return R + (z % R + R) % R;
|
|
1524
|
+
}, rt = J(u.current), B = J(c.current);
|
|
1525
|
+
if (Math.min(
|
|
1526
|
+
Math.abs(w - rt),
|
|
1527
|
+
Math.abs(w - B)
|
|
1528
|
+
) > a)
|
|
1529
|
+
return /* @__PURE__ */ Z(
|
|
1530
|
+
"div",
|
|
1531
|
+
{
|
|
1532
|
+
className: "ReactSpringCarouselItem",
|
|
1533
|
+
"data-part": "Item",
|
|
1534
|
+
"data-part-internal": `${r}-Item`,
|
|
1535
|
+
"data-id": x.id,
|
|
1536
|
+
"aria-hidden": "true",
|
|
1537
|
+
children: o == null ? void 0 : o({ item: x, index: w, isClonedItem: U })
|
|
1538
|
+
},
|
|
1539
|
+
`${x.id}-${w}`
|
|
1540
|
+
);
|
|
1541
|
+
}
|
|
1542
|
+
const p = d[k], F = f[k];
|
|
1543
|
+
return /* @__PURE__ */ Z(
|
|
1544
|
+
"div",
|
|
1545
|
+
{
|
|
1546
|
+
className: "ReactSpringCarouselItem",
|
|
1547
|
+
"data-part": "Item",
|
|
1548
|
+
"data-part-internal": `${r}-Item`,
|
|
1549
|
+
"data-id": x.id,
|
|
1550
|
+
children: typeof x.renderItem == "function" ? x.renderItem({
|
|
1551
|
+
useListenToCustomEvent: h,
|
|
1552
|
+
index: w,
|
|
1553
|
+
isClonedItem: U,
|
|
1554
|
+
isActiveItem: v,
|
|
1555
|
+
isNextItem: p,
|
|
1556
|
+
isPrevItem: F
|
|
1557
|
+
}) : x.renderItem
|
|
1558
|
+
},
|
|
1559
|
+
`${x.id}-${w}`
|
|
1560
|
+
);
|
|
1561
|
+
})
|
|
1562
|
+
}
|
|
1563
|
+
);
|
|
1564
|
+
}
|
|
1565
|
+
function tr(r) {
|
|
1516
1566
|
let t = 0;
|
|
1517
1567
|
const e = getComputedStyle(r).getPropertyValue("gap");
|
|
1518
1568
|
return e.includes("px") && (t = Number(e.replace("px", ""))), t;
|
|
1519
1569
|
}
|
|
1520
|
-
function
|
|
1570
|
+
function Mt(r) {
|
|
1521
1571
|
return r.scrollWidth - r.clientWidth;
|
|
1522
1572
|
}
|
|
1523
|
-
function
|
|
1524
|
-
const t = r.children[0], e =
|
|
1573
|
+
function vt(r) {
|
|
1574
|
+
const t = r.children[0], e = tr(r);
|
|
1525
1575
|
return t.getBoundingClientRect().width + e;
|
|
1526
1576
|
}
|
|
1527
|
-
function
|
|
1528
|
-
const e =
|
|
1577
|
+
function or({ container: r, onReach: t }) {
|
|
1578
|
+
const e = I("start"), n = I(0), [, i] = Lt(() => ({
|
|
1529
1579
|
x: 0
|
|
1530
1580
|
}));
|
|
1531
1581
|
function a(u) {
|
|
@@ -1545,47 +1595,47 @@ function sr({ container: r, onReach: t }) {
|
|
|
1545
1595
|
if (!r.current || u === "next" && e.current === "end" || u === "prev" && e.current === "start")
|
|
1546
1596
|
return;
|
|
1547
1597
|
let c = 0;
|
|
1548
|
-
if (u === "next" && (n.current += 1), u === "prev" && (n.current -= 1), c = n.current *
|
|
1549
|
-
const
|
|
1550
|
-
c >
|
|
1598
|
+
if (u === "next" && (n.current += 1), u === "prev" && (n.current -= 1), c = n.current * vt(r.current), u === "next") {
|
|
1599
|
+
const d = Mt(r.current);
|
|
1600
|
+
c > d && (e.current = "end", c = d, t && t("end"));
|
|
1551
1601
|
}
|
|
1552
1602
|
u === "prev" && c <= 0 && (e.current = "start", n.current = 0, c = 0, t && t("start")), a(c);
|
|
1553
1603
|
}
|
|
1554
1604
|
return q(() => {
|
|
1555
1605
|
function u() {
|
|
1556
|
-
var
|
|
1557
|
-
const
|
|
1558
|
-
index:
|
|
1559
|
-
start:
|
|
1560
|
-
end:
|
|
1561
|
-
})),
|
|
1562
|
-
(k) =>
|
|
1606
|
+
var w;
|
|
1607
|
+
const C = vt(r.current), E = ((w = [...r.current.children].at(0)) == null ? void 0 : w.getBoundingClientRect().width) || 0, A = Array(r.current.childElementCount).fill(0).map((k, x) => ({
|
|
1608
|
+
index: x,
|
|
1609
|
+
start: C * x,
|
|
1610
|
+
end: C * (x + 1)
|
|
1611
|
+
})), _ = r.current.scrollLeft + E, S = A.find(
|
|
1612
|
+
(k) => _ >= k.start && _ < k.end
|
|
1563
1613
|
);
|
|
1564
|
-
n.current = (
|
|
1614
|
+
n.current = (S == null ? void 0 : S.index) || 0;
|
|
1565
1615
|
}
|
|
1566
1616
|
function c() {
|
|
1567
1617
|
i.stop();
|
|
1568
1618
|
}
|
|
1569
|
-
function
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1619
|
+
function d(C) {
|
|
1620
|
+
const E = C.target;
|
|
1621
|
+
E.scrollLeft === 0 ? (n.current = 0, e.current = "start", t && t("start")) : E.scrollLeft >= Mt(E) ? (e.current = "end", t && t("end")) : e.current !== "idle" && (e.current = "idle", t && t("idle"));
|
|
1572
1622
|
}
|
|
1573
|
-
let f,
|
|
1574
|
-
function
|
|
1575
|
-
|
|
1576
|
-
r.current.scrollLeft ===
|
|
1623
|
+
let f, v = 0;
|
|
1624
|
+
function h() {
|
|
1625
|
+
v = r.current.scrollLeft, clearTimeout(f), f = setTimeout(function() {
|
|
1626
|
+
r.current.scrollLeft === v && u();
|
|
1577
1627
|
}, 200);
|
|
1578
1628
|
}
|
|
1579
1629
|
if (r.current)
|
|
1580
1630
|
return r.current.addEventListener("wheel", c, {
|
|
1581
1631
|
passive: !0
|
|
1582
|
-
}), r.current.addEventListener("scroll",
|
|
1583
|
-
r.current && (r.current.removeEventListener("scroll",
|
|
1632
|
+
}), r.current.addEventListener("scroll", d), r.current.addEventListener("scroll", h), () => {
|
|
1633
|
+
r.current && (r.current.removeEventListener("scroll", h), r.current.removeEventListener("scroll", d), r.current.removeEventListener("wheel", c));
|
|
1584
1634
|
};
|
|
1585
1635
|
}, [r, t]), q(() => {
|
|
1586
1636
|
if (r.current) {
|
|
1587
1637
|
const u = new ResizeObserver(() => {
|
|
1588
|
-
a(n.current *
|
|
1638
|
+
a(n.current * vt(r.current));
|
|
1589
1639
|
});
|
|
1590
1640
|
return u.observe(r.current), () => {
|
|
1591
1641
|
u.disconnect();
|
|
@@ -1601,6 +1651,6 @@ function sr({ container: r, onReach: t }) {
|
|
|
1601
1651
|
};
|
|
1602
1652
|
}
|
|
1603
1653
|
export {
|
|
1604
|
-
|
|
1605
|
-
|
|
1654
|
+
sr as useSpringCarousel,
|
|
1655
|
+
or as useSpringScroll
|
|
1606
1656
|
};
|