react-spring-carousel 3.0.0-beta-2.2.0 → 3.0.0-beta-2.2.1
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 +293 -293
- package/dist/index.umd.js +4 -4
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useSpringRef as
|
|
3
|
-
import ft, { useRef as
|
|
4
|
-
function
|
|
1
|
+
import { jsxs as ie, jsx as et } from "react/jsx-runtime";
|
|
2
|
+
import { useSpringRef as se, useSpring as jt } from "@react-spring/web";
|
|
3
|
+
import ft, { useRef as b, useEffect as q, useState as kt, useCallback as oe, useMemo as dt } from "react";
|
|
4
|
+
function ae(r, t, e) {
|
|
5
5
|
return Math.max(t, Math.min(r, e));
|
|
6
6
|
}
|
|
7
7
|
const S = {
|
|
@@ -21,17 +21,17 @@ const S = {
|
|
|
21
21
|
r[0] -= t[0], r[1] -= t[1];
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function Ct(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 ?
|
|
27
|
+
function Dt(r, t, e, n = 0.15) {
|
|
28
|
+
return n === 0 ? ae(r, t, e) : r < t ? -Ct(t - r, e - t, n) + t : r > e ? +Ct(r - e, e - t, n) + e : r;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
const [[a, o], [
|
|
32
|
-
return [
|
|
30
|
+
function ce(r, [t, e], [n, i]) {
|
|
31
|
+
const [[a, o], [l, c]] = r;
|
|
32
|
+
return [Dt(t, a, o, n), Dt(e, l, c, i)];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function ue(r, t) {
|
|
35
35
|
if (typeof r != "object" || r === null) return r;
|
|
36
36
|
var e = r[Symbol.toPrimitive];
|
|
37
37
|
if (e !== void 0) {
|
|
@@ -41,19 +41,19 @@ function ce(r, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return (t === "string" ? String : Number)(r);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
var t =
|
|
44
|
+
function le(r) {
|
|
45
|
+
var t = ue(r, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
48
|
function D(r, t, e) {
|
|
49
|
-
return t =
|
|
49
|
+
return t = le(t), t in r ? Object.defineProperty(r, t, {
|
|
50
50
|
value: e,
|
|
51
51
|
enumerable: !0,
|
|
52
52
|
configurable: !0,
|
|
53
53
|
writable: !0
|
|
54
54
|
}) : r[t] = e, r;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function At(r, t) {
|
|
57
57
|
var e = Object.keys(r);
|
|
58
58
|
if (Object.getOwnPropertySymbols) {
|
|
59
59
|
var n = Object.getOwnPropertySymbols(r);
|
|
@@ -66,15 +66,15 @@ function Dt(r, t) {
|
|
|
66
66
|
function v(r) {
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var e = arguments[t] != null ? arguments[t] : {};
|
|
69
|
-
t % 2 ?
|
|
69
|
+
t % 2 ? At(Object(e), !0).forEach(function(n) {
|
|
70
70
|
D(r, n, e[n]);
|
|
71
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) :
|
|
71
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : At(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 zt = {
|
|
78
78
|
pointer: {
|
|
79
79
|
start: "down",
|
|
80
80
|
change: "move",
|
|
@@ -96,63 +96,63 @@ const jt = {
|
|
|
96
96
|
end: "end"
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
function
|
|
99
|
+
function $t(r) {
|
|
100
100
|
return r ? r[0].toUpperCase() + r.slice(1) : "";
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
104
|
-
return r && !
|
|
102
|
+
const fe = ["enter", "leave"];
|
|
103
|
+
function de(r = !1, t) {
|
|
104
|
+
return r && !fe.includes(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
const n =
|
|
108
|
-
return "on" +
|
|
106
|
+
function he(r, t = "", e = !1) {
|
|
107
|
+
const n = zt[r], i = n && n[t] || t;
|
|
108
|
+
return "on" + $t(r) + $t(i) + (de(e, i) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
110
|
+
const pe = ["gotpointercapture", "lostpointercapture"];
|
|
111
|
+
function ge(r) {
|
|
112
112
|
let t = r.substring(2).toLowerCase();
|
|
113
113
|
const e = !!~t.indexOf("passive");
|
|
114
114
|
e && (t = t.replace("passive", ""));
|
|
115
|
-
const n =
|
|
115
|
+
const n = pe.includes(t) ? "capturecapture" : "capture", i = !!~t.indexOf(n);
|
|
116
116
|
return i && (t = t.replace("capture", "")), {
|
|
117
117
|
device: t,
|
|
118
118
|
capture: i,
|
|
119
119
|
passive: e
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
const e =
|
|
122
|
+
function me(r, t = "") {
|
|
123
|
+
const e = zt[r], n = e && e[t] || t;
|
|
124
124
|
return r + n;
|
|
125
125
|
}
|
|
126
126
|
function it(r) {
|
|
127
127
|
return "touches" in r;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function Ut(r) {
|
|
130
130
|
return it(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function ve(r) {
|
|
133
133
|
return Array.from(r.touches).filter((t) => {
|
|
134
134
|
var e, n;
|
|
135
135
|
return t.target === r.currentTarget || ((e = r.currentTarget) === null || e === void 0 || (n = e.contains) === null || n === void 0 ? void 0 : n.call(e, t.target));
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function ye(r) {
|
|
139
139
|
return r.type === "touchend" || r.type === "touchcancel" ? r.changedTouches : r.targetTouches;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return it(r) ?
|
|
141
|
+
function Kt(r) {
|
|
142
|
+
return it(r) ? ye(r)[0] : r;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function be(r) {
|
|
145
|
+
return ve(r).map((t) => t.identifier);
|
|
146
146
|
}
|
|
147
147
|
function ht(r) {
|
|
148
|
-
const t =
|
|
148
|
+
const t = Kt(r);
|
|
149
149
|
return it(r) ? t.identifier : t.pointerId;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const t =
|
|
151
|
+
function Ot(r) {
|
|
152
|
+
const t = Kt(r);
|
|
153
153
|
return [t.clientX, t.clientY];
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function _e(r) {
|
|
156
156
|
const t = {};
|
|
157
157
|
if ("buttons" in r && (t.buttons = r.buttons), "shiftKey" in r) {
|
|
158
158
|
const {
|
|
@@ -173,21 +173,21 @@ function be(r) {
|
|
|
173
173
|
function nt(r, ...t) {
|
|
174
174
|
return typeof r == "function" ? r(...t) : r;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function we() {
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return r.length === 0 ?
|
|
178
|
+
function Te(...r) {
|
|
179
|
+
return r.length === 0 ? we : r.length === 1 ? r[0] : function() {
|
|
180
180
|
let t;
|
|
181
181
|
for (const e of r)
|
|
182
182
|
t = e.apply(this, arguments) || t;
|
|
183
183
|
return t;
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function Pt(r, t) {
|
|
187
187
|
return Object.assign({}, t, r || {});
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
class
|
|
189
|
+
const xe = 32;
|
|
190
|
+
class Ie {
|
|
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
|
}
|
|
@@ -244,29 +244,29 @@ class xe {
|
|
|
244
244
|
} = this;
|
|
245
245
|
e.args = this.args;
|
|
246
246
|
let a = 0;
|
|
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,
|
|
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, _e(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
248
|
const C = e._delta.map(Math.abs);
|
|
249
249
|
S.addTo(e._distance, C);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
|
-
const [o,
|
|
252
|
+
const [o, l] = e._movement, [c, h] = n.threshold, {
|
|
253
253
|
_step: f,
|
|
254
|
-
values:
|
|
254
|
+
values: _
|
|
255
255
|
} = e;
|
|
256
|
-
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(o) >= c &&
|
|
256
|
+
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(o) >= c && _[0]), f[1] === !1 && (f[1] = Math.abs(l) >= h && _[1])) : (f[0] === !1 && (f[0] = Math.abs(o) >= c && Math.sign(o) * c), f[1] === !1 && (f[1] = Math.abs(l) >= h && Math.sign(l) * h)), e.intentional = f[0] !== !1 || f[1] !== !1, !e.intentional) return;
|
|
257
257
|
const d = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
|
-
const [C,
|
|
260
|
-
d[0] = f[0] !== !1 ? C - f[0] : 0, d[1] = f[1] !== !1 ?
|
|
259
|
+
const [C, M] = _;
|
|
260
|
+
d[0] = f[0] !== !1 ? C - f[0] : 0, d[1] = f[1] !== !1 ? M - f[1] : 0;
|
|
261
261
|
} else
|
|
262
|
-
d[0] = f[0] !== !1 ? o - f[0] : 0, d[1] = f[1] !== !1 ?
|
|
262
|
+
d[0] = f[0] !== !1 ? o - f[0] : 0, d[1] = f[1] !== !1 ? l - f[1] : 0;
|
|
263
263
|
this.restrictToAxis && !e._blocked && this.restrictToAxis(d);
|
|
264
264
|
const T = e.offset, x = e._active && !e._blocked || e.active;
|
|
265
265
|
x && (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 = nt(n.bounds, e)), this.setup && this.setup()), e.movement = d, this.computeOffset()));
|
|
266
|
-
const [B,
|
|
267
|
-
e.overflow = [B < A ? -1 : B > O ? 1 : 0,
|
|
266
|
+
const [B, N] = e.offset, [[A, O], [k, j]] = e._bounds;
|
|
267
|
+
e.overflow = [B < A ? -1 : B > O ? 1 : 0, N < k ? -1 : N > j ? 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
268
|
const z = e._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
-
if (e.offset =
|
|
269
|
+
if (e.offset = ce(e._bounds, e.offset, z), e.delta = S.sub(e.offset, T), this.computeMovement(), x && (!e.last || a > xe)) {
|
|
270
270
|
e.delta = S.sub(e.offset, T);
|
|
271
271
|
const C = e.delta.map(Math.abs);
|
|
272
272
|
S.addTo(e.distance, C), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && a > 0 && (e.velocity = [C[0] / a, C[1] / a], e.timeDelta = a);
|
|
@@ -284,14 +284,14 @@ class xe {
|
|
|
284
284
|
this.eventStore.clean(), this.timeoutStore.clean();
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function Ee([r, t], e) {
|
|
288
288
|
const n = Math.abs(r), i = Math.abs(t);
|
|
289
289
|
if (n > i && n > e)
|
|
290
290
|
return "x";
|
|
291
291
|
if (i > n && i > e)
|
|
292
292
|
return "y";
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class Se extends Ie {
|
|
295
295
|
constructor(...t) {
|
|
296
296
|
super(...t), D(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
@@ -310,8 +310,8 @@ class Ee extends xe {
|
|
|
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[
|
|
314
|
-
e.axis =
|
|
313
|
+
const i = typeof n.axisThreshold == "object" ? n.axisThreshold[Ut(t)] : n.axisThreshold;
|
|
314
|
+
e.axis = Ee(e._movement, i);
|
|
315
315
|
}
|
|
316
316
|
e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
|
|
317
317
|
}
|
|
@@ -327,7 +327,7 @@ class Ee extends xe {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const Rt = (r) => r, Nt = 0.15, mt = {
|
|
331
331
|
enabled(r = !0) {
|
|
332
332
|
return r;
|
|
333
333
|
},
|
|
@@ -343,7 +343,7 @@ 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 [Nt, Nt];
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
@@ -357,13 +357,13 @@ const Pt = (r) => r, Rt = 0.15, mt = {
|
|
|
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 || Rt;
|
|
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 || Rt;
|
|
367
367
|
},
|
|
368
368
|
threshold(r) {
|
|
369
369
|
return S.toVector(r, 0);
|
|
@@ -386,13 +386,13 @@ process.env.NODE_ENV === "development" && Object.assign(mt, {
|
|
|
386
386
|
return NaN;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
const
|
|
389
|
+
const ke = 0, Q = v(v({}, mt), {}, {
|
|
390
390
|
axis(r, t, {
|
|
391
391
|
axis: e
|
|
392
392
|
}) {
|
|
393
393
|
if (this.lockDirection = e === "lock", !this.lockDirection) return e;
|
|
394
394
|
},
|
|
395
|
-
axisThreshold(r =
|
|
395
|
+
axisThreshold(r = ke) {
|
|
396
396
|
return r;
|
|
397
397
|
},
|
|
398
398
|
bounds(r = {}) {
|
|
@@ -410,13 +410,13 @@ const Se = 0, Q = v(v({}, mt), {}, {
|
|
|
410
410
|
} = r;
|
|
411
411
|
return [[t, e], [n, i]];
|
|
412
412
|
}
|
|
413
|
-
}),
|
|
413
|
+
}), Mt = {
|
|
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],
|
|
417
417
|
ArrowDown: (r, t = 1) => [0, r * t]
|
|
418
418
|
};
|
|
419
|
-
class
|
|
419
|
+
class Ce extends Se {
|
|
420
420
|
constructor(...t) {
|
|
421
421
|
super(...t), D(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
@@ -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 = ht(t), n._pointerActive = !0, this.computeValues(
|
|
456
|
+
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(i && i.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = ht(t), n._pointerActive = !0, this.computeValues(Ot(t)), this.computeInitial(), e.preventScrollAxis && Ut(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;
|
|
@@ -464,7 +464,7 @@ class ke extends Ee {
|
|
|
464
464
|
if (!e._pointerActive) return;
|
|
465
465
|
const i = ht(t);
|
|
466
466
|
if (e._pointerId !== void 0 && i !== e._pointerId) return;
|
|
467
|
-
const a =
|
|
467
|
+
const a = Ot(t);
|
|
468
468
|
if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = S.sub(a, e._values), this.computeValues(a)), S.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;
|
|
@@ -498,10 +498,10 @@ class ke extends Ee {
|
|
|
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 [
|
|
501
|
+
const [l, c] = e._delta, [h, f] = e._movement, [_, d] = n.swipe.velocity, [T, x] = n.swipe.distance, B = n.swipe.duration;
|
|
502
502
|
if (e.elapsedTime < B) {
|
|
503
|
-
const
|
|
504
|
-
|
|
503
|
+
const N = Math.abs(l / e.timeDelta), A = Math.abs(c / e.timeDelta);
|
|
504
|
+
N > _ && Math.abs(h) > T && (e.swipe[0] = Math.sign(l)), A > d && Math.abs(f) > x && (e.swipe[1] = Math.sign(c));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -528,7 +528,7 @@ class ke extends Ee {
|
|
|
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, De(t);
|
|
532
532
|
const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
|
533
533
|
passive: !1
|
|
534
534
|
});
|
|
@@ -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 = Mt[t.key];
|
|
544
544
|
if (e) {
|
|
545
545
|
const n = this.state, i = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
546
546
|
this.start(t), n._delta = e(this.config.keyboardDisplacement, i), n._keyboardActive = !0, S.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 Mt && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
|
|
551
551
|
}
|
|
552
552
|
bind(t) {
|
|
553
553
|
const e = this.config.device;
|
|
@@ -557,23 +557,23 @@ class ke extends Ee {
|
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function De(r) {
|
|
561
561
|
"persist" in r && typeof r.persist == "function" && r.persist();
|
|
562
562
|
}
|
|
563
563
|
const Z = typeof window < "u" && window.document && window.document.createElement;
|
|
564
|
-
function
|
|
564
|
+
function Ft() {
|
|
565
565
|
return Z && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
|
-
function De() {
|
|
568
|
-
return Kt() || Z && window.navigator.maxTouchPoints > 1;
|
|
569
|
-
}
|
|
570
567
|
function Ae() {
|
|
571
|
-
return Z &&
|
|
568
|
+
return Ft() || Z && window.navigator.maxTouchPoints > 1;
|
|
572
569
|
}
|
|
573
570
|
function $e() {
|
|
574
|
-
return Z && "
|
|
571
|
+
return Z && "onpointerdown" in window;
|
|
575
572
|
}
|
|
576
573
|
function Oe() {
|
|
574
|
+
return Z && "exitPointerLock" in window.document;
|
|
575
|
+
}
|
|
576
|
+
function Pe() {
|
|
577
577
|
try {
|
|
578
578
|
return "constructor" in GestureEvent;
|
|
579
579
|
} catch {
|
|
@@ -582,16 +582,16 @@ function Oe() {
|
|
|
582
582
|
}
|
|
583
583
|
const $ = {
|
|
584
584
|
isBrowser: Z,
|
|
585
|
-
gesture:
|
|
586
|
-
touch:
|
|
587
|
-
touchscreen:
|
|
588
|
-
pointer:
|
|
589
|
-
pointerLock:
|
|
590
|
-
},
|
|
585
|
+
gesture: Pe(),
|
|
586
|
+
touch: Ft(),
|
|
587
|
+
touchscreen: Ae(),
|
|
588
|
+
pointer: $e(),
|
|
589
|
+
pointerLock: Oe()
|
|
590
|
+
}, Re = 250, Ne = 180, Me = 0.5, Le = 50, Ve = 250, Be = 10, Lt = {
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
},
|
|
594
|
+
}, Gt = v(v({}, Q), {}, {
|
|
595
595
|
device(r, t, {
|
|
596
596
|
pointer: {
|
|
597
597
|
touch: e = !1,
|
|
@@ -604,7 +604,7 @@ const $ = {
|
|
|
604
604
|
preventScrollAxis(r, t, {
|
|
605
605
|
preventScroll: e
|
|
606
606
|
}) {
|
|
607
|
-
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ?
|
|
607
|
+
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? Re : void 0, !(!$.touchscreen || e === !1))
|
|
608
608
|
return r || (e !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
610
|
pointerCapture(r, t, {
|
|
@@ -625,9 +625,9 @@ const $ = {
|
|
|
625
625
|
return this.filterTaps = e, this.tapsThreshold = n, a;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
628
|
-
velocity: r =
|
|
629
|
-
distance: t =
|
|
630
|
-
duration: e =
|
|
628
|
+
velocity: r = Me,
|
|
629
|
+
distance: t = Le,
|
|
630
|
+
duration: e = Ve
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
633
|
velocity: this.transform(S.toVector(r)),
|
|
@@ -638,7 +638,7 @@ const $ = {
|
|
|
638
638
|
delay(r = 0) {
|
|
639
639
|
switch (r) {
|
|
640
640
|
case !0:
|
|
641
|
-
return
|
|
641
|
+
return Ne;
|
|
642
642
|
case !1:
|
|
643
643
|
return 0;
|
|
644
644
|
default:
|
|
@@ -646,13 +646,13 @@ const $ = {
|
|
|
646
646
|
}
|
|
647
647
|
},
|
|
648
648
|
axisThreshold(r) {
|
|
649
|
-
return r ? v(v({},
|
|
649
|
+
return r ? v(v({}, Lt), r) : Lt;
|
|
650
650
|
},
|
|
651
|
-
keyboardDisplacement(r =
|
|
651
|
+
keyboardDisplacement(r = Be) {
|
|
652
652
|
return r;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
655
|
+
process.env.NODE_ENV === "development" && Object.assign(Gt, {
|
|
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 } }`.");
|
|
@@ -698,17 +698,17 @@ v(v({}, mt), {}, {
|
|
|
698
698
|
angleBounds: n = {}
|
|
699
699
|
}) {
|
|
700
700
|
const i = (o) => {
|
|
701
|
-
const
|
|
701
|
+
const l = Pt(nt(e, o), {
|
|
702
702
|
min: -1 / 0,
|
|
703
703
|
max: 1 / 0
|
|
704
704
|
});
|
|
705
|
-
return [
|
|
705
|
+
return [l.min, l.max];
|
|
706
706
|
}, a = (o) => {
|
|
707
|
-
const
|
|
707
|
+
const l = Pt(nt(n, o), {
|
|
708
708
|
min: -1 / 0,
|
|
709
709
|
max: 1 / 0
|
|
710
710
|
});
|
|
711
|
-
return [
|
|
711
|
+
return [l.min, l.max];
|
|
712
712
|
};
|
|
713
713
|
return typeof e != "function" && typeof n != "function" ? [i(), a()] : (o) => [i(o), a(o)];
|
|
714
714
|
},
|
|
@@ -728,25 +728,25 @@ v(v({}, Q), {}, {
|
|
|
728
728
|
v(v({}, Q), {}, {
|
|
729
729
|
mouseOnly: (r = !0) => r
|
|
730
730
|
});
|
|
731
|
-
const
|
|
732
|
-
function
|
|
733
|
-
|
|
731
|
+
const Wt = /* @__PURE__ */ new Map(), gt = /* @__PURE__ */ new Map();
|
|
732
|
+
function je(r) {
|
|
733
|
+
Wt.set(r.key, r.engine), gt.set(r.key, r.resolver);
|
|
734
734
|
}
|
|
735
|
-
const
|
|
735
|
+
const ze = {
|
|
736
736
|
key: "drag",
|
|
737
|
-
engine:
|
|
738
|
-
resolver:
|
|
737
|
+
engine: Ce,
|
|
738
|
+
resolver: Gt
|
|
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 Ke(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++)
|
|
@@ -754,7 +754,7 @@ function Ue(r, t) {
|
|
|
754
754
|
}
|
|
755
755
|
return e;
|
|
756
756
|
}
|
|
757
|
-
const
|
|
757
|
+
const Fe = {
|
|
758
758
|
target(r) {
|
|
759
759
|
if (r)
|
|
760
760
|
return () => "current" in r ? r.current : r;
|
|
@@ -777,7 +777,7 @@ const Ke = {
|
|
|
777
777
|
transform(r) {
|
|
778
778
|
return r;
|
|
779
779
|
}
|
|
780
|
-
},
|
|
780
|
+
}, Ge = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
781
781
|
function rt(r = {}, t) {
|
|
782
782
|
const e = {};
|
|
783
783
|
for (const [n, i] of Object.entries(t))
|
|
@@ -798,32 +798,32 @@ function rt(r = {}, t) {
|
|
|
798
798
|
}
|
|
799
799
|
return e;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function We(r, t, e = {}) {
|
|
802
802
|
const n = r, {
|
|
803
803
|
target: i,
|
|
804
804
|
eventOptions: a,
|
|
805
805
|
window: o,
|
|
806
|
-
enabled:
|
|
806
|
+
enabled: l,
|
|
807
807
|
transform: c
|
|
808
|
-
} = n, h =
|
|
808
|
+
} = n, h = Ke(n, Ge);
|
|
809
809
|
if (e.shared = rt({
|
|
810
810
|
target: i,
|
|
811
811
|
eventOptions: a,
|
|
812
812
|
window: o,
|
|
813
|
-
enabled:
|
|
813
|
+
enabled: l,
|
|
814
814
|
transform: c
|
|
815
|
-
},
|
|
815
|
+
}, Fe), t) {
|
|
816
816
|
const f = gt.get(t);
|
|
817
817
|
e[t] = rt(v({
|
|
818
818
|
shared: e.shared
|
|
819
819
|
}, h), f);
|
|
820
820
|
} else
|
|
821
821
|
for (const f in h) {
|
|
822
|
-
const
|
|
823
|
-
if (
|
|
822
|
+
const _ = gt.get(f);
|
|
823
|
+
if (_)
|
|
824
824
|
e[f] = rt(v({
|
|
825
825
|
shared: e.shared
|
|
826
|
-
}, h[f]),
|
|
826
|
+
}, h[f]), _);
|
|
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 Yt {
|
|
836
836
|
constructor(t, e) {
|
|
837
837
|
D(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,
|
|
841
|
-
t.addEventListener(
|
|
840
|
+
const o = this._listeners, l = me(e, n), c = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, h = v(v({}, c), a);
|
|
841
|
+
t.addEventListener(l, i, h);
|
|
842
842
|
const f = () => {
|
|
843
|
-
t.removeEventListener(
|
|
843
|
+
t.removeEventListener(l, i, h), o.delete(f);
|
|
844
844
|
};
|
|
845
845
|
return o.add(f), f;
|
|
846
846
|
}
|
|
@@ -848,7 +848,7 @@ class Wt {
|
|
|
848
848
|
this._listeners.forEach((t) => t()), this._listeners.clear();
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
class
|
|
851
|
+
class Ye {
|
|
852
852
|
constructor() {
|
|
853
853
|
D(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
@@ -863,20 +863,20 @@ class We {
|
|
|
863
863
|
this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
class
|
|
866
|
+
class He {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
D(this, "gestures", /* @__PURE__ */ new Set()), D(this, "_targetEventStore", new
|
|
868
|
+
D(this, "gestures", /* @__PURE__ */ new Set()), D(this, "_targetEventStore", new Yt(this)), D(this, "gestureEventStores", {}), D(this, "gestureTimeoutStores", {}), D(this, "handlers", {}), D(this, "config", {}), D(this, "pointerIds", /* @__PURE__ */ new Set()), D(this, "touchIds", /* @__PURE__ */ new Set()), D(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
|
+
}), Xe(this, t);
|
|
876
876
|
}
|
|
877
877
|
setEventIds(t) {
|
|
878
878
|
if (it(t))
|
|
879
|
-
return this.touchIds = new Set(
|
|
879
|
+
return this.touchIds = new Set(be(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 Ye {
|
|
|
884
884
|
this.handlers = t, this.nativeHandlers = e;
|
|
885
885
|
}
|
|
886
886
|
applyConfig(t, e) {
|
|
887
|
-
this.config =
|
|
887
|
+
this.config = We(t, e, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -900,30 +900,30 @@ 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
|
|
904
|
-
if (
|
|
905
|
-
const h =
|
|
903
|
+
const l = this.config[o], c = Vt(n, l.eventOptions, !!i);
|
|
904
|
+
if (l.enabled) {
|
|
905
|
+
const h = Wt.get(o);
|
|
906
906
|
new h(this, t, o).bind(c);
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
const a =
|
|
909
|
+
const a = Vt(n, e.eventOptions, !!i);
|
|
910
910
|
for (const o in this.nativeHandlers)
|
|
911
|
-
a(o, "", (
|
|
912
|
-
event:
|
|
911
|
+
a(o, "", (l) => this.nativeHandlers[o](v(v({}, this.state.shared), {}, {
|
|
912
|
+
event: l,
|
|
913
913
|
args: t
|
|
914
914
|
})), void 0, !0);
|
|
915
915
|
}
|
|
916
916
|
for (const a in n)
|
|
917
|
-
n[a] =
|
|
917
|
+
n[a] = Te(...n[a]);
|
|
918
918
|
if (!i) return n;
|
|
919
919
|
for (const a in n) {
|
|
920
920
|
const {
|
|
921
921
|
device: o,
|
|
922
|
-
capture:
|
|
922
|
+
capture: l,
|
|
923
923
|
passive: c
|
|
924
|
-
} =
|
|
924
|
+
} = ge(a);
|
|
925
925
|
this._targetEventStore.add(i, o, "", n[a], {
|
|
926
|
-
capture:
|
|
926
|
+
capture: l,
|
|
927
927
|
passive: c
|
|
928
928
|
});
|
|
929
929
|
}
|
|
@@ -931,28 +931,28 @@ 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 Yt(r, t), r.gestureTimeoutStores[t] = new Ye();
|
|
935
935
|
}
|
|
936
|
-
function
|
|
936
|
+
function Xe(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
|
|
939
|
+
const Vt = (r, t, e) => (n, i, a, o = {}, l = !1) => {
|
|
940
940
|
var c, h;
|
|
941
|
-
const f = (c = o.capture) !== null && c !== void 0 ? c : t.capture,
|
|
942
|
-
let d =
|
|
943
|
-
e &&
|
|
941
|
+
const f = (c = o.capture) !== null && c !== void 0 ? c : t.capture, _ = (h = o.passive) !== null && h !== void 0 ? h : t.passive;
|
|
942
|
+
let d = l ? n : he(n, i, f);
|
|
943
|
+
e && _ && (d += "Passive"), r[d] = r[d] || [], r[d].push(a);
|
|
944
944
|
};
|
|
945
|
-
function
|
|
946
|
-
const i = ft.useMemo(() => new
|
|
945
|
+
function qe(r, t = {}, e, n) {
|
|
946
|
+
const i = ft.useMemo(() => new He(r), []);
|
|
947
947
|
if (i.applyHandlers(r, n), i.applyConfig(t, e), ft.useEffect(i.effect.bind(i)), ft.useEffect(() => i.clean.bind(i), []), t.target === void 0)
|
|
948
948
|
return i.bind.bind(i);
|
|
949
949
|
}
|
|
950
|
-
function
|
|
951
|
-
return
|
|
950
|
+
function Je(r, t) {
|
|
951
|
+
return je(ze), qe({
|
|
952
952
|
drag: r
|
|
953
953
|
}, t || {}, "drag");
|
|
954
954
|
}
|
|
955
|
-
function
|
|
955
|
+
function Qe(r) {
|
|
956
956
|
const {
|
|
957
957
|
type: t,
|
|
958
958
|
actionType: e,
|
|
@@ -960,19 +960,19 @@ function Je(r) {
|
|
|
960
960
|
itemsLength: i,
|
|
961
961
|
withLoop: a,
|
|
962
962
|
scrollAmount: o,
|
|
963
|
-
totalAvailable:
|
|
963
|
+
totalAvailable: l
|
|
964
964
|
} = r;
|
|
965
|
-
let c = r.currentActive, h = r.fromValueRaw, f = !1,
|
|
965
|
+
let c = r.currentActive, h = r.fromValueRaw, f = !1, _ = !1;
|
|
966
966
|
t === "next" && (c += 1), t === "prev" && (c = c === 0 ? i - 1 : c - 1), n !== void 0 && (c = n);
|
|
967
967
|
let d = 0;
|
|
968
|
-
t === "next" && (d = -(c * o), a && c === i && (c = 0, h = h + o * i, d = 0), !a && (Math.abs(d) >=
|
|
968
|
+
t === "next" && (d = -(c * o), a && c === i && (c = 0, h = h + o * i, d = 0), !a && (Math.abs(d) >= l || c === i - 1) && (_ = !0, d = -l)), t === "prev" && (d = -(c * o), c === i - 1 && (h = h - i * o), !a && d >= 0 && (f = !0, d = 0)), e === "resize" && (d = -(c * o), a || (c === 0 && (f = !0), (c === i - 1 || Math.abs(d) >= l) && (_ = !0, Math.abs(d) >= l && l > 0 && (d = -l))));
|
|
969
969
|
const T = a ? c % i : c, x = a ? i + c % i : c;
|
|
970
970
|
return {
|
|
971
971
|
newActive: c,
|
|
972
972
|
fromValue: h,
|
|
973
973
|
toValue: d,
|
|
974
974
|
startReached: f,
|
|
975
|
-
endReached:
|
|
975
|
+
endReached: _,
|
|
976
976
|
logicalIndex: T,
|
|
977
977
|
realTrackIndex: x
|
|
978
978
|
};
|
|
@@ -980,12 +980,12 @@ function Je(r) {
|
|
|
980
980
|
function J(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
|
-
function
|
|
984
|
-
const r =
|
|
983
|
+
function Ze() {
|
|
984
|
+
const r = b(
|
|
985
985
|
null
|
|
986
986
|
);
|
|
987
987
|
r.current === null && (r.current = /* @__PURE__ */ new Set());
|
|
988
|
-
const t =
|
|
988
|
+
const t = b(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,
|
|
@@ -1009,29 +1009,29 @@ function ir({
|
|
|
1009
1009
|
gutter: i = [{ breakpoint: 0, gutter: 0, startEndGutter: 0 }],
|
|
1010
1010
|
itemsPerSlide: a = [{ breakpoint: 0, itemsPerSlide: 1 }],
|
|
1011
1011
|
carouselAxis: o = "x",
|
|
1012
|
-
startingPosition:
|
|
1012
|
+
startingPosition: l = "start",
|
|
1013
1013
|
enableGestures: c = !0,
|
|
1014
1014
|
slideWhenDragThresholdIsReached: h = !0,
|
|
1015
1015
|
slideType: f = "item",
|
|
1016
|
-
initialActiveItem:
|
|
1016
|
+
initialActiveItem: _ = 0,
|
|
1017
1017
|
renderWindow: d,
|
|
1018
1018
|
renderPlaceholder: T
|
|
1019
1019
|
}) {
|
|
1020
|
-
const [x, B] =
|
|
1021
|
-
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1024
|
-
const
|
|
1025
|
-
function
|
|
1020
|
+
const [x, B] = kt(!1), [, N] = kt(0), A = b(r), O = b(null), k = b(null), j = b(0), z = b(0), C = b(!e), M = b(!1), st = b(0), w = b(0), vt = b(0), yt = b(t);
|
|
1021
|
+
yt.current = t;
|
|
1022
|
+
const bt = b(e);
|
|
1023
|
+
bt.current = e;
|
|
1024
|
+
const _t = b(!1), U = b(null), L = b(null), K = b(null), F = b(null), G = b({ width: 0, height: 0 });
|
|
1025
|
+
function wt(s) {
|
|
1026
1026
|
if (s === void 0) return 0;
|
|
1027
1027
|
if (typeof s == "number")
|
|
1028
1028
|
return t[s] ? s : (console.warn(
|
|
1029
1029
|
`initialActiveItem: item at index ${s} doesn't exist.`
|
|
1030
1030
|
), 0);
|
|
1031
|
-
const
|
|
1032
|
-
return
|
|
1031
|
+
const u = t.findIndex((g) => g.id === s);
|
|
1032
|
+
return u < 0 ? (console.warn(`initialActiveItem: item with id "${s}" doesn't exist.`), 0) : u;
|
|
1033
1033
|
}
|
|
1034
|
-
const tt =
|
|
1034
|
+
const tt = se(), ot = jt({
|
|
1035
1035
|
value: 0,
|
|
1036
1036
|
ref: tt,
|
|
1037
1037
|
onChange({ value: s }) {
|
|
@@ -1041,24 +1041,24 @@ function ir({
|
|
|
1041
1041
|
n
|
|
1042
1042
|
);
|
|
1043
1043
|
}
|
|
1044
|
-
}),
|
|
1045
|
-
function
|
|
1044
|
+
}), Ht = e ? t.length * 3 : t.length, { useListenToCustomEvent: Tt, emitEvent: W } = Ze();
|
|
1045
|
+
function xt(s) {
|
|
1046
1046
|
if (!s || s.length === 0) return null;
|
|
1047
|
-
let
|
|
1047
|
+
let u = null, g = -1 / 0;
|
|
1048
1048
|
for (const p of s)
|
|
1049
|
-
(p.media ? window.matchMedia(p.media).matches : window.innerWidth >= p.breakpoint) && p.breakpoint >= g && (
|
|
1050
|
-
return
|
|
1049
|
+
(p.media ? window.matchMedia(p.media).matches : window.innerWidth >= p.breakpoint) && p.breakpoint >= g && (u = p, g = p.breakpoint);
|
|
1050
|
+
return u;
|
|
1051
1051
|
}
|
|
1052
|
-
function
|
|
1053
|
-
const { totalGutterCssVar: s } =
|
|
1052
|
+
function It() {
|
|
1053
|
+
const { totalGutterCssVar: s } = Et();
|
|
1054
1054
|
return s;
|
|
1055
1055
|
}
|
|
1056
|
-
function
|
|
1057
|
-
const s =
|
|
1056
|
+
function Xt() {
|
|
1057
|
+
const s = xt(a);
|
|
1058
1058
|
return (s == null ? void 0 : s.itemsPerSlide) || 1;
|
|
1059
1059
|
}
|
|
1060
1060
|
function at(s) {
|
|
1061
|
-
A.current && (
|
|
1061
|
+
A.current && (M.current || Y({
|
|
1062
1062
|
type: "next",
|
|
1063
1063
|
toIndex: s,
|
|
1064
1064
|
actionType: "click"
|
|
@@ -1073,14 +1073,14 @@ function ir({
|
|
|
1073
1073
|
}
|
|
1074
1074
|
function Y({
|
|
1075
1075
|
type: s,
|
|
1076
|
-
shouldAnimate:
|
|
1076
|
+
shouldAnimate: u = !0,
|
|
1077
1077
|
toIndex: g,
|
|
1078
1078
|
actionType: p
|
|
1079
1079
|
}) {
|
|
1080
1080
|
var P, H;
|
|
1081
|
-
const I = !
|
|
1082
|
-
C.current = !1,
|
|
1083
|
-
const m =
|
|
1081
|
+
const I = !u;
|
|
1082
|
+
C.current = !1, M.current = !1;
|
|
1083
|
+
const m = Qe({
|
|
1084
1084
|
type: s,
|
|
1085
1085
|
actionType: p,
|
|
1086
1086
|
toIndex: g,
|
|
@@ -1092,8 +1092,8 @@ function ir({
|
|
|
1092
1092
|
e ? z.current * (t.length * 2) : 0
|
|
1093
1093
|
) : 0,
|
|
1094
1094
|
fromValueRaw: ot.value.get()
|
|
1095
|
-
}),
|
|
1096
|
-
w.current = m.newActive, C.current = m.startReached,
|
|
1095
|
+
}), V = w.current;
|
|
1096
|
+
w.current = m.newActive, C.current = m.startReached, M.current = m.endReached, j.current = m.toValue, d !== void 0 && V !== m.newActive && N((E) => E + 1), W(p === "resize" ? {
|
|
1097
1097
|
eventName: "onResize",
|
|
1098
1098
|
sliceActionType: p,
|
|
1099
1099
|
slideDirection: s,
|
|
@@ -1102,7 +1102,7 @@ function ir({
|
|
|
1102
1102
|
index: m.logicalIndex,
|
|
1103
1103
|
trackIndex: m.realTrackIndex,
|
|
1104
1104
|
startReached: C.current,
|
|
1105
|
-
endReached:
|
|
1105
|
+
endReached: M.current
|
|
1106
1106
|
}
|
|
1107
1107
|
} : {
|
|
1108
1108
|
eventName: "onSlideStartChange",
|
|
@@ -1113,7 +1113,7 @@ function ir({
|
|
|
1113
1113
|
id: ((H = t.at(m.logicalIndex)) == null ? void 0 : H.id) ?? "",
|
|
1114
1114
|
trackIndex: m.realTrackIndex,
|
|
1115
1115
|
startReached: C.current,
|
|
1116
|
-
endReached:
|
|
1116
|
+
endReached: M.current
|
|
1117
1117
|
}
|
|
1118
1118
|
}), I && k.current && (k.current.style.transform = J(
|
|
1119
1119
|
m.toValue,
|
|
@@ -1133,34 +1133,34 @@ function ir({
|
|
|
1133
1133
|
onRest({ finished: E }) {
|
|
1134
1134
|
var y;
|
|
1135
1135
|
if (E) {
|
|
1136
|
-
const
|
|
1137
|
-
W({
|
|
1136
|
+
const R = e ? w.current % t.length : w.current, St = e ? t.length + w.current % t.length : w.current;
|
|
1137
|
+
vt.current = R, W({
|
|
1138
1138
|
eventName: "onSlideChangeComplete",
|
|
1139
1139
|
sliceActionType: p,
|
|
1140
1140
|
slideDirection: s,
|
|
1141
1141
|
currentItem: {
|
|
1142
|
-
index:
|
|
1143
|
-
id: ((y = t.at(
|
|
1144
|
-
trackIndex:
|
|
1142
|
+
index: R,
|
|
1143
|
+
id: ((y = t.at(R)) == null ? void 0 : y.id) ?? "",
|
|
1144
|
+
trackIndex: St,
|
|
1145
1145
|
startReached: C.current,
|
|
1146
|
-
endReached:
|
|
1146
|
+
endReached: M.current
|
|
1147
1147
|
}
|
|
1148
1148
|
});
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
1151
|
});
|
|
1152
1152
|
}
|
|
1153
|
-
function
|
|
1153
|
+
function qt() {
|
|
1154
1154
|
const s = k.current;
|
|
1155
|
-
let
|
|
1156
|
-
return f === "item" ?
|
|
1155
|
+
let u = 0;
|
|
1156
|
+
return f === "item" ? u = s.children[0].getBoundingClientRect()[o === "x" ? "width" : "height"] + It() : u = s.getBoundingClientRect()[o === "x" ? "width" : "height"] + It(), u;
|
|
1157
1157
|
}
|
|
1158
1158
|
function ut(s) {
|
|
1159
|
-
const
|
|
1160
|
-
return
|
|
1159
|
+
const u = k.current;
|
|
1160
|
+
return u[o === "x" ? "scrollWidth" : "scrollHeight"] - u.getBoundingClientRect()[o === "x" ? "width" : "height"] - s;
|
|
1161
1161
|
}
|
|
1162
|
-
function
|
|
1163
|
-
const s =
|
|
1162
|
+
function Et() {
|
|
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
|
|
@@ -1168,7 +1168,7 @@ function ir({
|
|
|
1168
1168
|
}
|
|
1169
1169
|
q(() => {
|
|
1170
1170
|
function s(E) {
|
|
1171
|
-
const y =
|
|
1171
|
+
const y = Xt();
|
|
1172
1172
|
switch (E) {
|
|
1173
1173
|
case "start":
|
|
1174
1174
|
return 0;
|
|
@@ -1184,19 +1184,19 @@ function ir({
|
|
|
1184
1184
|
return 0;
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
1187
|
-
function
|
|
1188
|
-
z.current =
|
|
1189
|
-
const { totalStartEndGutterCssVar: E } =
|
|
1187
|
+
function u() {
|
|
1188
|
+
z.current = qt(), st.current = z.current / 4;
|
|
1189
|
+
const { totalStartEndGutterCssVar: E } = Et();
|
|
1190
1190
|
let y = 0;
|
|
1191
|
-
e && (y = z.current * t.length), y -= z.current * s(
|
|
1191
|
+
e && (y = z.current * t.length), y -= z.current * s(l), y -= E / 2, O.current.style.setProperty(
|
|
1192
1192
|
`--${n}-offset-modifier`,
|
|
1193
1193
|
`${-y}px`
|
|
1194
1194
|
);
|
|
1195
1195
|
}
|
|
1196
1196
|
function g(E) {
|
|
1197
|
-
if (O.current && (
|
|
1198
|
-
const y =
|
|
1199
|
-
W({ eventName: "onInit", index: y, trackIndex:
|
|
1197
|
+
if (O.current && (u(), B(!0), E)) {
|
|
1198
|
+
const y = wt(_), R = e ? t.length + y % t.length : y;
|
|
1199
|
+
W({ eventName: "onInit", index: y, trackIndex: R });
|
|
1200
1200
|
}
|
|
1201
1201
|
}
|
|
1202
1202
|
function p() {
|
|
@@ -1215,16 +1215,16 @@ function ir({
|
|
|
1215
1215
|
F.current = null;
|
|
1216
1216
|
const y = O.current;
|
|
1217
1217
|
if (!y) return;
|
|
1218
|
-
const
|
|
1219
|
-
(
|
|
1220
|
-
width:
|
|
1221
|
-
height:
|
|
1218
|
+
const R = y.getBoundingClientRect();
|
|
1219
|
+
(R.width !== G.current.width || R.height !== G.current.height) && (G.current = {
|
|
1220
|
+
width: R.width,
|
|
1221
|
+
height: R.height
|
|
1222
1222
|
}, p()), E && (K.current = window.setTimeout(() => {
|
|
1223
1223
|
K.current = null, m(!1);
|
|
1224
1224
|
}, 400));
|
|
1225
1225
|
}));
|
|
1226
1226
|
}
|
|
1227
|
-
function
|
|
1227
|
+
function V() {
|
|
1228
1228
|
I(), m(!0);
|
|
1229
1229
|
}
|
|
1230
1230
|
function P() {
|
|
@@ -1236,9 +1236,9 @@ function ir({
|
|
|
1236
1236
|
document.visibilityState === "visible" && (I(), G.current = { width: 0, height: 0 }, m(!0));
|
|
1237
1237
|
}
|
|
1238
1238
|
if (r) {
|
|
1239
|
-
if (A.current = !0,
|
|
1239
|
+
if (A.current = !0, _t.current)
|
|
1240
1240
|
p();
|
|
1241
|
-
else if (g(!0),
|
|
1241
|
+
else if (g(!0), _t.current = !0, O.current) {
|
|
1242
1242
|
const y = O.current.getBoundingClientRect();
|
|
1243
1243
|
G.current = {
|
|
1244
1244
|
width: y.width,
|
|
@@ -1246,8 +1246,8 @@ function ir({
|
|
|
1246
1246
|
};
|
|
1247
1247
|
}
|
|
1248
1248
|
const E = window.visualViewport ?? window;
|
|
1249
|
-
return E.addEventListener("resize",
|
|
1250
|
-
E.removeEventListener("resize",
|
|
1249
|
+
return E.addEventListener("resize", V), window.addEventListener("orientationchange", P), document.addEventListener("visibilitychange", H), () => {
|
|
1250
|
+
E.removeEventListener("resize", V), window.removeEventListener(
|
|
1251
1251
|
"orientationchange",
|
|
1252
1252
|
P
|
|
1253
1253
|
), document.removeEventListener(
|
|
@@ -1257,40 +1257,40 @@ function ir({
|
|
|
1257
1257
|
};
|
|
1258
1258
|
}
|
|
1259
1259
|
}, [r, n, o, e]), q(() => {
|
|
1260
|
-
const s =
|
|
1261
|
-
r && s !== w.current && Y({
|
|
1260
|
+
const s = wt(_), u = s === vt.current;
|
|
1261
|
+
r && s !== w.current && !u && Y({
|
|
1262
1262
|
type: "next",
|
|
1263
1263
|
toIndex: s,
|
|
1264
1264
|
actionType: "resize",
|
|
1265
1265
|
shouldAnimate: !1
|
|
1266
1266
|
});
|
|
1267
|
-
}, [r,
|
|
1267
|
+
}, [r, _]);
|
|
1268
1268
|
const lt = c;
|
|
1269
|
-
function
|
|
1270
|
-
if (
|
|
1269
|
+
function Jt() {
|
|
1270
|
+
if (L.current !== null && (cancelAnimationFrame(L.current), L.current = null), U.current) {
|
|
1271
1271
|
const s = U.current;
|
|
1272
1272
|
U.current = null, W(s);
|
|
1273
1273
|
}
|
|
1274
1274
|
}
|
|
1275
|
-
function
|
|
1276
|
-
U.current = s,
|
|
1277
|
-
|
|
1278
|
-
const
|
|
1279
|
-
U.current = null,
|
|
1275
|
+
function Qt(s) {
|
|
1276
|
+
U.current = s, L.current === null && (L.current = requestAnimationFrame(() => {
|
|
1277
|
+
L.current = null;
|
|
1278
|
+
const u = U.current;
|
|
1279
|
+
U.current = null, u && W(u);
|
|
1280
1280
|
}));
|
|
1281
1281
|
}
|
|
1282
1282
|
q(
|
|
1283
1283
|
() => () => {
|
|
1284
|
-
|
|
1284
|
+
L.current !== null && (cancelAnimationFrame(L.current), L.current = null), U.current = null;
|
|
1285
1285
|
},
|
|
1286
1286
|
[]
|
|
1287
1287
|
);
|
|
1288
|
-
const
|
|
1288
|
+
const Zt = Je(
|
|
1289
1289
|
(s) => {
|
|
1290
1290
|
if (!A.current)
|
|
1291
1291
|
return;
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1292
|
+
const u = s.dragging, g = s.offset[o === "x" ? 0 : 1], p = s.movement[o === "x" ? 0 : 1], I = p > st.current, m = p < -st.current, V = s.velocity;
|
|
1293
|
+
u && (Qt({
|
|
1294
1294
|
...s,
|
|
1295
1295
|
eventName: "onDrag",
|
|
1296
1296
|
slideActionType: "drag"
|
|
@@ -1298,7 +1298,7 @@ function ir({
|
|
|
1298
1298
|
value: g,
|
|
1299
1299
|
immediate: !0,
|
|
1300
1300
|
config: {
|
|
1301
|
-
velocity:
|
|
1301
|
+
velocity: V
|
|
1302
1302
|
},
|
|
1303
1303
|
onChange({ value: P }) {
|
|
1304
1304
|
k.current.style.transform = J(
|
|
@@ -1307,7 +1307,7 @@ function ir({
|
|
|
1307
1307
|
n
|
|
1308
1308
|
);
|
|
1309
1309
|
}
|
|
1310
|
-
}), h && (I || m) && s.cancel()), s.last && (
|
|
1310
|
+
}), h && (I || m) && s.cancel()), s.last && (Jt(), I ? (Y({
|
|
1311
1311
|
actionType: "drag",
|
|
1312
1312
|
type: "prev"
|
|
1313
1313
|
}), s.cancel()) : m ? (Y({
|
|
@@ -1316,7 +1316,7 @@ function ir({
|
|
|
1316
1316
|
}), s.cancel()) : (tt.start({
|
|
1317
1317
|
value: j.current,
|
|
1318
1318
|
config: {
|
|
1319
|
-
velocity:
|
|
1319
|
+
velocity: V
|
|
1320
1320
|
},
|
|
1321
1321
|
onChange({ value: P }) {
|
|
1322
1322
|
k.current.style.transform = J(
|
|
@@ -1341,25 +1341,25 @@ function ir({
|
|
|
1341
1341
|
},
|
|
1342
1342
|
from: () => [ot.value.get(), ot.value.get()]
|
|
1343
1343
|
}
|
|
1344
|
-
),
|
|
1344
|
+
), te = oe((s) => {
|
|
1345
1345
|
var m;
|
|
1346
|
-
const
|
|
1346
|
+
const u = yt.current, p = bt.current ? u.length + w.current % u.length : w.current;
|
|
1347
1347
|
if (typeof s == "number") return p === s;
|
|
1348
|
-
const I = w.current %
|
|
1349
|
-
return s === ((m =
|
|
1350
|
-
}, []),
|
|
1351
|
-
() => Array.from({ length: t.length }, (s,
|
|
1348
|
+
const I = w.current % u.length;
|
|
1349
|
+
return s === ((m = u[I]) == null ? void 0 : m.id);
|
|
1350
|
+
}, []), ee = dt(
|
|
1351
|
+
() => Array.from({ length: t.length }, (s, u) => () => {
|
|
1352
1352
|
const g = e ? w.current % t.length : w.current;
|
|
1353
|
-
return e ?
|
|
1353
|
+
return e ? u === (g + 1) % t.length : g + 1 >= t.length ? !1 : u === g + 1;
|
|
1354
1354
|
}),
|
|
1355
1355
|
[t.length, e]
|
|
1356
|
-
),
|
|
1357
|
-
() => Array.from({ length: t.length }, (s,
|
|
1356
|
+
), re = dt(
|
|
1357
|
+
() => Array.from({ length: t.length }, (s, u) => () => {
|
|
1358
1358
|
const g = e ? w.current % t.length : w.current;
|
|
1359
|
-
return e ?
|
|
1359
|
+
return e ? u === (g - 1 + t.length) % t.length : g - 1 < 0 ? !1 : u === g - 1;
|
|
1360
1360
|
}),
|
|
1361
1361
|
[t.length, e]
|
|
1362
|
-
),
|
|
1362
|
+
), ne = dt(
|
|
1363
1363
|
() => `
|
|
1364
1364
|
[data-part-internal="${n}-Container"] {
|
|
1365
1365
|
display: flex;
|
|
@@ -1391,7 +1391,7 @@ function ir({
|
|
|
1391
1391
|
display: flex;
|
|
1392
1392
|
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)));
|
|
1393
1393
|
}
|
|
1394
|
-
${i && i.length > 0 ? i.slice().sort((s,
|
|
1394
|
+
${i && i.length > 0 ? i.slice().sort((s, u) => s.breakpoint - u.breakpoint).map(
|
|
1395
1395
|
(s) => `
|
|
1396
1396
|
@media ${s.media || `(min-width: ${s.breakpoint}px)`} {
|
|
1397
1397
|
[data-part-internal="${n}-Container"] {
|
|
@@ -1401,7 +1401,7 @@ function ir({
|
|
|
1401
1401
|
}
|
|
1402
1402
|
`
|
|
1403
1403
|
).join("") : ""}
|
|
1404
|
-
${a && a.length > 0 ? a.slice().sort((s,
|
|
1404
|
+
${a && a.length > 0 ? a.slice().sort((s, u) => s.breakpoint - u.breakpoint).map(
|
|
1405
1405
|
(s) => `
|
|
1406
1406
|
@media ${s.media || `(min-width: ${s.breakpoint}px)`} {
|
|
1407
1407
|
[data-part-internal="${n}-Container"] {
|
|
@@ -1423,16 +1423,16 @@ function ir({
|
|
|
1423
1423
|
]
|
|
1424
1424
|
);
|
|
1425
1425
|
return {
|
|
1426
|
-
carouselFragment: /* @__PURE__ */
|
|
1426
|
+
carouselFragment: /* @__PURE__ */ ie(
|
|
1427
1427
|
"div",
|
|
1428
1428
|
{
|
|
1429
1429
|
ref: O,
|
|
1430
1430
|
className: "ReactSpringCarouselContainer",
|
|
1431
1431
|
"data-part": "Container",
|
|
1432
1432
|
"data-part-internal": `${n}-Container`,
|
|
1433
|
-
...
|
|
1433
|
+
...Zt(),
|
|
1434
1434
|
children: [
|
|
1435
|
-
/* @__PURE__ */ et("style", { dangerouslySetInnerHTML: { __html:
|
|
1435
|
+
/* @__PURE__ */ et("style", { dangerouslySetInnerHTML: { __html: ne } }),
|
|
1436
1436
|
/* @__PURE__ */ et(
|
|
1437
1437
|
"div",
|
|
1438
1438
|
{
|
|
@@ -1441,13 +1441,13 @@ function ir({
|
|
|
1441
1441
|
"data-part": "Track",
|
|
1442
1442
|
"data-part-internal": `${n}-Track`,
|
|
1443
1443
|
onScroll: () => {
|
|
1444
|
-
C.current = !1,
|
|
1444
|
+
C.current = !1, M.current = !1;
|
|
1445
1445
|
},
|
|
1446
|
-
children: Array.from({ length:
|
|
1447
|
-
const g = e ?
|
|
1446
|
+
children: Array.from({ length: Ht }, (s, u) => {
|
|
1447
|
+
const g = e ? u % t.length : u, p = t[g], I = e && (u < t.length || u >= t.length * 2);
|
|
1448
1448
|
if (d !== void 0) {
|
|
1449
1449
|
const P = e ? t.length + w.current % t.length : w.current;
|
|
1450
|
-
if (Math.abs(
|
|
1450
|
+
if (Math.abs(u - P) > d)
|
|
1451
1451
|
return /* @__PURE__ */ et(
|
|
1452
1452
|
"div",
|
|
1453
1453
|
{
|
|
@@ -1456,12 +1456,12 @@ function ir({
|
|
|
1456
1456
|
"data-part-internal": `${n}-Item`,
|
|
1457
1457
|
"data-id": p.id,
|
|
1458
1458
|
"aria-hidden": "true",
|
|
1459
|
-
children: T == null ? void 0 : T({ item: p, index:
|
|
1459
|
+
children: T == null ? void 0 : T({ item: p, index: u, isClonedItem: I })
|
|
1460
1460
|
},
|
|
1461
|
-
`${p.id}-${
|
|
1461
|
+
`${p.id}-${u}`
|
|
1462
1462
|
);
|
|
1463
1463
|
}
|
|
1464
|
-
const m =
|
|
1464
|
+
const m = ee[g], V = re[g];
|
|
1465
1465
|
return /* @__PURE__ */ et(
|
|
1466
1466
|
"div",
|
|
1467
1467
|
{
|
|
@@ -1470,15 +1470,15 @@ function ir({
|
|
|
1470
1470
|
"data-part-internal": `${n}-Item`,
|
|
1471
1471
|
"data-id": p.id,
|
|
1472
1472
|
children: typeof p.renderItem == "function" ? p.renderItem({
|
|
1473
|
-
useListenToCustomEvent:
|
|
1474
|
-
index:
|
|
1473
|
+
useListenToCustomEvent: Tt,
|
|
1474
|
+
index: u,
|
|
1475
1475
|
isClonedItem: I,
|
|
1476
|
-
isActiveItem:
|
|
1476
|
+
isActiveItem: te,
|
|
1477
1477
|
isNextItem: m,
|
|
1478
|
-
isPrevItem:
|
|
1478
|
+
isPrevItem: V
|
|
1479
1479
|
}) : p.renderItem
|
|
1480
1480
|
},
|
|
1481
|
-
`${p.id}-${
|
|
1481
|
+
`${p.id}-${u}`
|
|
1482
1482
|
);
|
|
1483
1483
|
})
|
|
1484
1484
|
}
|
|
@@ -1486,7 +1486,7 @@ function ir({
|
|
|
1486
1486
|
]
|
|
1487
1487
|
}
|
|
1488
1488
|
),
|
|
1489
|
-
useListenToCustomEvent:
|
|
1489
|
+
useListenToCustomEvent: Tt,
|
|
1490
1490
|
slideToNextItem: () => at(),
|
|
1491
1491
|
slideToPrevItem: () => ct(),
|
|
1492
1492
|
slideToItem: (s) => {
|
|
@@ -1500,66 +1500,66 @@ function ir({
|
|
|
1500
1500
|
s > w.current ? at(s) : ct(s);
|
|
1501
1501
|
}
|
|
1502
1502
|
if (typeof s == "string") {
|
|
1503
|
-
const
|
|
1504
|
-
if (
|
|
1503
|
+
const u = t.findIndex((g) => g.id === s);
|
|
1504
|
+
if (u < 0) {
|
|
1505
1505
|
console.warn(
|
|
1506
1506
|
`The item you're trying to slide doesn't exist. id: ${s}`
|
|
1507
1507
|
);
|
|
1508
1508
|
return;
|
|
1509
1509
|
}
|
|
1510
|
-
|
|
1510
|
+
u > w.current ? at(u) : ct(u);
|
|
1511
1511
|
}
|
|
1512
1512
|
}
|
|
1513
1513
|
};
|
|
1514
1514
|
}
|
|
1515
|
-
function
|
|
1515
|
+
function tr(r) {
|
|
1516
1516
|
let t = 0;
|
|
1517
1517
|
const e = getComputedStyle(r).getPropertyValue("gap");
|
|
1518
1518
|
return e.includes("px") && (t = Number(e.replace("px", ""))), t;
|
|
1519
1519
|
}
|
|
1520
|
-
function
|
|
1520
|
+
function Bt(r) {
|
|
1521
1521
|
return r.scrollWidth - r.clientWidth;
|
|
1522
1522
|
}
|
|
1523
1523
|
function pt(r) {
|
|
1524
|
-
const t = r.children[0], e =
|
|
1524
|
+
const t = r.children[0], e = tr(r);
|
|
1525
1525
|
return t.getBoundingClientRect().width + e;
|
|
1526
1526
|
}
|
|
1527
|
-
function
|
|
1528
|
-
const e =
|
|
1527
|
+
function or({ container: r, onReach: t }) {
|
|
1528
|
+
const e = b("start"), n = b(0), [, i] = jt(() => ({
|
|
1529
1529
|
x: 0
|
|
1530
1530
|
}));
|
|
1531
|
-
function a(
|
|
1531
|
+
function a(l) {
|
|
1532
1532
|
i.start({
|
|
1533
1533
|
from: {
|
|
1534
1534
|
x: r.current.scrollLeft
|
|
1535
1535
|
},
|
|
1536
1536
|
to: {
|
|
1537
|
-
x:
|
|
1537
|
+
x: l
|
|
1538
1538
|
},
|
|
1539
1539
|
onChange({ value: c }) {
|
|
1540
1540
|
r.current && (r.current.scrollLeft = c.x);
|
|
1541
1541
|
}
|
|
1542
1542
|
});
|
|
1543
1543
|
}
|
|
1544
|
-
function o(
|
|
1545
|
-
if (!r.current ||
|
|
1544
|
+
function o(l) {
|
|
1545
|
+
if (!r.current || l === "next" && e.current === "end" || l === "prev" && e.current === "start")
|
|
1546
1546
|
return;
|
|
1547
1547
|
let c = 0;
|
|
1548
|
-
if (
|
|
1549
|
-
const h =
|
|
1548
|
+
if (l === "next" && (n.current += 1), l === "prev" && (n.current -= 1), c = n.current * pt(r.current), l === "next") {
|
|
1549
|
+
const h = Bt(r.current);
|
|
1550
1550
|
c > h && (e.current = "end", c = h, t && t("end"));
|
|
1551
1551
|
}
|
|
1552
|
-
|
|
1552
|
+
l === "prev" && c <= 0 && (e.current = "start", n.current = 0, c = 0, t && t("start")), a(c);
|
|
1553
1553
|
}
|
|
1554
1554
|
return q(() => {
|
|
1555
|
-
function
|
|
1555
|
+
function l() {
|
|
1556
1556
|
var O;
|
|
1557
1557
|
const T = pt(r.current), x = ((O = [...r.current.children].at(0)) == null ? void 0 : O.getBoundingClientRect().width) || 0, B = Array(r.current.childElementCount).fill(0).map((k, j) => ({
|
|
1558
1558
|
index: j,
|
|
1559
1559
|
start: T * j,
|
|
1560
1560
|
end: T * (j + 1)
|
|
1561
|
-
})),
|
|
1562
|
-
(k) =>
|
|
1561
|
+
})), N = r.current.scrollLeft + x, A = B.find(
|
|
1562
|
+
(k) => N >= k.start && N < k.end
|
|
1563
1563
|
);
|
|
1564
1564
|
n.current = (A == null ? void 0 : A.index) || 0;
|
|
1565
1565
|
}
|
|
@@ -1568,12 +1568,12 @@ function sr({ container: r, onReach: t }) {
|
|
|
1568
1568
|
}
|
|
1569
1569
|
function h(T) {
|
|
1570
1570
|
const x = T.target;
|
|
1571
|
-
x.scrollLeft === 0 ? (n.current = 0, e.current = "start", t && t("start")) : x.scrollLeft >=
|
|
1571
|
+
x.scrollLeft === 0 ? (n.current = 0, e.current = "start", t && t("start")) : x.scrollLeft >= Bt(x) ? (e.current = "end", t && t("end")) : e.current !== "idle" && (e.current = "idle", t && t("idle"));
|
|
1572
1572
|
}
|
|
1573
|
-
let f,
|
|
1573
|
+
let f, _ = 0;
|
|
1574
1574
|
function d() {
|
|
1575
|
-
|
|
1576
|
-
r.current.scrollLeft ===
|
|
1575
|
+
_ = r.current.scrollLeft, clearTimeout(f), f = setTimeout(function() {
|
|
1576
|
+
r.current.scrollLeft === _ && l();
|
|
1577
1577
|
}, 200);
|
|
1578
1578
|
}
|
|
1579
1579
|
if (r.current)
|
|
@@ -1584,11 +1584,11 @@ function sr({ container: r, onReach: t }) {
|
|
|
1584
1584
|
};
|
|
1585
1585
|
}, [r, t]), q(() => {
|
|
1586
1586
|
if (r.current) {
|
|
1587
|
-
const
|
|
1587
|
+
const l = new ResizeObserver(() => {
|
|
1588
1588
|
a(n.current * pt(r.current));
|
|
1589
1589
|
});
|
|
1590
|
-
return
|
|
1591
|
-
|
|
1590
|
+
return l.observe(r.current), () => {
|
|
1591
|
+
l.disconnect();
|
|
1592
1592
|
};
|
|
1593
1593
|
}
|
|
1594
1594
|
}, []), {
|
|
@@ -1601,6 +1601,6 @@ function sr({ container: r, onReach: t }) {
|
|
|
1601
1601
|
};
|
|
1602
1602
|
}
|
|
1603
1603
|
export {
|
|
1604
|
-
|
|
1605
|
-
|
|
1604
|
+
sr as useSpringCarousel,
|
|
1605
|
+
or as useSpringScroll
|
|
1606
1606
|
};
|