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