react-spring-carousel 3.0.0-beta-2.0.104 → 3.0.0-beta-2.0.105
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 +247 -243
- package/dist/index.umd.js +5 -5
- package/dist/types.d.ts +3 -0
- 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 Ut, jsx as tt } from "react/jsx-runtime";
|
|
2
|
+
import { useSpringRef as Kt, useSpring as kt } from "@react-spring/web";
|
|
3
|
+
import et, { useRef as $, useEffect as U, useState as Gt } from "react";
|
|
4
|
+
function zt(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 mt(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 gt(e, t, r, n = 0.15) {
|
|
28
|
+
return n === 0 ? zt(e, t, r) : e < t ? -mt(t - e, r - t, n) + t : e > r ? +mt(e - r, r - t, n) + r : e;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Wt(e, [t, r], [n, s]) {
|
|
31
31
|
const [[o, a], [c, f]] = e;
|
|
32
|
-
return [
|
|
32
|
+
return [gt(t, o, a, n), gt(r, c, f, s)];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Yt(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 zt(e, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return (t === "string" ? String : Number)(e);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
var t =
|
|
44
|
+
function Ft(e) {
|
|
45
|
+
var t = Yt(e, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return t =
|
|
48
|
+
function T(e, t, r) {
|
|
49
|
+
return t = Ft(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 vt(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 mt(e, t) {
|
|
|
66
66
|
function p(e) {
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var r = arguments[t] != null ? arguments[t] : {};
|
|
69
|
-
t % 2 ?
|
|
70
|
-
|
|
71
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) :
|
|
69
|
+
t % 2 ? vt(Object(r), !0).forEach(function(n) {
|
|
70
|
+
T(e, n, r[n]);
|
|
71
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : vt(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 Ct = {
|
|
78
78
|
pointer: {
|
|
79
79
|
start: "down",
|
|
80
80
|
change: "move",
|
|
@@ -96,63 +96,63 @@ const It = {
|
|
|
96
96
|
end: "end"
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
function
|
|
99
|
+
function yt(e) {
|
|
100
100
|
return e ? e[0].toUpperCase() + e.slice(1) : "";
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
104
|
-
return e && !
|
|
102
|
+
const Ht = ["enter", "leave"];
|
|
103
|
+
function Xt(e = !1, t) {
|
|
104
|
+
return e && !Ht.includes(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
const n =
|
|
108
|
-
return "on" +
|
|
106
|
+
function qt(e, t = "", r = !1) {
|
|
107
|
+
const n = Ct[e], s = n && n[t] || t;
|
|
108
|
+
return "on" + yt(e) + yt(s) + (Xt(r, s) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
110
|
+
const Jt = ["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 = Jt.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 Zt(e, t = "") {
|
|
123
|
+
const r = Ct[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 Dt(e) {
|
|
130
130
|
return X(e) ? "touch" : "pointerType" in e ? e.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function te(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 ee(e) {
|
|
139
139
|
return e.type === "touchend" || e.type === "touchcancel" ? e.changedTouches : e.targetTouches;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return X(e) ?
|
|
141
|
+
function $t(e) {
|
|
142
|
+
return X(e) ? ee(e)[0] : e;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function re(e) {
|
|
145
|
+
return te(e).map((t) => t.identifier);
|
|
146
146
|
}
|
|
147
147
|
function rt(e) {
|
|
148
|
-
const t =
|
|
148
|
+
const t = $t(e);
|
|
149
149
|
return X(e) ? t.identifier : t.pointerId;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const t =
|
|
151
|
+
function bt(e) {
|
|
152
|
+
const t = $t(e);
|
|
153
153
|
return [t.clientX, t.clientY];
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function ne(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 ee(e) {
|
|
|
173
173
|
function H(e, ...t) {
|
|
174
174
|
return typeof e == "function" ? e(...t) : e;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function se() {
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return e.length === 0 ?
|
|
178
|
+
function ie(...e) {
|
|
179
|
+
return e.length === 0 ? se : 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 _t(e, t) {
|
|
187
187
|
return Object.assign({}, t, e || {});
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
class
|
|
189
|
+
const oe = 32;
|
|
190
|
+
class ae {
|
|
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,30 +244,30 @@ class ie {
|
|
|
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, ne(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
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
|
-
const [a, c] = r._movement, [f,
|
|
252
|
+
const [a, c] = r._movement, [f, h] = n.threshold, {
|
|
253
253
|
_step: u,
|
|
254
254
|
values: _
|
|
255
255
|
} = r;
|
|
256
|
-
if (n.hasCustomTransform ? (u[0] === !1 && (u[0] = Math.abs(a) >= f && _[0]), u[1] === !1 && (u[1] = Math.abs(c) >=
|
|
256
|
+
if (n.hasCustomTransform ? (u[0] === !1 && (u[0] = Math.abs(a) >= f && _[0]), u[1] === !1 && (u[1] = Math.abs(c) >= h && _[1])) : (u[0] === !1 && (u[0] = Math.abs(a) >= f && Math.sign(a) * f), u[1] === !1 && (u[1] = Math.abs(c) >= h && Math.sign(c) * h)), r.intentional = u[0] !== !1 || u[1] !== !1, !r.intentional) return;
|
|
257
257
|
const m = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
|
-
const [A,
|
|
260
|
-
m[0] = u[0] !== !1 ? A - u[0] : 0, m[1] = u[1] !== !1 ?
|
|
259
|
+
const [A, d] = _;
|
|
260
|
+
m[0] = u[0] !== !1 ? A - u[0] : 0, m[1] = u[1] !== !1 ? d - u[1] : 0;
|
|
261
261
|
} else
|
|
262
262
|
m[0] = u[0] !== !1 ? a - u[0] : 0, m[1] = u[1] !== !1 ? c - u[1] : 0;
|
|
263
263
|
this.restrictToAxis && !r._blocked && this.restrictToAxis(m);
|
|
264
|
-
const
|
|
264
|
+
const S = 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, x] = r.offset, [[w, M], [y,
|
|
267
|
-
r.overflow = [O < w ? -1 : O > M ? 1 : 0, x < y ? -1 : x >
|
|
266
|
+
const [O, x] = r.offset, [[w, M], [y, I]] = r._bounds;
|
|
267
|
+
r.overflow = [O < w ? -1 : O > M ? 1 : 0, x < y ? -1 : x > I ? 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
268
|
const L = r._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
-
if (r.offset =
|
|
270
|
-
r.delta = b.sub(r.offset,
|
|
269
|
+
if (r.offset = Wt(r._bounds, r.offset, L), r.delta = b.sub(r.offset, S), this.computeMovement(), D && (!r.last || o > oe)) {
|
|
270
|
+
r.delta = b.sub(r.offset, S);
|
|
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);
|
|
273
273
|
}
|
|
@@ -284,16 +284,16 @@ class ie {
|
|
|
284
284
|
this.eventStore.clean(), this.timeoutStore.clean();
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function ce([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 ue extends ae {
|
|
295
295
|
constructor(...t) {
|
|
296
|
-
super(...t),
|
|
296
|
+
super(...t), T(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
298
298
|
reset() {
|
|
299
299
|
super.reset(), this.state.axis = void 0;
|
|
@@ -310,8 +310,8 @@ class ae extends ie {
|
|
|
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[Dt(t)] : n.axisThreshold;
|
|
314
|
+
r.axis = ce(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 ae extends ie {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const xt = (e) => e, wt = 0.15, ot = {
|
|
331
331
|
enabled(e = !0) {
|
|
332
332
|
return e;
|
|
333
333
|
},
|
|
@@ -343,7 +343,7 @@ const bt = (e) => e, _t = 0.15, ot = {
|
|
|
343
343
|
rubberband(e = 0) {
|
|
344
344
|
switch (e) {
|
|
345
345
|
case !0:
|
|
346
|
-
return [
|
|
346
|
+
return [wt, wt];
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
@@ -357,13 +357,13 @@ const bt = (e) => e, _t = 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 || xt;
|
|
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 || xt;
|
|
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 le = 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 = le) {
|
|
396
396
|
return e;
|
|
397
397
|
},
|
|
398
398
|
bounds(e = {}) {
|
|
@@ -410,15 +410,15 @@ const ce = 0, K = p(p({}, ot), {}, {
|
|
|
410
410
|
} = e;
|
|
411
411
|
return [[t, r], [n, s]];
|
|
412
412
|
}
|
|
413
|
-
}),
|
|
413
|
+
}), Et = {
|
|
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 fe extends ue {
|
|
420
420
|
constructor(...t) {
|
|
421
|
-
super(...t),
|
|
421
|
+
super(...t), T(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
423
423
|
reset() {
|
|
424
424
|
super.reset();
|
|
@@ -453,7 +453,7 @@ class ue extends ae {
|
|
|
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(bt(t)), this.computeInitial(), r.preventScrollAxis && Dt(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 ue extends ae {
|
|
|
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 = bt(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;
|
|
@@ -498,10 +498,10 @@ class ue extends ae {
|
|
|
498
498
|
if (r.tap = o <= n.tapsThreshold && a <= n.tapsThreshold, r.tap && n.filterTaps)
|
|
499
499
|
r._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [c, f] = r._delta, [
|
|
501
|
+
const [c, f] = r._delta, [h, u] = r._movement, [_, m] = n.swipe.velocity, [S, D] = n.swipe.distance, O = n.swipe.duration;
|
|
502
502
|
if (r.elapsedTime < O) {
|
|
503
503
|
const x = Math.abs(c / r.timeDelta), w = Math.abs(f / r.timeDelta);
|
|
504
|
-
x > _ && Math.abs(
|
|
504
|
+
x > _ && Math.abs(h) > S && (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 ue extends ae {
|
|
|
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 r = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
|
533
533
|
passive: !1
|
|
534
534
|
});
|
|
@@ -540,14 +540,14 @@ class ue extends ae {
|
|
|
540
540
|
}, this.config.delay);
|
|
541
541
|
}
|
|
542
542
|
keyDown(t) {
|
|
543
|
-
const r =
|
|
543
|
+
const r = Et[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 Et && (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 ue extends ae {
|
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function de(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 Pt() {
|
|
565
565
|
return G && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
568
|
-
return
|
|
567
|
+
function he() {
|
|
568
|
+
return Pt() || G && window.navigator.maxTouchPoints > 1;
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function pe() {
|
|
571
571
|
return G && "onpointerdown" in window;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function me() {
|
|
574
574
|
return G && "exitPointerLock" in window.document;
|
|
575
575
|
}
|
|
576
|
-
function
|
|
576
|
+
function ge() {
|
|
577
577
|
try {
|
|
578
578
|
return "constructor" in GestureEvent;
|
|
579
579
|
} catch {
|
|
@@ -582,16 +582,16 @@ function pe() {
|
|
|
582
582
|
}
|
|
583
583
|
const P = {
|
|
584
584
|
isBrowser: G,
|
|
585
|
-
gesture:
|
|
586
|
-
touch:
|
|
587
|
-
touchscreen:
|
|
588
|
-
pointer:
|
|
589
|
-
pointerLock:
|
|
590
|
-
},
|
|
585
|
+
gesture: ge(),
|
|
586
|
+
touch: Pt(),
|
|
587
|
+
touchscreen: he(),
|
|
588
|
+
pointer: pe(),
|
|
589
|
+
pointerLock: me()
|
|
590
|
+
}, ve = 250, ye = 180, be = 0.5, _e = 50, xe = 250, we = 10, Tt = {
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
},
|
|
594
|
+
}, Ot = 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 ? ve : 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 = be,
|
|
629
|
+
distance: t = _e,
|
|
630
|
+
duration: r = xe
|
|
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 ye;
|
|
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({}, Tt), e) : Tt;
|
|
650
650
|
},
|
|
651
|
-
keyboardDisplacement(e =
|
|
651
|
+
keyboardDisplacement(e = we) {
|
|
652
652
|
return e;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
655
|
+
process.env.NODE_ENV === "development" && Object.assign(Ot, {
|
|
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 = _t(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 = _t(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 At = /* @__PURE__ */ new Map(), it = /* @__PURE__ */ new Map();
|
|
732
|
+
function Ee(e) {
|
|
733
|
+
At.set(e.key, e.engine), it.set(e.key, e.resolver);
|
|
734
734
|
}
|
|
735
|
-
const
|
|
735
|
+
const Te = {
|
|
736
736
|
key: "drag",
|
|
737
|
-
engine:
|
|
738
|
-
resolver:
|
|
737
|
+
engine: fe,
|
|
738
|
+
resolver: Ot
|
|
739
739
|
};
|
|
740
|
-
function
|
|
740
|
+
function Se(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 Ie(e, t) {
|
|
748
748
|
if (e == null) return {};
|
|
749
|
-
var r =
|
|
749
|
+
var r = Se(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 Te(e, t) {
|
|
|
754
754
|
}
|
|
755
755
|
return r;
|
|
756
756
|
}
|
|
757
|
-
const
|
|
757
|
+
const ke = {
|
|
758
758
|
target(e) {
|
|
759
759
|
if (e)
|
|
760
760
|
return () => "current" in e ? e.current : e;
|
|
@@ -777,7 +777,7 @@ const Se = {
|
|
|
777
777
|
transform(e) {
|
|
778
778
|
return e;
|
|
779
779
|
}
|
|
780
|
-
},
|
|
780
|
+
}, Ce = ["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,32 +798,32 @@ function F(e = {}, t) {
|
|
|
798
798
|
}
|
|
799
799
|
return r;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function De(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,
|
|
808
|
+
} = n, h = Ie(n, Ce);
|
|
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
|
+
}, ke), t) {
|
|
816
816
|
const u = it.get(t);
|
|
817
817
|
r[t] = F(p({
|
|
818
818
|
shared: r.shared
|
|
819
|
-
},
|
|
819
|
+
}, h), u);
|
|
820
820
|
} else
|
|
821
|
-
for (const u in
|
|
821
|
+
for (const u in h) {
|
|
822
822
|
const _ = it.get(u);
|
|
823
823
|
if (_)
|
|
824
824
|
r[u] = F(p({
|
|
825
825
|
shared: r.shared
|
|
826
|
-
},
|
|
826
|
+
}, h[u]), _);
|
|
827
827
|
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(u)) {
|
|
828
828
|
if (u === "domTarget")
|
|
829
829
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -832,15 +832,15 @@ function ke(e, t, r = {}) {
|
|
|
832
832
|
}
|
|
833
833
|
return r;
|
|
834
834
|
}
|
|
835
|
-
class
|
|
835
|
+
class Nt {
|
|
836
836
|
constructor(t, r) {
|
|
837
|
-
|
|
837
|
+
T(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = r;
|
|
838
838
|
}
|
|
839
839
|
add(t, r, n, s, o) {
|
|
840
|
-
const a = this._listeners, c =
|
|
841
|
-
t.addEventListener(c, s,
|
|
840
|
+
const a = this._listeners, c = Zt(r, n), f = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, h = p(p({}, f), o);
|
|
841
|
+
t.addEventListener(c, s, h);
|
|
842
842
|
const u = () => {
|
|
843
|
-
t.removeEventListener(c, s,
|
|
843
|
+
t.removeEventListener(c, s, h), a.delete(u);
|
|
844
844
|
};
|
|
845
845
|
return a.add(u), u;
|
|
846
846
|
}
|
|
@@ -848,9 +848,9 @@ class Ot {
|
|
|
848
848
|
this._listeners.forEach((t) => t()), this._listeners.clear();
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
class
|
|
851
|
+
class $e {
|
|
852
852
|
constructor() {
|
|
853
|
-
|
|
853
|
+
T(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
855
855
|
add(t, r, n = 140, ...s) {
|
|
856
856
|
this.remove(t), this._timeouts.set(t, window.setTimeout(r, n, ...s));
|
|
@@ -863,20 +863,20 @@ class Ce {
|
|
|
863
863
|
this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
class
|
|
866
|
+
class Pe {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
|
|
868
|
+
T(this, "gestures", /* @__PURE__ */ new Set()), T(this, "_targetEventStore", new Nt(this)), T(this, "gestureEventStores", {}), T(this, "gestureTimeoutStores", {}), T(this, "handlers", {}), T(this, "config", {}), T(this, "pointerIds", /* @__PURE__ */ new Set()), T(this, "touchIds", /* @__PURE__ */ new Set()), T(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
|
+
}), Oe(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(re(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 De {
|
|
|
884
884
|
this.handlers = t, this.nativeHandlers = r;
|
|
885
885
|
}
|
|
886
886
|
applyConfig(t, r) {
|
|
887
|
-
this.config =
|
|
887
|
+
this.config = De(t, r, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -900,13 +900,13 @@ class De {
|
|
|
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 = St(n, c.eventOptions, !!s);
|
|
904
904
|
if (c.enabled) {
|
|
905
|
-
const
|
|
906
|
-
new
|
|
905
|
+
const h = At.get(a);
|
|
906
|
+
new h(this, t, a).bind(f);
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
const o =
|
|
909
|
+
const o = St(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 De {
|
|
|
914
914
|
})), void 0, !0);
|
|
915
915
|
}
|
|
916
916
|
for (const o in n)
|
|
917
|
-
n[o] =
|
|
917
|
+
n[o] = ie(...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 De {
|
|
|
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 Nt(e, t), e.gestureTimeoutStores[t] = new $e();
|
|
935
935
|
}
|
|
936
|
-
function
|
|
936
|
+
function Oe(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
|
|
940
|
-
var f,
|
|
941
|
-
const u = (f = a.capture) !== null && f !== void 0 ? f : t.capture, _ = (
|
|
942
|
-
let m = c ? n :
|
|
939
|
+
const St = (e, t, r) => (n, s, o, a = {}, c = !1) => {
|
|
940
|
+
var f, h;
|
|
941
|
+
const u = (f = a.capture) !== null && f !== void 0 ? f : t.capture, _ = (h = a.passive) !== null && h !== void 0 ? h : t.passive;
|
|
942
|
+
let m = c ? n : qt(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 Ae(e, t = {}, r, n) {
|
|
946
|
+
const s = et.useMemo(() => new Pe(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 Ne(e, t) {
|
|
951
|
+
return Ee(Te), Ae({
|
|
952
952
|
drag: e
|
|
953
953
|
}, t || {}, "drag");
|
|
954
954
|
}
|
|
955
955
|
const nt = "RSC::Event";
|
|
956
|
-
function
|
|
956
|
+
function Le() {
|
|
957
957
|
const e = $(null);
|
|
958
958
|
function t(n) {
|
|
959
959
|
U(() => {
|
|
@@ -985,11 +985,11 @@ function Ae() {
|
|
|
985
985
|
emitEvent: r
|
|
986
986
|
};
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function Me(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 Ke({
|
|
993
993
|
init: e = !0,
|
|
994
994
|
items: t,
|
|
995
995
|
withLoop: r = !1,
|
|
@@ -999,13 +999,13 @@ function Be({
|
|
|
999
999
|
carouselAxis: a = "x",
|
|
1000
1000
|
startingPosition: c = "start",
|
|
1001
1001
|
enableGestures: f = !0,
|
|
1002
|
-
slideWhenDragThresholdIsReached:
|
|
1002
|
+
slideWhenDragThresholdIsReached: h = !0,
|
|
1003
1003
|
onInit: u,
|
|
1004
1004
|
slideType: _ = "item",
|
|
1005
1005
|
initialActiveItem: m = 0
|
|
1006
1006
|
}) {
|
|
1007
|
-
const [
|
|
1008
|
-
function
|
|
1007
|
+
const [S, D] = Gt(!1), O = $(e), x = $(null), w = $(null), M = $(0), y = $(0), I = $(!r), L = $(!1), A = $(0), d = $(0);
|
|
1008
|
+
function Lt(i) {
|
|
1009
1009
|
if (i === void 0) return 0;
|
|
1010
1010
|
if (typeof i == "number")
|
|
1011
1011
|
return t[i] ? i : (console.warn(
|
|
@@ -1014,14 +1014,14 @@ function Be({
|
|
|
1014
1014
|
const l = t.findIndex((g) => g.id === i);
|
|
1015
1015
|
return l < 0 ? (console.warn(`initialActiveItem: item with id "${i}" doesn't exist.`), 0) : l;
|
|
1016
1016
|
}
|
|
1017
|
-
const z =
|
|
1017
|
+
const z = Kt(), q = kt({
|
|
1018
1018
|
value: 0,
|
|
1019
1019
|
ref: z,
|
|
1020
1020
|
onChange({ value: i }) {
|
|
1021
1021
|
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)`;
|
|
1022
1022
|
w.current.style.transform = l;
|
|
1023
1023
|
}
|
|
1024
|
-
}),
|
|
1024
|
+
}), at = r ? [
|
|
1025
1025
|
...t.map((i) => ({
|
|
1026
1026
|
...i,
|
|
1027
1027
|
id: `prev-repeated-item-${i.id}`,
|
|
@@ -1033,12 +1033,12 @@ function Be({
|
|
|
1033
1033
|
id: `next-repeated-item-${i.id}`,
|
|
1034
1034
|
isClonedItem: !0
|
|
1035
1035
|
}))
|
|
1036
|
-
] : t, { useListenToCustomEvent:
|
|
1037
|
-
function
|
|
1038
|
-
const { totalGutterCssVar: i } =
|
|
1036
|
+
] : t, { useListenToCustomEvent: ct, emitEvent: W } = Le();
|
|
1037
|
+
function ut() {
|
|
1038
|
+
const { totalGutterCssVar: i } = lt();
|
|
1039
1039
|
return i;
|
|
1040
1040
|
}
|
|
1041
|
-
function
|
|
1041
|
+
function Mt() {
|
|
1042
1042
|
if (x.current) {
|
|
1043
1043
|
const l = window.getComputedStyle(
|
|
1044
1044
|
x.current
|
|
@@ -1055,7 +1055,7 @@ function Be({
|
|
|
1055
1055
|
}));
|
|
1056
1056
|
}
|
|
1057
1057
|
function Q(i) {
|
|
1058
|
-
O.current && (
|
|
1058
|
+
O.current && (I.current || R({
|
|
1059
1059
|
type: "prev",
|
|
1060
1060
|
toIndex: i,
|
|
1061
1061
|
actionType: "click"
|
|
@@ -1065,42 +1065,44 @@ function Be({
|
|
|
1065
1065
|
type: i,
|
|
1066
1066
|
shouldAnimate: l = !0,
|
|
1067
1067
|
toIndex: g,
|
|
1068
|
-
actionType:
|
|
1068
|
+
actionType: k
|
|
1069
1069
|
}) {
|
|
1070
|
-
var
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1070
|
+
var dt, ht;
|
|
1071
|
+
const E = !l;
|
|
1072
|
+
I.current = !1, L.current = !1;
|
|
1073
1073
|
let v = q.value.get(), C = 0;
|
|
1074
|
-
if (i === "next" && (
|
|
1074
|
+
if (i === "next" && (d.current += 1), i === "prev" && (d.current === 0 ? d.current = t.length - 1 : d.current -= 1), g !== void 0 && (d.current = g), i === "next") {
|
|
1075
1075
|
const V = Z(
|
|
1076
1076
|
r ? y.current * (t.length * 2) : 0
|
|
1077
1077
|
);
|
|
1078
|
-
C = -(
|
|
1078
|
+
C = -(d.current * y.current), r && d.current === t.length && (d.current = 0, v = v + y.current * t.length, C = 0), !r && (Math.abs(C) >= V || d.current === t.length - 1) && (L.current = !0, C = -V);
|
|
1079
1079
|
}
|
|
1080
|
-
i === "prev" && (C = -(
|
|
1081
|
-
const N = r ?
|
|
1082
|
-
|
|
1080
|
+
i === "prev" && (C = -(d.current * y.current), d.current === t.length - 1 && (v = v - t.length * y.current), !r && C >= 0 && (I.current = !0, C = 0)), M.current = C;
|
|
1081
|
+
const N = r ? d.current % t.length : d.current, j = r ? t.length + d.current % t.length : d.current;
|
|
1082
|
+
k === "resize" ? (C = -(d.current * y.current), W({
|
|
1083
1083
|
eventName: "onResize",
|
|
1084
|
-
sliceActionType:
|
|
1084
|
+
sliceActionType: k,
|
|
1085
1085
|
slideDirection: i,
|
|
1086
1086
|
currentItem: {
|
|
1087
1087
|
index: N,
|
|
1088
|
-
id: ((
|
|
1089
|
-
|
|
1088
|
+
id: ((dt = t.at(N)) == null ? void 0 : dt.id) ?? "",
|
|
1089
|
+
trackIndex: j,
|
|
1090
|
+
startReached: I.current,
|
|
1090
1091
|
endReached: L.current
|
|
1091
1092
|
}
|
|
1092
1093
|
})) : W({
|
|
1093
1094
|
eventName: "onSlideStartChange",
|
|
1094
|
-
sliceActionType:
|
|
1095
|
+
sliceActionType: k,
|
|
1095
1096
|
slideDirection: i,
|
|
1096
1097
|
nextItem: {
|
|
1097
1098
|
index: N,
|
|
1098
|
-
id: ((
|
|
1099
|
-
|
|
1099
|
+
id: ((ht = t.at(N)) == null ? void 0 : ht.id) ?? "",
|
|
1100
|
+
trackIndex: j,
|
|
1101
|
+
startReached: I.current,
|
|
1100
1102
|
endReached: L.current
|
|
1101
1103
|
}
|
|
1102
1104
|
}), z.start({
|
|
1103
|
-
immediate:
|
|
1105
|
+
immediate: E,
|
|
1104
1106
|
from: {
|
|
1105
1107
|
value: v
|
|
1106
1108
|
},
|
|
@@ -1114,15 +1116,16 @@ function Be({
|
|
|
1114
1116
|
onRest({ finished: V }) {
|
|
1115
1117
|
var Y;
|
|
1116
1118
|
if (V) {
|
|
1117
|
-
const
|
|
1119
|
+
const pt = r ? d.current % t.length : d.current, Bt = r ? t.length + d.current % t.length : d.current;
|
|
1118
1120
|
W({
|
|
1119
1121
|
eventName: "onSlideChangeComplete",
|
|
1120
|
-
sliceActionType:
|
|
1122
|
+
sliceActionType: k,
|
|
1121
1123
|
slideDirection: i,
|
|
1122
1124
|
currentItem: {
|
|
1123
|
-
index:
|
|
1124
|
-
id: ((Y = t.at(
|
|
1125
|
-
|
|
1125
|
+
index: pt,
|
|
1126
|
+
id: ((Y = t.at(pt)) == null ? void 0 : Y.id) ?? "",
|
|
1127
|
+
trackIndex: Bt,
|
|
1128
|
+
startReached: I.current,
|
|
1126
1129
|
endReached: L.current
|
|
1127
1130
|
}
|
|
1128
1131
|
});
|
|
@@ -1130,33 +1133,33 @@ function Be({
|
|
|
1130
1133
|
}
|
|
1131
1134
|
});
|
|
1132
1135
|
}
|
|
1133
|
-
function
|
|
1136
|
+
function Vt() {
|
|
1134
1137
|
const i = w.current;
|
|
1135
1138
|
let l = 0;
|
|
1136
|
-
return _ === "item" ? l = i.children[0].getBoundingClientRect()[a === "x" ? "width" : "height"] +
|
|
1139
|
+
return _ === "item" ? l = i.children[0].getBoundingClientRect()[a === "x" ? "width" : "height"] + ut() : l = i.getBoundingClientRect()[a === "x" ? "width" : "height"] + ut(), l;
|
|
1137
1140
|
}
|
|
1138
1141
|
function Z(i) {
|
|
1139
1142
|
const l = w.current;
|
|
1140
1143
|
return l[a === "x" ? "scrollWidth" : "scrollHeight"] - l.getBoundingClientRect()[a === "x" ? "width" : "height"] - i;
|
|
1141
1144
|
}
|
|
1142
|
-
function
|
|
1145
|
+
function lt() {
|
|
1143
1146
|
let i = 0, l = 0;
|
|
1144
1147
|
if (x.current) {
|
|
1145
1148
|
const g = window.getComputedStyle(
|
|
1146
1149
|
x.current
|
|
1147
|
-
),
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
+
), k = g.getPropertyValue(`--${n}-start-end-gutter`).trim();
|
|
1151
|
+
k.includes("px") && (i = Number(
|
|
1152
|
+
k.replace("px", "")
|
|
1150
1153
|
));
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1154
|
+
const E = g.getPropertyValue(`--${n}-gutter`).trim();
|
|
1155
|
+
E.includes("px") && (l = Number(E.replace("px", "")));
|
|
1153
1156
|
}
|
|
1154
1157
|
return { totalStartEndGutterCssVar: i, totalGutterCssVar: l };
|
|
1155
1158
|
}
|
|
1156
1159
|
U(() => {
|
|
1157
|
-
function i(
|
|
1158
|
-
const v =
|
|
1159
|
-
switch (
|
|
1160
|
+
function i(E) {
|
|
1161
|
+
const v = Mt();
|
|
1162
|
+
switch (E) {
|
|
1160
1163
|
case "start":
|
|
1161
1164
|
return 0;
|
|
1162
1165
|
case "middle-start":
|
|
@@ -1172,43 +1175,43 @@ function Be({
|
|
|
1172
1175
|
}
|
|
1173
1176
|
}
|
|
1174
1177
|
function l() {
|
|
1175
|
-
y.current =
|
|
1176
|
-
const { totalStartEndGutterCssVar:
|
|
1178
|
+
y.current = Vt(), A.current = y.current / 4;
|
|
1179
|
+
const { totalStartEndGutterCssVar: E } = lt();
|
|
1177
1180
|
let v = 0;
|
|
1178
|
-
r && (v = y.current * t.length), v -= y.current * i(c), v -=
|
|
1181
|
+
r && (v = y.current * t.length), v -= y.current * i(c), v -= E / 2, x.current.style.setProperty(
|
|
1179
1182
|
`--${n}-offset-modifier`,
|
|
1180
1183
|
`${-v}px`
|
|
1181
1184
|
);
|
|
1182
1185
|
}
|
|
1183
|
-
function g(
|
|
1184
|
-
x.current && (l(), D(!0),
|
|
1186
|
+
function g(E) {
|
|
1187
|
+
x.current && (l(), D(!0), E && E());
|
|
1185
1188
|
}
|
|
1186
|
-
function
|
|
1189
|
+
function k() {
|
|
1187
1190
|
g(), R({
|
|
1188
1191
|
type: "resize",
|
|
1189
|
-
toIndex:
|
|
1192
|
+
toIndex: d.current,
|
|
1190
1193
|
shouldAnimate: !1,
|
|
1191
1194
|
actionType: "resize"
|
|
1192
1195
|
});
|
|
1193
1196
|
}
|
|
1194
1197
|
if (e)
|
|
1195
|
-
return O.current = !0, g(u), window.addEventListener("resize",
|
|
1196
|
-
window.removeEventListener("resize",
|
|
1198
|
+
return O.current = !0, g(u), window.addEventListener("resize", k), () => {
|
|
1199
|
+
window.removeEventListener("resize", k);
|
|
1197
1200
|
};
|
|
1198
1201
|
}, [e, r, n, a, s, c]), U(() => {
|
|
1199
|
-
const i =
|
|
1200
|
-
e && i !==
|
|
1202
|
+
const i = Lt(m);
|
|
1203
|
+
e && i !== d.current && R({
|
|
1201
1204
|
type: "next",
|
|
1202
1205
|
toIndex: i,
|
|
1203
1206
|
actionType: "resize",
|
|
1204
1207
|
shouldAnimate: !1
|
|
1205
1208
|
});
|
|
1206
1209
|
}, [e, m]);
|
|
1207
|
-
const
|
|
1210
|
+
const ft = f, Rt = Ne(
|
|
1208
1211
|
(i) => {
|
|
1209
1212
|
if (!O.current)
|
|
1210
1213
|
return;
|
|
1211
|
-
const l = i.dragging, g = i.offset[a === "x" ? 0 : 1],
|
|
1214
|
+
const l = i.dragging, g = i.offset[a === "x" ? 0 : 1], k = i.movement[a === "x" ? 0 : 1], E = k > A.current, v = k < -A.current, C = i.velocity;
|
|
1212
1215
|
l && (W({
|
|
1213
1216
|
...i,
|
|
1214
1217
|
eventName: "onDrag",
|
|
@@ -1223,7 +1226,7 @@ function Be({
|
|
|
1223
1226
|
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)`;
|
|
1224
1227
|
w.current.style.transform = j;
|
|
1225
1228
|
}
|
|
1226
|
-
}),
|
|
1229
|
+
}), h && (E || v) && i.cancel()), i.last && (E ? (R({
|
|
1227
1230
|
actionType: "drag",
|
|
1228
1231
|
type: "prev"
|
|
1229
1232
|
}), i.cancel()) : v ? (R({
|
|
@@ -1241,7 +1244,7 @@ function Be({
|
|
|
1241
1244
|
}), i.cancel()));
|
|
1242
1245
|
},
|
|
1243
1246
|
{
|
|
1244
|
-
enabled:
|
|
1247
|
+
enabled: ft,
|
|
1245
1248
|
axis: a,
|
|
1246
1249
|
rubberband: !r,
|
|
1247
1250
|
...r ? {} : {
|
|
@@ -1255,25 +1258,26 @@ function Be({
|
|
|
1255
1258
|
from: () => [q.value.get(), q.value.get()]
|
|
1256
1259
|
}
|
|
1257
1260
|
);
|
|
1258
|
-
function
|
|
1259
|
-
var
|
|
1260
|
-
|
|
1261
|
+
function jt(i) {
|
|
1262
|
+
var g;
|
|
1263
|
+
const l = r ? t.length + d.current % t.length : d.current;
|
|
1264
|
+
return typeof i == "number" ? l === i : i === ((g = at[l]) == null ? void 0 : g.id);
|
|
1261
1265
|
}
|
|
1262
1266
|
return {
|
|
1263
|
-
carouselFragment: /* @__PURE__ */
|
|
1267
|
+
carouselFragment: /* @__PURE__ */ Ut(
|
|
1264
1268
|
"div",
|
|
1265
1269
|
{
|
|
1266
1270
|
ref: x,
|
|
1267
1271
|
className: "ReactSpringCarouselContainer",
|
|
1268
1272
|
"data-part": "Container",
|
|
1269
1273
|
"data-part-internal": `${n}-Container`,
|
|
1270
|
-
...
|
|
1274
|
+
...Rt(),
|
|
1271
1275
|
children: [
|
|
1272
1276
|
/* @__PURE__ */ tt(
|
|
1273
1277
|
"style",
|
|
1274
1278
|
{
|
|
1275
1279
|
dangerouslySetInnerHTML: {
|
|
1276
|
-
__html:
|
|
1280
|
+
__html: Me(`
|
|
1277
1281
|
[data-part-internal="${n}-Container"] {
|
|
1278
1282
|
display: flex;
|
|
1279
1283
|
width: 100%;
|
|
@@ -1286,14 +1290,14 @@ function Be({
|
|
|
1286
1290
|
--${n}-scroll-y-value: ${a === "y" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
|
|
1287
1291
|
--${n}-gutter: 0px;
|
|
1288
1292
|
--${n}-start-end-gutter: 0px;
|
|
1289
|
-
touch-action: ${
|
|
1293
|
+
touch-action: ${ft ? a === "x" ? "pan-y" : "pan-x" : "auto"};
|
|
1290
1294
|
}
|
|
1291
1295
|
[data-part-internal="${n}-Track"] {
|
|
1292
1296
|
display: flex;
|
|
1293
1297
|
position: relative;
|
|
1294
1298
|
--initial-offset-modifier: calc(calc(-100% - var(--${n}-gutter) + calc(var(--${n}-start-end-gutter) / 2 / ${t.length} * var(--${n}-items-per-slide)) + var(--${n}-start-end-gutter)) * ${t.length} / var(--${n}-items-per-slide));
|
|
1295
|
-
left: ${r && a === "x" && !
|
|
1296
|
-
top: ${r && a === "y" && !
|
|
1299
|
+
left: ${r && a === "x" && !S ? "var(--initial-offset-modifier)" : "0px"};
|
|
1300
|
+
top: ${r && a === "y" && !S ? "var(--initial-offset-modifier)" : "0px"};
|
|
1297
1301
|
flex-direction: ${a === "x" ? "row" : "column"};
|
|
1298
1302
|
width: 100%;
|
|
1299
1303
|
height: 100%;
|
|
@@ -1335,9 +1339,9 @@ function Be({
|
|
|
1335
1339
|
"data-part": "Track",
|
|
1336
1340
|
"data-part-internal": `${n}-Track`,
|
|
1337
1341
|
onScroll: () => {
|
|
1338
|
-
|
|
1342
|
+
I.current = !1, L.current = !1;
|
|
1339
1343
|
},
|
|
1340
|
-
children:
|
|
1344
|
+
children: at.map((i, l) => /* @__PURE__ */ tt(
|
|
1341
1345
|
"div",
|
|
1342
1346
|
{
|
|
1343
1347
|
className: "ReactSpringCarouselItem",
|
|
@@ -1345,10 +1349,10 @@ function Be({
|
|
|
1345
1349
|
"data-part-internal": `${n}-Item`,
|
|
1346
1350
|
"data-id": i.id,
|
|
1347
1351
|
children: typeof i.renderItem == "function" ? i.renderItem({
|
|
1348
|
-
useListenToCustomEvent:
|
|
1349
|
-
index:
|
|
1352
|
+
useListenToCustomEvent: ct,
|
|
1353
|
+
index: l,
|
|
1350
1354
|
isClonedItem: !!i.isClonedItem,
|
|
1351
|
-
isActiveItem:
|
|
1355
|
+
isActiveItem: jt
|
|
1352
1356
|
}) : i.renderItem
|
|
1353
1357
|
},
|
|
1354
1358
|
`${i.id}-${l}`
|
|
@@ -1358,7 +1362,7 @@ function Be({
|
|
|
1358
1362
|
]
|
|
1359
1363
|
}
|
|
1360
1364
|
),
|
|
1361
|
-
useListenToCustomEvent:
|
|
1365
|
+
useListenToCustomEvent: ct,
|
|
1362
1366
|
slideToNextItem: () => J(),
|
|
1363
1367
|
slideToPrevItem: () => Q(),
|
|
1364
1368
|
slideToItem: (i) => {
|
|
@@ -1369,7 +1373,7 @@ function Be({
|
|
|
1369
1373
|
);
|
|
1370
1374
|
return;
|
|
1371
1375
|
}
|
|
1372
|
-
i >
|
|
1376
|
+
i > d.current ? J(i) : Q(i);
|
|
1373
1377
|
}
|
|
1374
1378
|
if (typeof i == "string") {
|
|
1375
1379
|
const l = t.findIndex((g) => g.id === i);
|
|
@@ -1379,25 +1383,25 @@ function Be({
|
|
|
1379
1383
|
);
|
|
1380
1384
|
return;
|
|
1381
1385
|
}
|
|
1382
|
-
l >
|
|
1386
|
+
l > d.current ? J(l) : Q(l);
|
|
1383
1387
|
}
|
|
1384
1388
|
}
|
|
1385
1389
|
};
|
|
1386
1390
|
}
|
|
1387
|
-
function
|
|
1391
|
+
function Ve(e) {
|
|
1388
1392
|
let t = 0;
|
|
1389
1393
|
const r = getComputedStyle(e).getPropertyValue("gap");
|
|
1390
1394
|
return r.includes("px") && (t = Number(r.replace("px", ""))), t;
|
|
1391
1395
|
}
|
|
1392
|
-
function
|
|
1396
|
+
function It(e) {
|
|
1393
1397
|
return e.scrollWidth - e.clientWidth;
|
|
1394
1398
|
}
|
|
1395
1399
|
function st(e) {
|
|
1396
|
-
const t = e.children[0], r =
|
|
1400
|
+
const t = e.children[0], r = Ve(e);
|
|
1397
1401
|
return t.getBoundingClientRect().width + r;
|
|
1398
1402
|
}
|
|
1399
|
-
function
|
|
1400
|
-
const r = $("start"), n = $(0), [, s] =
|
|
1403
|
+
function Ge({ container: e, onReach: t }) {
|
|
1404
|
+
const r = $("start"), n = $(0), [, s] = kt(() => ({
|
|
1401
1405
|
x: 0
|
|
1402
1406
|
}));
|
|
1403
1407
|
function o(c) {
|
|
@@ -1418,18 +1422,18 @@ function Ue({ container: e, onReach: t }) {
|
|
|
1418
1422
|
return;
|
|
1419
1423
|
let f = 0;
|
|
1420
1424
|
if (c === "next" && (n.current += 1), c === "prev" && (n.current -= 1), f = n.current * st(e.current), c === "next") {
|
|
1421
|
-
const
|
|
1422
|
-
f >
|
|
1425
|
+
const h = It(e.current);
|
|
1426
|
+
f > h && (r.current = "end", f = h, t && t("end"));
|
|
1423
1427
|
}
|
|
1424
1428
|
c === "prev" && f <= 0 && (r.current = "start", n.current = 0, f = 0, t && t("start")), o(f);
|
|
1425
1429
|
}
|
|
1426
1430
|
return U(() => {
|
|
1427
1431
|
function c() {
|
|
1428
1432
|
var M;
|
|
1429
|
-
const
|
|
1430
|
-
index:
|
|
1431
|
-
start:
|
|
1432
|
-
end:
|
|
1433
|
+
const S = st(e.current), D = ((M = [...e.current.children].at(0)) == null ? void 0 : M.getBoundingClientRect().width) || 0, O = Array(e.current.childElementCount).fill(0).map((y, I) => ({
|
|
1434
|
+
index: I,
|
|
1435
|
+
start: S * I,
|
|
1436
|
+
end: S * (I + 1)
|
|
1433
1437
|
})), x = e.current.scrollLeft + D, w = O.find(
|
|
1434
1438
|
(y) => x >= y.start && x < y.end
|
|
1435
1439
|
);
|
|
@@ -1438,9 +1442,9 @@ function Ue({ container: e, onReach: t }) {
|
|
|
1438
1442
|
function f() {
|
|
1439
1443
|
s.stop();
|
|
1440
1444
|
}
|
|
1441
|
-
function
|
|
1442
|
-
const D =
|
|
1443
|
-
D.scrollLeft === 0 ? (n.current = 0, r.current = "start", t && t("start")) : D.scrollLeft >=
|
|
1445
|
+
function h(S) {
|
|
1446
|
+
const D = S.target;
|
|
1447
|
+
D.scrollLeft === 0 ? (n.current = 0, r.current = "start", t && t("start")) : D.scrollLeft >= It(D) ? (r.current = "end", t && t("end")) : r.current !== "idle" && (r.current = "idle", t && t("idle"));
|
|
1444
1448
|
}
|
|
1445
1449
|
let u, _ = 0;
|
|
1446
1450
|
function m() {
|
|
@@ -1451,8 +1455,8 @@ function Ue({ container: e, onReach: t }) {
|
|
|
1451
1455
|
if (e.current)
|
|
1452
1456
|
return e.current.addEventListener("wheel", f, {
|
|
1453
1457
|
passive: !0
|
|
1454
|
-
}), e.current.addEventListener("scroll",
|
|
1455
|
-
e.current && (e.current.removeEventListener("scroll", m), e.current.removeEventListener("scroll",
|
|
1458
|
+
}), e.current.addEventListener("scroll", h), e.current.addEventListener("scroll", m), () => {
|
|
1459
|
+
e.current && (e.current.removeEventListener("scroll", m), e.current.removeEventListener("scroll", h), e.current.removeEventListener("wheel", f));
|
|
1456
1460
|
};
|
|
1457
1461
|
}, [e, t]), U(() => {
|
|
1458
1462
|
if (e.current) {
|
|
@@ -1473,6 +1477,6 @@ function Ue({ container: e, onReach: t }) {
|
|
|
1473
1477
|
};
|
|
1474
1478
|
}
|
|
1475
1479
|
export {
|
|
1476
|
-
|
|
1477
|
-
|
|
1480
|
+
Ke as useSpringCarousel,
|
|
1481
|
+
Ge as useSpringScroll
|
|
1478
1482
|
};
|