react-spring-carousel 3.0.0-beta-2.0.183 → 3.0.0-beta-2.0.184
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 +278 -276
- package/dist/index.umd.js +4 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import
|
|
4
|
-
function
|
|
1
|
+
import { jsxs as It, jsx as J } from "react/jsx-runtime";
|
|
2
|
+
import { useSpring as Dt } from "@react-spring/web";
|
|
3
|
+
import Q, { useRef as A, useEffect as mt, useState as kt } from "react";
|
|
4
|
+
function Ct(r, t, e) {
|
|
5
5
|
return Math.max(t, Math.min(r, e));
|
|
6
6
|
}
|
|
7
7
|
const g = {
|
|
@@ -21,17 +21,17 @@ const g = {
|
|
|
21
21
|
r[0] -= t[0], r[1] -= t[1];
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function st(r, t, e) {
|
|
25
25
|
return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(r, e * 5) : r * t * e / (t + e * r);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return n === 0 ?
|
|
27
|
+
function it(r, t, e, n = 0.15) {
|
|
28
|
+
return n === 0 ? Ct(r, t, e) : r < t ? -st(t - r, e - t, n) + t : r > e ? +st(r - e, e - t, n) + e : r;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Ot(r, [t, e], [n, s]) {
|
|
31
31
|
const [[i, c], [a, u]] = r;
|
|
32
|
-
return [
|
|
32
|
+
return [it(t, i, c, n), it(e, a, u, s)];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function At(r, t) {
|
|
35
35
|
if (typeof r != "object" || r === null) return r;
|
|
36
36
|
var e = r[Symbol.toPrimitive];
|
|
37
37
|
if (e !== void 0) {
|
|
@@ -41,19 +41,19 @@ function kt(r, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return (t === "string" ? String : Number)(r);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
var t =
|
|
44
|
+
function Pt(r) {
|
|
45
|
+
var t = At(r, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
48
|
function y(r, t, e) {
|
|
49
|
-
return t =
|
|
49
|
+
return t = Pt(t), t in r ? Object.defineProperty(r, t, {
|
|
50
50
|
value: e,
|
|
51
51
|
enumerable: !0,
|
|
52
52
|
configurable: !0,
|
|
53
53
|
writable: !0
|
|
54
54
|
}) : r[t] = e, r;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function ot(r, t) {
|
|
57
57
|
var e = Object.keys(r);
|
|
58
58
|
if (Object.getOwnPropertySymbols) {
|
|
59
59
|
var n = Object.getOwnPropertySymbols(r);
|
|
@@ -63,18 +63,18 @@ function it(r, t) {
|
|
|
63
63
|
}
|
|
64
64
|
return e;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function h(r) {
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var e = arguments[t] != null ? arguments[t] : {};
|
|
69
|
-
t % 2 ?
|
|
69
|
+
t % 2 ? ot(Object(e), !0).forEach(function(n) {
|
|
70
70
|
y(r, n, e[n]);
|
|
71
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) :
|
|
71
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : ot(Object(e)).forEach(function(n) {
|
|
72
72
|
Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
return r;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const gt = {
|
|
78
78
|
pointer: {
|
|
79
79
|
start: "down",
|
|
80
80
|
change: "move",
|
|
@@ -96,63 +96,63 @@ const mt = {
|
|
|
96
96
|
end: "end"
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
function
|
|
99
|
+
function at(r) {
|
|
100
100
|
return r ? r[0].toUpperCase() + r.slice(1) : "";
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
104
|
-
return r &&
|
|
102
|
+
const $t = ["enter", "leave"];
|
|
103
|
+
function Nt(r = !1, t) {
|
|
104
|
+
return r && !$t.includes(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
const n =
|
|
108
|
-
return "on" +
|
|
106
|
+
function Mt(r, t = "", e = !1) {
|
|
107
|
+
const n = gt[r], s = n && n[t] || t;
|
|
108
|
+
return "on" + at(r) + at(s) + (Nt(e, s) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
110
|
+
const Rt = ["gotpointercapture", "lostpointercapture"];
|
|
111
|
+
function Lt(r) {
|
|
112
112
|
let t = r.substring(2).toLowerCase();
|
|
113
113
|
const e = !!~t.indexOf("passive");
|
|
114
114
|
e && (t = t.replace("passive", ""));
|
|
115
|
-
const n =
|
|
115
|
+
const n = Rt.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: e
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
const e =
|
|
122
|
+
function Vt(r, t = "") {
|
|
123
|
+
const e = gt[r], n = e && e[t] || t;
|
|
124
124
|
return r + n;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function F(r) {
|
|
127
127
|
return "touches" in r;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
return
|
|
129
|
+
function vt(r) {
|
|
130
|
+
return F(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function jt(r) {
|
|
133
133
|
return Array.from(r.touches).filter((t) => {
|
|
134
134
|
var e, n;
|
|
135
135
|
return t.target === r.currentTarget || ((e = r.currentTarget) === null || e === void 0 || (n = e.contains) === null || n === void 0 ? void 0 : n.call(e, t.target));
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Ut(r) {
|
|
139
139
|
return r.type === "touchend" || r.type === "touchcancel" ? r.changedTouches : r.targetTouches;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return
|
|
141
|
+
function yt(r) {
|
|
142
|
+
return F(r) ? Ut(r)[0] : r;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function Kt(r) {
|
|
145
|
+
return jt(r).map((t) => t.identifier);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
const t =
|
|
149
|
-
return
|
|
147
|
+
function Z(r) {
|
|
148
|
+
const t = yt(r);
|
|
149
|
+
return F(r) ? t.identifier : t.pointerId;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const t =
|
|
151
|
+
function ct(r) {
|
|
152
|
+
const t = yt(r);
|
|
153
153
|
return [t.clientX, t.clientY];
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function Bt(r) {
|
|
156
156
|
const t = {};
|
|
157
157
|
if ("buttons" in r && (t.buttons = r.buttons), "shiftKey" in r) {
|
|
158
158
|
const {
|
|
@@ -170,24 +170,24 @@ function jt(r) {
|
|
|
170
170
|
}
|
|
171
171
|
return t;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function W(r, ...t) {
|
|
174
174
|
return typeof r == "function" ? r(...t) : r;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function zt() {
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return r.length === 0 ?
|
|
178
|
+
function Yt(...r) {
|
|
179
|
+
return r.length === 0 ? zt : r.length === 1 ? r[0] : function() {
|
|
180
180
|
let t;
|
|
181
181
|
for (const e of r)
|
|
182
182
|
t = e.apply(this, arguments) || t;
|
|
183
183
|
return t;
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function ut(r, t) {
|
|
187
187
|
return Object.assign({}, t, r || {});
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
class
|
|
189
|
+
const Wt = 32;
|
|
190
|
+
class Ft {
|
|
191
191
|
constructor(t, e, n) {
|
|
192
192
|
this.ctrl = t, this.args = e, this.key = n, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
|
|
193
193
|
}
|
|
@@ -226,7 +226,7 @@ class zt {
|
|
|
226
226
|
}
|
|
227
227
|
start(t) {
|
|
228
228
|
const e = this.state, n = this.config;
|
|
229
|
-
e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = n.from ?
|
|
229
|
+
e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = n.from ? W(n.from, e) : e.offset, e.offset = e.lastOffset, e.startTime = e.timeStamp = t.timeStamp);
|
|
230
230
|
}
|
|
231
231
|
computeValues(t) {
|
|
232
232
|
const e = this.state;
|
|
@@ -244,38 +244,38 @@ class zt {
|
|
|
244
244
|
} = this;
|
|
245
245
|
e.args = this.args;
|
|
246
246
|
let i = 0;
|
|
247
|
-
if (t && (e.event = t, n.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s,
|
|
248
|
-
const
|
|
249
|
-
g.addTo(e._distance,
|
|
247
|
+
if (t && (e.event = t, n.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s, Bt(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, i = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
|
|
248
|
+
const l = e._delta.map(Math.abs);
|
|
249
|
+
g.addTo(e._distance, l);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
|
-
const [c, a] = e._movement, [u,
|
|
252
|
+
const [c, a] = e._movement, [u, p] = n.threshold, {
|
|
253
253
|
_step: f,
|
|
254
254
|
values: E
|
|
255
255
|
} = e;
|
|
256
|
-
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(c) >= u && E[0]), f[1] === !1 && (f[1] = Math.abs(a) >=
|
|
256
|
+
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(c) >= u && E[0]), f[1] === !1 && (f[1] = Math.abs(a) >= p && E[1])) : (f[0] === !1 && (f[0] = Math.abs(c) >= u && Math.sign(c) * u), f[1] === !1 && (f[1] = Math.abs(a) >= p && Math.sign(a) * p)), e.intentional = f[0] !== !1 || f[1] !== !1, !e.intentional) return;
|
|
257
257
|
const v = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
|
-
const [
|
|
260
|
-
v[0] = f[0] !== !1 ?
|
|
259
|
+
const [l, M] = E;
|
|
260
|
+
v[0] = f[0] !== !1 ? l - f[0] : 0, v[1] = f[1] !== !1 ? M - f[1] : 0;
|
|
261
261
|
} else
|
|
262
262
|
v[0] = f[0] !== !1 ? c - f[0] : 0, v[1] = f[1] !== !1 ? a - f[1] : 0;
|
|
263
263
|
this.restrictToAxis && !e._blocked && this.restrictToAxis(v);
|
|
264
|
-
const $ = e.offset,
|
|
265
|
-
|
|
266
|
-
const [
|
|
267
|
-
e.overflow = [
|
|
268
|
-
const
|
|
269
|
-
if (e.offset =
|
|
264
|
+
const $ = e.offset, N = e._active && !e._blocked || e.active;
|
|
265
|
+
N && (e.first = e._active && !e.active, e.last = !e._active && e.active, e.active = s[this.ingKey] = e._active, t && (e.first && ("bounds" in n && (e._bounds = W(n.bounds, e)), this.setup && this.setup()), e.movement = v, this.computeOffset()));
|
|
266
|
+
const [P, D] = e.offset, [[S, B], [k, C]] = e._bounds;
|
|
267
|
+
e.overflow = [P < S ? -1 : P > B ? 1 : 0, D < k ? -1 : D > C ? 1 : 0], e._movementBound[0] = e.overflow[0] ? e._movementBound[0] === !1 ? e._movement[0] : e._movementBound[0] : !1, e._movementBound[1] = e.overflow[1] ? e._movementBound[1] === !1 ? e._movement[1] : e._movementBound[1] : !1;
|
|
268
|
+
const L = e._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
+
if (e.offset = Ot(e._bounds, e.offset, L), e.delta = g.sub(e.offset, $), this.computeMovement(), N && (!e.last || i > Wt)) {
|
|
270
270
|
e.delta = g.sub(e.offset, $);
|
|
271
|
-
const
|
|
272
|
-
g.addTo(e.distance,
|
|
271
|
+
const l = e.delta.map(Math.abs);
|
|
272
|
+
g.addTo(e.distance, l), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && i > 0 && (e.velocity = [l[0] / i, l[1] / i], e.timeDelta = i);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
emit() {
|
|
276
276
|
const t = this.state, e = this.shared, n = this.config;
|
|
277
277
|
if (t._active || this.clean(), (t._blocked || !t.intentional) && !t._force && !n.triggerAllEvents) return;
|
|
278
|
-
const s = this.handler(
|
|
278
|
+
const s = this.handler(h(h(h({}, e), t), {}, {
|
|
279
279
|
[this.aliasKey]: t.values
|
|
280
280
|
}));
|
|
281
281
|
s !== void 0 && (t.memo = s);
|
|
@@ -284,14 +284,14 @@ class zt {
|
|
|
284
284
|
this.eventStore.clean(), this.timeoutStore.clean();
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function Ht([r, t], e) {
|
|
288
288
|
const n = Math.abs(r), s = Math.abs(t);
|
|
289
289
|
if (n > s && n > e)
|
|
290
290
|
return "x";
|
|
291
291
|
if (s > n && s > e)
|
|
292
292
|
return "y";
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class Gt extends Ft {
|
|
295
295
|
constructor(...t) {
|
|
296
296
|
super(...t), y(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
@@ -310,8 +310,8 @@ class Wt extends zt {
|
|
|
310
310
|
axisIntent(t) {
|
|
311
311
|
const e = this.state, n = this.config;
|
|
312
312
|
if (!e.axis && t) {
|
|
313
|
-
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[
|
|
314
|
-
e.axis =
|
|
313
|
+
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[vt(t)] : n.axisThreshold;
|
|
314
|
+
e.axis = Ht(e._movement, s);
|
|
315
315
|
}
|
|
316
316
|
e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
|
|
317
317
|
}
|
|
@@ -327,12 +327,12 @@ class Wt extends zt {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const ft = (r) => r, lt = 0.15, rt = {
|
|
331
331
|
enabled(r = !0) {
|
|
332
332
|
return r;
|
|
333
333
|
},
|
|
334
334
|
eventOptions(r, t, e) {
|
|
335
|
-
return
|
|
335
|
+
return h(h({}, e.shared.eventOptions), r);
|
|
336
336
|
},
|
|
337
337
|
preventDefault(r = !1) {
|
|
338
338
|
return r;
|
|
@@ -343,7 +343,7 @@ const ut = (r) => r, ft = 0.15, et = {
|
|
|
343
343
|
rubberband(r = 0) {
|
|
344
344
|
switch (r) {
|
|
345
345
|
case !0:
|
|
346
|
-
return [
|
|
346
|
+
return [lt, lt];
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
@@ -357,19 +357,19 @@ const ut = (r) => r, ft = 0.15, et = {
|
|
|
357
357
|
transform(r, t, e) {
|
|
358
358
|
const n = r || e.shared.transform;
|
|
359
359
|
if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
|
|
360
|
-
const s = n ||
|
|
360
|
+
const s = n || ft;
|
|
361
361
|
return (i) => {
|
|
362
362
|
const c = s(i);
|
|
363
363
|
return (!isFinite(c[0]) || !isFinite(c[1])) && console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${c[0]},${[1]}]`), c;
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
return n ||
|
|
366
|
+
return n || ft;
|
|
367
367
|
},
|
|
368
368
|
threshold(r) {
|
|
369
369
|
return g.toVector(r, 0);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
372
|
+
process.env.NODE_ENV === "development" && Object.assign(rt, {
|
|
373
373
|
domTarget(r) {
|
|
374
374
|
if (r !== void 0)
|
|
375
375
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -386,13 +386,13 @@ process.env.NODE_ENV === "development" && Object.assign(et, {
|
|
|
386
386
|
return NaN;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
const
|
|
389
|
+
const Xt = 0, U = h(h({}, rt), {}, {
|
|
390
390
|
axis(r, t, {
|
|
391
391
|
axis: e
|
|
392
392
|
}) {
|
|
393
393
|
if (this.lockDirection = e === "lock", !this.lockDirection) return e;
|
|
394
394
|
},
|
|
395
|
-
axisThreshold(r =
|
|
395
|
+
axisThreshold(r = Xt) {
|
|
396
396
|
return r;
|
|
397
397
|
},
|
|
398
398
|
bounds(r = {}) {
|
|
@@ -410,13 +410,13 @@ const Ft = 0, U = d(d({}, et), {}, {
|
|
|
410
410
|
} = r;
|
|
411
411
|
return [[t, e], [n, s]];
|
|
412
412
|
}
|
|
413
|
-
}),
|
|
413
|
+
}), dt = {
|
|
414
414
|
ArrowRight: (r, t = 1) => [r * t, 0],
|
|
415
415
|
ArrowLeft: (r, t = 1) => [-1 * r * t, 0],
|
|
416
416
|
ArrowUp: (r, t = 1) => [0, -1 * r * t],
|
|
417
417
|
ArrowDown: (r, t = 1) => [0, r * t]
|
|
418
418
|
};
|
|
419
|
-
class
|
|
419
|
+
class qt extends Gt {
|
|
420
420
|
constructor(...t) {
|
|
421
421
|
super(...t), y(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
@@ -453,7 +453,7 @@ class Ht extends Wt {
|
|
|
453
453
|
const e = this.config, n = this.state;
|
|
454
454
|
if (t.buttons != null && (Array.isArray(e.pointerButtons) ? !e.pointerButtons.includes(t.buttons) : e.pointerButtons !== -1 && e.pointerButtons !== t.buttons)) return;
|
|
455
455
|
const s = this.ctrl.setEventIds(t);
|
|
456
|
-
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId =
|
|
456
|
+
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = Z(t), n._pointerActive = !0, this.computeValues(ct(t)), this.computeInitial(), e.preventScrollAxis && vt(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : e.delay > 0 ? (this.setupDelayTrigger(t), e.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
|
|
457
457
|
}
|
|
458
458
|
startPointerDrag(t) {
|
|
459
459
|
const e = this.state;
|
|
@@ -462,9 +462,9 @@ class Ht extends Wt {
|
|
|
462
462
|
pointerMove(t) {
|
|
463
463
|
const e = this.state, n = this.config;
|
|
464
464
|
if (!e._pointerActive) return;
|
|
465
|
-
const s =
|
|
465
|
+
const s = Z(t);
|
|
466
466
|
if (e._pointerId !== void 0 && s !== e._pointerId) return;
|
|
467
|
-
const i =
|
|
467
|
+
const i = ct(t);
|
|
468
468
|
if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = g.sub(i, e._values), this.computeValues(i)), g.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
|
|
469
469
|
this.timeoutStore.remove("dragDelay"), e.active = !1, this.startPointerDrag(t);
|
|
470
470
|
return;
|
|
@@ -491,17 +491,17 @@ class Ht extends Wt {
|
|
|
491
491
|
}
|
|
492
492
|
const e = this.state, n = this.config;
|
|
493
493
|
if (!e._active || !e._pointerActive) return;
|
|
494
|
-
const s =
|
|
494
|
+
const s = Z(t);
|
|
495
495
|
if (e._pointerId !== void 0 && s !== e._pointerId) return;
|
|
496
496
|
this.state._pointerActive = !1, this.setActive(), this.compute(t);
|
|
497
497
|
const [i, c] = e._distance;
|
|
498
498
|
if (e.tap = i <= n.tapsThreshold && c <= n.tapsThreshold, e.tap && n.filterTaps)
|
|
499
499
|
e._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [a, u] = e._delta, [
|
|
502
|
-
if (e.elapsedTime <
|
|
503
|
-
const
|
|
504
|
-
|
|
501
|
+
const [a, u] = e._delta, [p, f] = e._movement, [E, v] = n.swipe.velocity, [$, N] = n.swipe.distance, P = n.swipe.duration;
|
|
502
|
+
if (e.elapsedTime < P) {
|
|
503
|
+
const D = Math.abs(a / e.timeDelta), S = Math.abs(u / e.timeDelta);
|
|
504
|
+
D > E && Math.abs(p) > $ && (e.swipe[0] = Math.sign(a)), S > v && Math.abs(f) > N && (e.swipe[1] = Math.sign(u));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -528,7 +528,7 @@ class Ht extends Wt {
|
|
|
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, Jt(t);
|
|
532
532
|
const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
|
533
533
|
passive: !1
|
|
534
534
|
});
|
|
@@ -540,14 +540,14 @@ class Ht extends Wt {
|
|
|
540
540
|
}, this.config.delay);
|
|
541
541
|
}
|
|
542
542
|
keyDown(t) {
|
|
543
|
-
const e =
|
|
543
|
+
const e = dt[t.key];
|
|
544
544
|
if (e) {
|
|
545
545
|
const n = this.state, s = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
546
546
|
this.start(t), n._delta = e(this.config.keyboardDisplacement, s), n._keyboardActive = !0, g.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 dt && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
|
|
551
551
|
}
|
|
552
552
|
bind(t) {
|
|
553
553
|
const e = this.config.device;
|
|
@@ -557,23 +557,23 @@ class Ht extends Wt {
|
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function Jt(r) {
|
|
561
561
|
"persist" in r && typeof r.persist == "function" && r.persist();
|
|
562
562
|
}
|
|
563
563
|
const K = typeof window < "u" && window.document && window.document.createElement;
|
|
564
|
-
function
|
|
564
|
+
function _t() {
|
|
565
565
|
return K && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
568
|
-
return
|
|
567
|
+
function Qt() {
|
|
568
|
+
return _t() || K && window.navigator.maxTouchPoints > 1;
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function Zt() {
|
|
571
571
|
return K && "onpointerdown" in window;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function te() {
|
|
574
574
|
return K && "exitPointerLock" in window.document;
|
|
575
575
|
}
|
|
576
|
-
function
|
|
576
|
+
function ee() {
|
|
577
577
|
try {
|
|
578
578
|
return "constructor" in GestureEvent;
|
|
579
579
|
} catch {
|
|
@@ -582,16 +582,16 @@ function Qt() {
|
|
|
582
582
|
}
|
|
583
583
|
const x = {
|
|
584
584
|
isBrowser: K,
|
|
585
|
-
gesture:
|
|
586
|
-
touch:
|
|
587
|
-
touchscreen:
|
|
588
|
-
pointer:
|
|
589
|
-
pointerLock:
|
|
590
|
-
},
|
|
585
|
+
gesture: ee(),
|
|
586
|
+
touch: _t(),
|
|
587
|
+
touchscreen: Qt(),
|
|
588
|
+
pointer: Zt(),
|
|
589
|
+
pointerLock: te()
|
|
590
|
+
}, re = 250, ne = 180, se = 0.5, ie = 50, oe = 250, ae = 10, ht = {
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
},
|
|
594
|
+
}, bt = h(h({}, U), {}, {
|
|
595
595
|
device(r, t, {
|
|
596
596
|
pointer: {
|
|
597
597
|
touch: e = !1,
|
|
@@ -604,7 +604,7 @@ const x = {
|
|
|
604
604
|
preventScrollAxis(r, t, {
|
|
605
605
|
preventScroll: e
|
|
606
606
|
}) {
|
|
607
|
-
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ?
|
|
607
|
+
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? re : void 0, !(!x.touchscreen || e === !1))
|
|
608
608
|
return r || (e !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
610
|
pointerCapture(r, t, {
|
|
@@ -625,9 +625,9 @@ const x = {
|
|
|
625
625
|
return this.filterTaps = e, this.tapsThreshold = n, i;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
628
|
-
velocity: r =
|
|
629
|
-
distance: t =
|
|
630
|
-
duration: e =
|
|
628
|
+
velocity: r = se,
|
|
629
|
+
distance: t = ie,
|
|
630
|
+
duration: e = oe
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
633
|
velocity: this.transform(g.toVector(r)),
|
|
@@ -638,7 +638,7 @@ const x = {
|
|
|
638
638
|
delay(r = 0) {
|
|
639
639
|
switch (r) {
|
|
640
640
|
case !0:
|
|
641
|
-
return
|
|
641
|
+
return ne;
|
|
642
642
|
case !1:
|
|
643
643
|
return 0;
|
|
644
644
|
default:
|
|
@@ -646,13 +646,13 @@ const x = {
|
|
|
646
646
|
}
|
|
647
647
|
},
|
|
648
648
|
axisThreshold(r) {
|
|
649
|
-
return r ?
|
|
649
|
+
return r ? h(h({}, ht), r) : ht;
|
|
650
650
|
},
|
|
651
|
-
keyboardDisplacement(r =
|
|
651
|
+
keyboardDisplacement(r = ae) {
|
|
652
652
|
return r;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
655
|
+
process.env.NODE_ENV === "development" && Object.assign(bt, {
|
|
656
656
|
useTouch(r) {
|
|
657
657
|
if (r !== void 0)
|
|
658
658
|
throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");
|
|
@@ -679,7 +679,7 @@ process.env.NODE_ENV === "development" && Object.assign(_t, {
|
|
|
679
679
|
return NaN;
|
|
680
680
|
}
|
|
681
681
|
});
|
|
682
|
-
|
|
682
|
+
h(h({}, rt), {}, {
|
|
683
683
|
device(r, t, {
|
|
684
684
|
shared: e,
|
|
685
685
|
pointer: {
|
|
@@ -698,13 +698,13 @@ d(d({}, et), {}, {
|
|
|
698
698
|
angleBounds: n = {}
|
|
699
699
|
}) {
|
|
700
700
|
const s = (c) => {
|
|
701
|
-
const a =
|
|
701
|
+
const a = ut(W(e, c), {
|
|
702
702
|
min: -1 / 0,
|
|
703
703
|
max: 1 / 0
|
|
704
704
|
});
|
|
705
705
|
return [a.min, a.max];
|
|
706
706
|
}, i = (c) => {
|
|
707
|
-
const a =
|
|
707
|
+
const a = ut(W(n, c), {
|
|
708
708
|
min: -1 / 0,
|
|
709
709
|
max: 1 / 0
|
|
710
710
|
});
|
|
@@ -722,31 +722,31 @@ d(d({}, et), {}, {
|
|
|
722
722
|
return r;
|
|
723
723
|
}
|
|
724
724
|
});
|
|
725
|
-
|
|
725
|
+
h(h({}, U), {}, {
|
|
726
726
|
mouseOnly: (r = !0) => r
|
|
727
727
|
});
|
|
728
|
-
|
|
728
|
+
h(h({}, U), {}, {
|
|
729
729
|
mouseOnly: (r = !0) => r
|
|
730
730
|
});
|
|
731
|
-
const
|
|
732
|
-
function
|
|
733
|
-
|
|
731
|
+
const wt = /* @__PURE__ */ new Map(), et = /* @__PURE__ */ new Map();
|
|
732
|
+
function ce(r) {
|
|
733
|
+
wt.set(r.key, r.engine), et.set(r.key, r.resolver);
|
|
734
734
|
}
|
|
735
|
-
const
|
|
735
|
+
const ue = {
|
|
736
736
|
key: "drag",
|
|
737
|
-
engine:
|
|
738
|
-
resolver:
|
|
737
|
+
engine: qt,
|
|
738
|
+
resolver: bt
|
|
739
739
|
};
|
|
740
|
-
function
|
|
740
|
+
function fe(r, t) {
|
|
741
741
|
if (r == null) return {};
|
|
742
742
|
var e = {}, n = Object.keys(r), s, i;
|
|
743
743
|
for (i = 0; i < n.length; i++)
|
|
744
744
|
s = n[i], !(t.indexOf(s) >= 0) && (e[s] = r[s]);
|
|
745
745
|
return e;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function le(r, t) {
|
|
748
748
|
if (r == null) return {};
|
|
749
|
-
var e =
|
|
749
|
+
var e = fe(r, t), n, s;
|
|
750
750
|
if (Object.getOwnPropertySymbols) {
|
|
751
751
|
var i = Object.getOwnPropertySymbols(r);
|
|
752
752
|
for (s = 0; s < i.length; s++)
|
|
@@ -754,7 +754,7 @@ function ce(r, t) {
|
|
|
754
754
|
}
|
|
755
755
|
return e;
|
|
756
756
|
}
|
|
757
|
-
const
|
|
757
|
+
const de = {
|
|
758
758
|
target(r) {
|
|
759
759
|
if (r)
|
|
760
760
|
return () => "current" in r ? r.current : r;
|
|
@@ -777,8 +777,8 @@ const ue = {
|
|
|
777
777
|
transform(r) {
|
|
778
778
|
return r;
|
|
779
779
|
}
|
|
780
|
-
},
|
|
781
|
-
function
|
|
780
|
+
}, he = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
781
|
+
function Y(r = {}, t) {
|
|
782
782
|
const e = {};
|
|
783
783
|
for (const [n, s] of Object.entries(t))
|
|
784
784
|
switch (typeof s) {
|
|
@@ -790,7 +790,7 @@ function z(r = {}, t) {
|
|
|
790
790
|
e[n] = s.call(e, r[n], n, r);
|
|
791
791
|
break;
|
|
792
792
|
case "object":
|
|
793
|
-
e[n] =
|
|
793
|
+
e[n] = Y(r[n], s);
|
|
794
794
|
break;
|
|
795
795
|
case "boolean":
|
|
796
796
|
s && (e[n] = r[n]);
|
|
@@ -798,32 +798,32 @@ function z(r = {}, t) {
|
|
|
798
798
|
}
|
|
799
799
|
return e;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function pe(r, t, e = {}) {
|
|
802
802
|
const n = r, {
|
|
803
803
|
target: s,
|
|
804
804
|
eventOptions: i,
|
|
805
805
|
window: c,
|
|
806
806
|
enabled: a,
|
|
807
807
|
transform: u
|
|
808
|
-
} = n,
|
|
809
|
-
if (e.shared =
|
|
808
|
+
} = n, p = le(n, he);
|
|
809
|
+
if (e.shared = Y({
|
|
810
810
|
target: s,
|
|
811
811
|
eventOptions: i,
|
|
812
812
|
window: c,
|
|
813
813
|
enabled: a,
|
|
814
814
|
transform: u
|
|
815
|
-
},
|
|
816
|
-
const f =
|
|
817
|
-
e[t] =
|
|
815
|
+
}, de), t) {
|
|
816
|
+
const f = et.get(t);
|
|
817
|
+
e[t] = Y(h({
|
|
818
818
|
shared: e.shared
|
|
819
|
-
},
|
|
819
|
+
}, p), f);
|
|
820
820
|
} else
|
|
821
|
-
for (const f in
|
|
822
|
-
const E =
|
|
821
|
+
for (const f in p) {
|
|
822
|
+
const E = et.get(f);
|
|
823
823
|
if (E)
|
|
824
|
-
e[f] =
|
|
824
|
+
e[f] = Y(h({
|
|
825
825
|
shared: e.shared
|
|
826
|
-
},
|
|
826
|
+
}, p[f]), E);
|
|
827
827
|
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(f)) {
|
|
828
828
|
if (f === "domTarget")
|
|
829
829
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -832,15 +832,15 @@ function le(r, t, e = {}) {
|
|
|
832
832
|
}
|
|
833
833
|
return e;
|
|
834
834
|
}
|
|
835
|
-
class
|
|
835
|
+
class Et {
|
|
836
836
|
constructor(t, e) {
|
|
837
837
|
y(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
|
|
838
838
|
}
|
|
839
839
|
add(t, e, n, s, i) {
|
|
840
|
-
const c = this._listeners, a =
|
|
841
|
-
t.addEventListener(a, s,
|
|
840
|
+
const c = this._listeners, a = Vt(e, n), u = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, p = h(h({}, u), i);
|
|
841
|
+
t.addEventListener(a, s, p);
|
|
842
842
|
const f = () => {
|
|
843
|
-
t.removeEventListener(a, s,
|
|
843
|
+
t.removeEventListener(a, s, p), c.delete(f);
|
|
844
844
|
};
|
|
845
845
|
return c.add(f), f;
|
|
846
846
|
}
|
|
@@ -848,7 +848,7 @@ class wt {
|
|
|
848
848
|
this._listeners.forEach((t) => t()), this._listeners.clear();
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
class
|
|
851
|
+
class me {
|
|
852
852
|
constructor() {
|
|
853
853
|
y(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
@@ -863,20 +863,20 @@ class de {
|
|
|
863
863
|
this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
class
|
|
866
|
+
class ge {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
y(this, "gestures", /* @__PURE__ */ new Set()), y(this, "_targetEventStore", new
|
|
868
|
+
y(this, "gestures", /* @__PURE__ */ new Set()), y(this, "_targetEventStore", new Et(this)), y(this, "gestureEventStores", {}), y(this, "gestureTimeoutStores", {}), y(this, "handlers", {}), y(this, "config", {}), y(this, "pointerIds", /* @__PURE__ */ new Set()), y(this, "touchIds", /* @__PURE__ */ new Set()), y(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
|
+
}), ve(this, t);
|
|
876
876
|
}
|
|
877
877
|
setEventIds(t) {
|
|
878
|
-
if (
|
|
879
|
-
return this.touchIds = new Set(
|
|
878
|
+
if (F(t))
|
|
879
|
+
return this.touchIds = new Set(Kt(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 he {
|
|
|
884
884
|
this.handlers = t, this.nativeHandlers = e;
|
|
885
885
|
}
|
|
886
886
|
applyConfig(t, e) {
|
|
887
|
-
this.config =
|
|
887
|
+
this.config = pe(t, e, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -900,28 +900,28 @@ class he {
|
|
|
900
900
|
if (!(e.target && (s = e.target(), !s))) {
|
|
901
901
|
if (e.enabled) {
|
|
902
902
|
for (const c of this.gestures) {
|
|
903
|
-
const a = this.config[c], u =
|
|
903
|
+
const a = this.config[c], u = pt(n, a.eventOptions, !!s);
|
|
904
904
|
if (a.enabled) {
|
|
905
|
-
const
|
|
906
|
-
new
|
|
905
|
+
const p = wt.get(c);
|
|
906
|
+
new p(this, t, c).bind(u);
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
const i =
|
|
909
|
+
const i = pt(n, e.eventOptions, !!s);
|
|
910
910
|
for (const c in this.nativeHandlers)
|
|
911
|
-
i(c, "", (a) => this.nativeHandlers[c](
|
|
911
|
+
i(c, "", (a) => this.nativeHandlers[c](h(h({}, this.state.shared), {}, {
|
|
912
912
|
event: a,
|
|
913
913
|
args: t
|
|
914
914
|
})), void 0, !0);
|
|
915
915
|
}
|
|
916
916
|
for (const i in n)
|
|
917
|
-
n[i] =
|
|
917
|
+
n[i] = Yt(...n[i]);
|
|
918
918
|
if (!s) return n;
|
|
919
919
|
for (const i in n) {
|
|
920
920
|
const {
|
|
921
921
|
device: c,
|
|
922
922
|
capture: a,
|
|
923
923
|
passive: u
|
|
924
|
-
} =
|
|
924
|
+
} = Lt(i);
|
|
925
925
|
this._targetEventStore.add(s, c, "", n[i], {
|
|
926
926
|
capture: a,
|
|
927
927
|
passive: u
|
|
@@ -931,41 +931,41 @@ class he {
|
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
933
|
function R(r, t) {
|
|
934
|
-
r.gestures.add(t), r.gestureEventStores[t] = new
|
|
934
|
+
r.gestures.add(t), r.gestureEventStores[t] = new Et(r, t), r.gestureTimeoutStores[t] = new me();
|
|
935
935
|
}
|
|
936
|
-
function
|
|
936
|
+
function ve(r, t) {
|
|
937
937
|
t.drag && R(r, "drag"), t.wheel && R(r, "wheel"), t.scroll && R(r, "scroll"), t.move && R(r, "move"), t.pinch && R(r, "pinch"), t.hover && R(r, "hover");
|
|
938
938
|
}
|
|
939
|
-
const
|
|
940
|
-
var u,
|
|
941
|
-
const f = (u = c.capture) !== null && u !== void 0 ? u : t.capture, E = (
|
|
942
|
-
let v = a ? n :
|
|
939
|
+
const pt = (r, t, e) => (n, s, i, c = {}, a = !1) => {
|
|
940
|
+
var u, p;
|
|
941
|
+
const f = (u = c.capture) !== null && u !== void 0 ? u : t.capture, E = (p = c.passive) !== null && p !== void 0 ? p : t.passive;
|
|
942
|
+
let v = a ? n : Mt(n, s, f);
|
|
943
943
|
e && E && (v += "Passive"), r[v] = r[v] || [], r[v].push(i);
|
|
944
944
|
};
|
|
945
|
-
function
|
|
946
|
-
const s =
|
|
947
|
-
if (s.applyHandlers(r, n), s.applyConfig(t, e),
|
|
945
|
+
function ye(r, t = {}, e, n) {
|
|
946
|
+
const s = Q.useMemo(() => new ge(r), []);
|
|
947
|
+
if (s.applyHandlers(r, n), s.applyConfig(t, e), Q.useEffect(s.effect.bind(s)), Q.useEffect(() => s.clean.bind(s), []), t.target === void 0)
|
|
948
948
|
return s.bind.bind(s);
|
|
949
949
|
}
|
|
950
|
-
function
|
|
951
|
-
return
|
|
950
|
+
function _e(r, t) {
|
|
951
|
+
return ce(ue), ye({
|
|
952
952
|
drag: r
|
|
953
953
|
}, t || {}, "drag");
|
|
954
954
|
}
|
|
955
|
-
const
|
|
956
|
-
function
|
|
957
|
-
const r =
|
|
955
|
+
const tt = "RSC::Event";
|
|
956
|
+
function be() {
|
|
957
|
+
const r = A(null);
|
|
958
958
|
function t(n) {
|
|
959
|
-
|
|
959
|
+
mt(() => {
|
|
960
960
|
r.current || (r.current = document.createElement("div"));
|
|
961
961
|
function s(i) {
|
|
962
962
|
n(i.detail);
|
|
963
963
|
}
|
|
964
964
|
if (r.current)
|
|
965
|
-
return r.current.addEventListener(
|
|
965
|
+
return r.current.addEventListener(tt, s, !1), () => {
|
|
966
966
|
var i;
|
|
967
967
|
(i = r.current) == null || i.removeEventListener(
|
|
968
|
-
|
|
968
|
+
tt,
|
|
969
969
|
s,
|
|
970
970
|
!1
|
|
971
971
|
);
|
|
@@ -974,7 +974,7 @@ function ve() {
|
|
|
974
974
|
}
|
|
975
975
|
function e(n) {
|
|
976
976
|
if (r.current) {
|
|
977
|
-
const s = new CustomEvent(
|
|
977
|
+
const s = new CustomEvent(tt, {
|
|
978
978
|
detail: n
|
|
979
979
|
});
|
|
980
980
|
r.current.dispatchEvent(s);
|
|
@@ -985,7 +985,7 @@ function ve() {
|
|
|
985
985
|
emitEvent: e
|
|
986
986
|
};
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function Te({
|
|
989
989
|
init: r = !0,
|
|
990
990
|
items: t,
|
|
991
991
|
withLoop: e = !1,
|
|
@@ -995,23 +995,23 @@ function Ee({
|
|
|
995
995
|
startEndGutter: c = 0,
|
|
996
996
|
carouselAxis: a = "x",
|
|
997
997
|
slideType: u = "fixed",
|
|
998
|
-
startingPosition:
|
|
998
|
+
startingPosition: p = "start",
|
|
999
999
|
enableGestures: f = !0,
|
|
1000
1000
|
slideWhenDragThresholdIsReached: E = !0,
|
|
1001
1001
|
onInit: v
|
|
1002
1002
|
}) {
|
|
1003
|
-
const
|
|
1003
|
+
const [$, N] = kt(!1), P = A(r), D = A(null), S = A(null), B = A(0), k = A(!e), C = A(!1), L = A(0), l = A(0), [M, H] = Dt(
|
|
1004
1004
|
() => ({
|
|
1005
1005
|
value: 0,
|
|
1006
1006
|
onChange({ value: o }) {
|
|
1007
|
-
(u === "fixed" || u === "fluid") &&
|
|
1007
|
+
(u === "fixed" || u === "fluid") && D.current.style.setProperty(
|
|
1008
1008
|
`--${n}-offset-position`,
|
|
1009
1009
|
`${o.value}px`
|
|
1010
1010
|
), u === "freeScroll" && (S.current[a === "x" ? "scrollLeft" : "scrollTop"] = Math.abs(o.value));
|
|
1011
1011
|
}
|
|
1012
1012
|
}),
|
|
1013
1013
|
[a]
|
|
1014
|
-
),
|
|
1014
|
+
), xt = u !== "freeScroll" && e ? [
|
|
1015
1015
|
...t.map((o) => ({
|
|
1016
1016
|
...o,
|
|
1017
1017
|
id: `prev-repeated-item-${o.id}`,
|
|
@@ -1023,16 +1023,16 @@ function Ee({
|
|
|
1023
1023
|
id: `next-repeated-item-${o.id}`,
|
|
1024
1024
|
isClonedItem: !0
|
|
1025
1025
|
}))
|
|
1026
|
-
] : t, { useListenToCustomEvent:
|
|
1027
|
-
function
|
|
1028
|
-
|
|
1026
|
+
] : t, { useListenToCustomEvent: nt, emitEvent: V } = be();
|
|
1027
|
+
function G(o) {
|
|
1028
|
+
P.current && (C.current || j({
|
|
1029
1029
|
type: "next",
|
|
1030
1030
|
toIndex: o,
|
|
1031
1031
|
actionType: "click"
|
|
1032
1032
|
}));
|
|
1033
1033
|
}
|
|
1034
|
-
function
|
|
1035
|
-
|
|
1034
|
+
function X(o) {
|
|
1035
|
+
P.current && (k.current || j({
|
|
1036
1036
|
type: "prev",
|
|
1037
1037
|
toIndex: o,
|
|
1038
1038
|
actionType: "click"
|
|
@@ -1040,51 +1040,51 @@ function Ee({
|
|
|
1040
1040
|
}
|
|
1041
1041
|
function j({
|
|
1042
1042
|
type: o,
|
|
1043
|
-
shouldAnimate:
|
|
1044
|
-
toIndex:
|
|
1043
|
+
shouldAnimate: d = !0,
|
|
1044
|
+
toIndex: T,
|
|
1045
1045
|
actionType: _
|
|
1046
1046
|
}) {
|
|
1047
|
-
const m =
|
|
1048
|
-
|
|
1049
|
-
let
|
|
1050
|
-
if (o === "next" && (
|
|
1051
|
-
const w =
|
|
1047
|
+
const m = z(), O = !d;
|
|
1048
|
+
k.current = !1, C.current = !1;
|
|
1049
|
+
let I = M.value.get(), b = 0;
|
|
1050
|
+
if (o === "next" && (l.current += 1), o === "prev" && (l.current === 0 ? l.current = t.length - 1 : l.current -= 1), T !== void 0 && (l.current = T), u !== "freeScroll" && o === "next") {
|
|
1051
|
+
const w = q(
|
|
1052
1052
|
e ? m * (t.length * 2) : 0
|
|
1053
1053
|
);
|
|
1054
|
-
b = -(
|
|
1054
|
+
b = -(l.current * m), w - Math.abs(b) < m / 1.2 && u === "fluid" && !e && (b = -w), !e && Math.abs(b) >= w && (C.current = !0, b = -w), e && l.current === t.length && (l.current = 0, I = I + m * t.length, b = 0);
|
|
1055
1055
|
}
|
|
1056
|
-
if (u !== "freeScroll" && o === "prev" && (b = -(
|
|
1056
|
+
if (u !== "freeScroll" && o === "prev" && (b = -(l.current * m), l.current === t.length - 1 && (I = I - t.length * m), !e && b >= 0 && (k.current = !0, b = 0)), u === "freeScroll" && o === "next") {
|
|
1057
1057
|
const w = S.current[a === "x" ? "scrollLeft" : "scrollTop"];
|
|
1058
|
-
|
|
1058
|
+
I = w, b = w + m;
|
|
1059
1059
|
}
|
|
1060
1060
|
if (u === "freeScroll" && o === "prev") {
|
|
1061
1061
|
const w = S.current[a === "x" ? "scrollLeft" : "scrollTop"];
|
|
1062
|
-
|
|
1062
|
+
I = w, b = w - m;
|
|
1063
1063
|
}
|
|
1064
|
-
|
|
1064
|
+
B.current = b, V(_ === "resize" ? {
|
|
1065
1065
|
eventName: "onResize",
|
|
1066
1066
|
sliceActionType: _,
|
|
1067
1067
|
slideDirection: o,
|
|
1068
1068
|
currentItem: {
|
|
1069
|
-
index:
|
|
1070
|
-
id: t.at(
|
|
1071
|
-
startReached:
|
|
1072
|
-
endReached:
|
|
1069
|
+
index: l.current,
|
|
1070
|
+
id: t.at(l.current).id,
|
|
1071
|
+
startReached: k.current,
|
|
1072
|
+
endReached: C.current
|
|
1073
1073
|
}
|
|
1074
1074
|
} : {
|
|
1075
1075
|
eventName: "onSlideStartChange",
|
|
1076
1076
|
sliceActionType: _,
|
|
1077
1077
|
slideDirection: o,
|
|
1078
1078
|
nextItem: {
|
|
1079
|
-
index:
|
|
1080
|
-
id: t.at(
|
|
1081
|
-
startReached:
|
|
1082
|
-
endReached:
|
|
1079
|
+
index: l.current,
|
|
1080
|
+
id: t.at(l.current).id,
|
|
1081
|
+
startReached: k.current,
|
|
1082
|
+
endReached: C.current
|
|
1083
1083
|
}
|
|
1084
|
-
}),
|
|
1085
|
-
immediate:
|
|
1084
|
+
}), H.start({
|
|
1085
|
+
immediate: O,
|
|
1086
1086
|
from: {
|
|
1087
|
-
value:
|
|
1087
|
+
value: I
|
|
1088
1088
|
},
|
|
1089
1089
|
to: {
|
|
1090
1090
|
value: b
|
|
@@ -1095,10 +1095,10 @@ function Ee({
|
|
|
1095
1095
|
sliceActionType: _,
|
|
1096
1096
|
slideDirection: o,
|
|
1097
1097
|
currentItem: {
|
|
1098
|
-
index:
|
|
1099
|
-
id: t.at(
|
|
1100
|
-
startReached:
|
|
1101
|
-
endReached:
|
|
1098
|
+
index: l.current,
|
|
1099
|
+
id: t.at(l.current).id,
|
|
1100
|
+
startReached: k.current,
|
|
1101
|
+
endReached: C.current
|
|
1102
1102
|
}
|
|
1103
1103
|
}), w && u === "fluid" && V({
|
|
1104
1104
|
eventName: "onSlideChangeComplete",
|
|
@@ -1107,32 +1107,32 @@ function Ee({
|
|
|
1107
1107
|
currentItem: {
|
|
1108
1108
|
index: 0,
|
|
1109
1109
|
id: "",
|
|
1110
|
-
startReached:
|
|
1111
|
-
endReached:
|
|
1110
|
+
startReached: k.current,
|
|
1111
|
+
endReached: C.current
|
|
1112
1112
|
}
|
|
1113
1113
|
});
|
|
1114
1114
|
}
|
|
1115
1115
|
});
|
|
1116
1116
|
}
|
|
1117
|
-
function
|
|
1117
|
+
function z() {
|
|
1118
1118
|
const o = S.current.children[0];
|
|
1119
|
-
let
|
|
1120
|
-
return
|
|
1119
|
+
let d = 0;
|
|
1120
|
+
return d = o.getBoundingClientRect()[a === "x" ? "width" : "height"] + i, d;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1123
|
-
const
|
|
1124
|
-
return
|
|
1122
|
+
function q(o) {
|
|
1123
|
+
const d = S.current;
|
|
1124
|
+
return d[a === "x" ? "scrollWidth" : "scrollHeight"] - d.getBoundingClientRect()[a === "x" ? "width" : "height"] - o;
|
|
1125
1125
|
}
|
|
1126
|
-
function
|
|
1126
|
+
function St() {
|
|
1127
1127
|
let o = 0;
|
|
1128
|
-
const
|
|
1128
|
+
const d = getComputedStyle(
|
|
1129
1129
|
document.documentElement
|
|
1130
1130
|
).getPropertyValue(`--${n}-start-end-gutter`);
|
|
1131
|
-
return
|
|
1132
|
-
|
|
1131
|
+
return d.includes("px") && (o = Number(
|
|
1132
|
+
d.replace("px", "")
|
|
1133
1133
|
)), { totalStartEndGutterCssVar: o };
|
|
1134
1134
|
}
|
|
1135
|
-
|
|
1135
|
+
mt(() => {
|
|
1136
1136
|
function o(_, m) {
|
|
1137
1137
|
switch (_) {
|
|
1138
1138
|
case "start":
|
|
@@ -1149,58 +1149,58 @@ function Ee({
|
|
|
1149
1149
|
return 0;
|
|
1150
1150
|
}
|
|
1151
1151
|
}
|
|
1152
|
-
function
|
|
1153
|
-
if (
|
|
1154
|
-
const { totalStartEndGutterCssVar: m } =
|
|
1152
|
+
function d(_) {
|
|
1153
|
+
if (D.current) {
|
|
1154
|
+
const { totalStartEndGutterCssVar: m } = St();
|
|
1155
1155
|
document.documentElement.style.setProperty(
|
|
1156
1156
|
`--${n}-start-end-gutter`,
|
|
1157
1157
|
`${m}px`
|
|
1158
1158
|
);
|
|
1159
|
-
let
|
|
1160
|
-
e && (
|
|
1159
|
+
let O = 0;
|
|
1160
|
+
e && (O = z() * t.length), O -= z() * o(p, s), O -= m / 2, D.current.style.setProperty(
|
|
1161
1161
|
`--${n}-offset-modifier`,
|
|
1162
|
-
`${-
|
|
1163
|
-
), _ && _();
|
|
1162
|
+
`${-O}px`
|
|
1163
|
+
), N(!0), _ && _();
|
|
1164
1164
|
}
|
|
1165
1165
|
}
|
|
1166
|
-
function
|
|
1167
|
-
|
|
1166
|
+
function T() {
|
|
1167
|
+
d(), j({
|
|
1168
1168
|
type: "next",
|
|
1169
|
-
toIndex:
|
|
1169
|
+
toIndex: l.current,
|
|
1170
1170
|
shouldAnimate: !1,
|
|
1171
1171
|
actionType: "resize"
|
|
1172
1172
|
});
|
|
1173
1173
|
}
|
|
1174
|
-
if (r && (L.current =
|
|
1175
|
-
return
|
|
1176
|
-
window.removeEventListener("resize",
|
|
1174
|
+
if (r && (L.current = z() / 4), r && u === "fixed")
|
|
1175
|
+
return d(v), window.addEventListener("resize", T), () => {
|
|
1176
|
+
window.removeEventListener("resize", T);
|
|
1177
1177
|
};
|
|
1178
|
-
}, [r, e, n, a, i,
|
|
1179
|
-
const
|
|
1178
|
+
}, [r, e, n, a, i, p, u]);
|
|
1179
|
+
const Tt = _e(
|
|
1180
1180
|
(o) => {
|
|
1181
|
-
if (
|
|
1181
|
+
if (!P.current)
|
|
1182
1182
|
return;
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1183
|
+
const d = o.dragging, T = o.offset[a === "x" ? 0 : 1], _ = o.movement[a === "x" ? 0 : 1], m = _ > L.current, O = _ < -L.current, I = o.velocity;
|
|
1184
|
+
d && (V({
|
|
1185
1185
|
...o,
|
|
1186
1186
|
eventName: "onDrag",
|
|
1187
1187
|
slideActionType: "drag"
|
|
1188
|
-
}),
|
|
1189
|
-
value:
|
|
1188
|
+
}), H.start({
|
|
1189
|
+
value: T,
|
|
1190
1190
|
immediate: !0,
|
|
1191
1191
|
config: {
|
|
1192
|
-
velocity:
|
|
1192
|
+
velocity: I
|
|
1193
1193
|
}
|
|
1194
|
-
}), E && (m ||
|
|
1194
|
+
}), E && (m || O) && o.cancel()), o.last && (m ? j({
|
|
1195
1195
|
actionType: "drag",
|
|
1196
1196
|
type: "prev"
|
|
1197
|
-
}) :
|
|
1197
|
+
}) : O ? j({
|
|
1198
1198
|
actionType: "drag",
|
|
1199
1199
|
type: "next"
|
|
1200
|
-
}) :
|
|
1201
|
-
value:
|
|
1200
|
+
}) : H.start({
|
|
1201
|
+
value: B.current,
|
|
1202
1202
|
config: {
|
|
1203
|
-
velocity:
|
|
1203
|
+
velocity: I
|
|
1204
1204
|
}
|
|
1205
1205
|
}));
|
|
1206
1206
|
},
|
|
@@ -1211,8 +1211,8 @@ function Ee({
|
|
|
1211
1211
|
...e ? {} : {
|
|
1212
1212
|
bounds: () => ({
|
|
1213
1213
|
right: 0,
|
|
1214
|
-
left: -
|
|
1215
|
-
top: -
|
|
1214
|
+
left: -q(0),
|
|
1215
|
+
top: -q(0),
|
|
1216
1216
|
bottom: 0
|
|
1217
1217
|
})
|
|
1218
1218
|
},
|
|
@@ -1220,15 +1220,15 @@ function Ee({
|
|
|
1220
1220
|
}
|
|
1221
1221
|
);
|
|
1222
1222
|
return {
|
|
1223
|
-
carouselFragment: /* @__PURE__ */
|
|
1223
|
+
carouselFragment: /* @__PURE__ */ It(
|
|
1224
1224
|
"div",
|
|
1225
1225
|
{
|
|
1226
|
-
ref:
|
|
1226
|
+
ref: D,
|
|
1227
1227
|
className: "ReactSpringCarouselContainer",
|
|
1228
1228
|
"data-part": "Container",
|
|
1229
1229
|
"data-part-internal": `${n}-Container`,
|
|
1230
1230
|
children: [
|
|
1231
|
-
/* @__PURE__ */
|
|
1231
|
+
/* @__PURE__ */ J(
|
|
1232
1232
|
"style",
|
|
1233
1233
|
{
|
|
1234
1234
|
dangerouslySetInnerHTML: {
|
|
@@ -1251,6 +1251,8 @@ function Ee({
|
|
|
1251
1251
|
}
|
|
1252
1252
|
[data-part-internal="${n}-Track"] {
|
|
1253
1253
|
display: flex;
|
|
1254
|
+
position: relative;
|
|
1255
|
+
left: ${a === "x" && !$ ? `calc(var(--${n}-start-end-gutter) / 2)` : "0px"};
|
|
1254
1256
|
flex-direction: ${a === "x" ? "row" : "column"};
|
|
1255
1257
|
width: 100%;
|
|
1256
1258
|
height: 100%;
|
|
@@ -1267,20 +1269,20 @@ function Ee({
|
|
|
1267
1269
|
}
|
|
1268
1270
|
}
|
|
1269
1271
|
),
|
|
1270
|
-
/* @__PURE__ */
|
|
1272
|
+
/* @__PURE__ */ J(
|
|
1271
1273
|
"div",
|
|
1272
1274
|
{
|
|
1273
1275
|
ref: S,
|
|
1274
1276
|
className: "ReactSpringCarouselTrack",
|
|
1275
1277
|
"data-part": "Track",
|
|
1276
1278
|
"data-part-internal": `${n}-Track`,
|
|
1277
|
-
...
|
|
1279
|
+
...Tt(),
|
|
1278
1280
|
...u === "freeScroll" ? {
|
|
1279
1281
|
onWheel() {
|
|
1280
1282
|
M.value.stop();
|
|
1281
1283
|
}
|
|
1282
1284
|
} : {},
|
|
1283
|
-
children:
|
|
1285
|
+
children: xt.map((o, d) => /* @__PURE__ */ J(
|
|
1284
1286
|
"div",
|
|
1285
1287
|
{
|
|
1286
1288
|
className: "ReactSpringCarouselItem",
|
|
@@ -1288,21 +1290,21 @@ function Ee({
|
|
|
1288
1290
|
"data-part-internal": `${n}-Item`,
|
|
1289
1291
|
"data-id": o.id,
|
|
1290
1292
|
children: typeof o.renderItem == "function" ? o.renderItem({
|
|
1291
|
-
useListenToCustomEvent:
|
|
1292
|
-
index:
|
|
1293
|
+
useListenToCustomEvent: nt,
|
|
1294
|
+
index: d,
|
|
1293
1295
|
isClonedItem: !!o.isClonedItem
|
|
1294
1296
|
}) : o.renderItem
|
|
1295
1297
|
},
|
|
1296
|
-
`${o.id}-${
|
|
1298
|
+
`${o.id}-${d}`
|
|
1297
1299
|
))
|
|
1298
1300
|
}
|
|
1299
1301
|
)
|
|
1300
1302
|
]
|
|
1301
1303
|
}
|
|
1302
1304
|
),
|
|
1303
|
-
useListenToCustomEvent:
|
|
1304
|
-
slideToNextItem: () =>
|
|
1305
|
-
slideToPrevItem: () =>
|
|
1305
|
+
useListenToCustomEvent: nt,
|
|
1306
|
+
slideToNextItem: () => G(),
|
|
1307
|
+
slideToPrevItem: () => X(),
|
|
1306
1308
|
slideToItem: (o) => {
|
|
1307
1309
|
if (typeof o == "number") {
|
|
1308
1310
|
if (!t[o]) {
|
|
@@ -1311,21 +1313,21 @@ function Ee({
|
|
|
1311
1313
|
);
|
|
1312
1314
|
return;
|
|
1313
1315
|
}
|
|
1314
|
-
o >
|
|
1316
|
+
o > l.current ? G(o) : X(o);
|
|
1315
1317
|
}
|
|
1316
1318
|
if (typeof o == "string") {
|
|
1317
|
-
const
|
|
1318
|
-
if (
|
|
1319
|
+
const d = t.findIndex((T) => T.id === o);
|
|
1320
|
+
if (d < 0) {
|
|
1319
1321
|
console.warn(
|
|
1320
1322
|
`The item you're trying to slide doesn't exist. id: ${o}`
|
|
1321
1323
|
);
|
|
1322
1324
|
return;
|
|
1323
1325
|
}
|
|
1324
|
-
|
|
1326
|
+
d > l.current ? G(d) : X(d);
|
|
1325
1327
|
}
|
|
1326
1328
|
}
|
|
1327
1329
|
};
|
|
1328
1330
|
}
|
|
1329
1331
|
export {
|
|
1330
|
-
|
|
1332
|
+
Te as useSpringCarousel
|
|
1331
1333
|
};
|