react-spring-carousel 3.0.0-beta-2.0.106 → 3.0.0-beta-2.1.0
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 +751 -739
- package/dist/index.umd.js +10 -10
- package/dist/types.d.ts +2 -0
- package/dist/useEventsModule.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useSpringRef as
|
|
3
|
-
import
|
|
4
|
-
function
|
|
5
|
-
return Math.max(t, Math.min(
|
|
1
|
+
import { jsxs as Yt, jsx as et } from "react/jsx-runtime";
|
|
2
|
+
import { useSpringRef as Ht, useSpring as $t } from "@react-spring/web";
|
|
3
|
+
import rt, { useRef as w, useEffect as U, useState as Xt, useCallback as qt, useMemo as nt } from "react";
|
|
4
|
+
function Jt(r, t, e) {
|
|
5
|
+
return Math.max(t, Math.min(r, e));
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
toVector(
|
|
9
|
-
return
|
|
7
|
+
const E = {
|
|
8
|
+
toVector(r, t) {
|
|
9
|
+
return r === void 0 && (r = t), Array.isArray(r) ? r : [r, r];
|
|
10
10
|
},
|
|
11
|
-
add(
|
|
12
|
-
return [
|
|
11
|
+
add(r, t) {
|
|
12
|
+
return [r[0] + t[0], r[1] + t[1]];
|
|
13
13
|
},
|
|
14
|
-
sub(
|
|
15
|
-
return [
|
|
14
|
+
sub(r, t) {
|
|
15
|
+
return [r[0] - t[0], r[1] - t[1]];
|
|
16
16
|
},
|
|
17
|
-
addTo(
|
|
18
|
-
|
|
17
|
+
addTo(r, t) {
|
|
18
|
+
r[0] += t[0], r[1] += t[1];
|
|
19
19
|
},
|
|
20
|
-
subTo(
|
|
21
|
-
|
|
20
|
+
subTo(r, t) {
|
|
21
|
+
r[0] -= t[0], r[1] -= t[1];
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
function
|
|
25
|
-
return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(
|
|
24
|
+
function yt(r, t, e) {
|
|
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 bt(r, t, e, n = 0.15) {
|
|
28
|
+
return n === 0 ? Jt(r, t, e) : r < t ? -yt(t - r, e - t, n) + t : r > e ? +yt(r - e, e - t, n) + e : r;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
const [[
|
|
32
|
-
return [
|
|
30
|
+
function Qt(r, [t, e], [n, s]) {
|
|
31
|
+
const [[a, o], [u, d]] = r;
|
|
32
|
+
return [bt(t, a, o, n), bt(e, u, d, s)];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
if (typeof
|
|
36
|
-
var
|
|
37
|
-
if (
|
|
38
|
-
var n =
|
|
34
|
+
function Zt(r, t) {
|
|
35
|
+
if (typeof r != "object" || r === null) return r;
|
|
36
|
+
var e = r[Symbol.toPrimitive];
|
|
37
|
+
if (e !== void 0) {
|
|
38
|
+
var n = e.call(r, t);
|
|
39
39
|
if (typeof n != "object") return n;
|
|
40
40
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
41
41
|
}
|
|
42
|
-
return (t === "string" ? String : Number)(
|
|
42
|
+
return (t === "string" ? String : Number)(r);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
var t =
|
|
44
|
+
function te(r) {
|
|
45
|
+
var t = Zt(r, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return t =
|
|
50
|
-
value:
|
|
48
|
+
function C(r, t, e) {
|
|
49
|
+
return t = te(t), t in r ? Object.defineProperty(r, t, {
|
|
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
|
|
57
|
-
var
|
|
56
|
+
function _t(r, t) {
|
|
57
|
+
var e = Object.keys(r);
|
|
58
58
|
if (Object.getOwnPropertySymbols) {
|
|
59
|
-
var n = Object.getOwnPropertySymbols(
|
|
59
|
+
var n = Object.getOwnPropertySymbols(r);
|
|
60
60
|
t && (n = n.filter(function(s) {
|
|
61
|
-
return Object.getOwnPropertyDescriptor(
|
|
62
|
-
})),
|
|
61
|
+
return Object.getOwnPropertyDescriptor(r, s).enumerable;
|
|
62
|
+
})), e.push.apply(e, n);
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return e;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function m(r) {
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
|
-
var
|
|
69
|
-
t % 2 ?
|
|
70
|
-
|
|
71
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
72
|
-
Object.defineProperty(
|
|
68
|
+
var e = arguments[t] != null ? arguments[t] : {};
|
|
69
|
+
t % 2 ? _t(Object(e), !0).forEach(function(n) {
|
|
70
|
+
C(r, n, e[n]);
|
|
71
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : _t(Object(e)).forEach(function(n) {
|
|
72
|
+
Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
return
|
|
75
|
+
return r;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const Pt = {
|
|
78
78
|
pointer: {
|
|
79
79
|
start: "down",
|
|
80
80
|
change: "move",
|
|
@@ -96,100 +96,100 @@ const Ct = {
|
|
|
96
96
|
end: "end"
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
function
|
|
100
|
-
return
|
|
99
|
+
function xt(r) {
|
|
100
|
+
return r ? r[0].toUpperCase() + r.slice(1) : "";
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
104
|
-
return
|
|
102
|
+
const ee = ["enter", "leave"];
|
|
103
|
+
function re(r = !1, t) {
|
|
104
|
+
return r && !ee.includes(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
const n =
|
|
108
|
-
return "on" +
|
|
106
|
+
function ne(r, t = "", e = !1) {
|
|
107
|
+
const n = Pt[r], s = n && n[t] || t;
|
|
108
|
+
return "on" + xt(r) + xt(s) + (re(e, s) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
112
|
-
let t =
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
const n =
|
|
110
|
+
const se = ["gotpointercapture", "lostpointercapture"];
|
|
111
|
+
function ie(r) {
|
|
112
|
+
let t = r.substring(2).toLowerCase();
|
|
113
|
+
const e = !!~t.indexOf("passive");
|
|
114
|
+
e && (t = t.replace("passive", ""));
|
|
115
|
+
const n = se.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
|
-
passive:
|
|
119
|
+
passive: e
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
return
|
|
122
|
+
function oe(r, t = "") {
|
|
123
|
+
const e = Pt[r], n = e && e[t] || t;
|
|
124
|
+
return r + n;
|
|
125
125
|
}
|
|
126
|
-
function X(
|
|
127
|
-
return "touches" in
|
|
126
|
+
function X(r) {
|
|
127
|
+
return "touches" in r;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
return X(
|
|
129
|
+
function Ot(r) {
|
|
130
|
+
return X(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
return Array.from(
|
|
134
|
-
var
|
|
135
|
-
return t.target ===
|
|
132
|
+
function ae(r) {
|
|
133
|
+
return Array.from(r.touches).filter((t) => {
|
|
134
|
+
var e, n;
|
|
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
|
|
139
|
-
return
|
|
138
|
+
function ce(r) {
|
|
139
|
+
return r.type === "touchend" || r.type === "touchcancel" ? r.changedTouches : r.targetTouches;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return X(
|
|
141
|
+
function At(r) {
|
|
142
|
+
return X(r) ? ce(r)[0] : r;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function ue(r) {
|
|
145
|
+
return ae(r).map((t) => t.identifier);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
const t =
|
|
149
|
-
return X(
|
|
147
|
+
function st(r) {
|
|
148
|
+
const t = At(r);
|
|
149
|
+
return X(r) ? t.identifier : t.pointerId;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const t =
|
|
151
|
+
function wt(r) {
|
|
152
|
+
const t = At(r);
|
|
153
153
|
return [t.clientX, t.clientY];
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function le(r) {
|
|
156
156
|
const t = {};
|
|
157
|
-
if ("buttons" in
|
|
157
|
+
if ("buttons" in r && (t.buttons = r.buttons), "shiftKey" in r) {
|
|
158
158
|
const {
|
|
159
|
-
shiftKey:
|
|
159
|
+
shiftKey: e,
|
|
160
160
|
altKey: n,
|
|
161
161
|
metaKey: s,
|
|
162
|
-
ctrlKey:
|
|
163
|
-
} =
|
|
162
|
+
ctrlKey: a
|
|
163
|
+
} = r;
|
|
164
164
|
Object.assign(t, {
|
|
165
|
-
shiftKey:
|
|
165
|
+
shiftKey: e,
|
|
166
166
|
altKey: n,
|
|
167
167
|
metaKey: s,
|
|
168
|
-
ctrlKey:
|
|
168
|
+
ctrlKey: a
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
return t;
|
|
172
172
|
}
|
|
173
|
-
function H(
|
|
174
|
-
return typeof
|
|
173
|
+
function H(r, ...t) {
|
|
174
|
+
return typeof r == "function" ? r(...t) : r;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function fe() {
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return
|
|
178
|
+
function de(...r) {
|
|
179
|
+
return r.length === 0 ? fe : r.length === 1 ? r[0] : function() {
|
|
180
180
|
let t;
|
|
181
|
-
for (const
|
|
182
|
-
t =
|
|
181
|
+
for (const e of r)
|
|
182
|
+
t = e.apply(this, arguments) || t;
|
|
183
183
|
return t;
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
return Object.assign({}, t,
|
|
186
|
+
function Et(r, t) {
|
|
187
|
+
return Object.assign({}, t, r || {});
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
class
|
|
191
|
-
constructor(t,
|
|
192
|
-
this.ctrl = t, this.args =
|
|
189
|
+
const he = 32;
|
|
190
|
+
class pe {
|
|
191
|
+
constructor(t, e, n) {
|
|
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
|
}
|
|
194
194
|
get state() {
|
|
195
195
|
return this.ctrl.state[this.key];
|
|
@@ -218,19 +218,19 @@ class oe {
|
|
|
218
218
|
reset() {
|
|
219
219
|
const {
|
|
220
220
|
state: t,
|
|
221
|
-
shared:
|
|
221
|
+
shared: e,
|
|
222
222
|
ingKey: n,
|
|
223
223
|
args: s
|
|
224
224
|
} = this;
|
|
225
|
-
|
|
225
|
+
e[n] = t._active = t.active = t._blocked = t._force = !1, t._step = [!1, !1], t.intentional = !1, t._movement = [0, 0], t._distance = [0, 0], t._direction = [0, 0], t._delta = [0, 0], t._bounds = [[-1 / 0, 1 / 0], [-1 / 0, 1 / 0]], t.args = s, t.axis = void 0, t.memo = void 0, t.elapsedTime = t.timeDelta = 0, t.direction = [0, 0], t.distance = [0, 0], t.overflow = [0, 0], t._movementBound = [!1, !1], t.velocity = [0, 0], t.movement = [0, 0], t.delta = [0, 0], t.timeStamp = 0;
|
|
226
226
|
}
|
|
227
227
|
start(t) {
|
|
228
|
-
const
|
|
229
|
-
|
|
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 ? H(n.from, e) : e.offset, e.offset = e.lastOffset, e.startTime = e.timeStamp = t.timeStamp);
|
|
230
230
|
}
|
|
231
231
|
computeValues(t) {
|
|
232
|
-
const
|
|
233
|
-
|
|
232
|
+
const e = this.state;
|
|
233
|
+
e._values = t, e.values = this.config.transform(t);
|
|
234
234
|
}
|
|
235
235
|
computeInitial() {
|
|
236
236
|
const t = this.state;
|
|
@@ -238,44 +238,44 @@ class oe {
|
|
|
238
238
|
}
|
|
239
239
|
compute(t) {
|
|
240
240
|
const {
|
|
241
|
-
state:
|
|
241
|
+
state: e,
|
|
242
242
|
config: n,
|
|
243
243
|
shared: s
|
|
244
244
|
} = this;
|
|
245
|
-
|
|
246
|
-
let
|
|
247
|
-
if (t && (
|
|
248
|
-
const
|
|
249
|
-
|
|
245
|
+
e.args = this.args;
|
|
246
|
+
let a = 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, le(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, a = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
|
|
248
|
+
const f = e._delta.map(Math.abs);
|
|
249
|
+
E.addTo(e._distance, f);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
|
-
const [
|
|
253
|
-
_step:
|
|
254
|
-
values:
|
|
255
|
-
} =
|
|
256
|
-
if (n.hasCustomTransform ? (
|
|
257
|
-
const
|
|
252
|
+
const [o, u] = e._movement, [d, g] = n.threshold, {
|
|
253
|
+
_step: l,
|
|
254
|
+
values: b
|
|
255
|
+
} = e;
|
|
256
|
+
if (n.hasCustomTransform ? (l[0] === !1 && (l[0] = Math.abs(o) >= d && b[0]), l[1] === !1 && (l[1] = Math.abs(u) >= g && b[1])) : (l[0] === !1 && (l[0] = Math.abs(o) >= d && Math.sign(o) * d), l[1] === !1 && (l[1] = Math.abs(u) >= g && Math.sign(u) * g)), e.intentional = l[0] !== !1 || l[1] !== !1, !e.intentional) return;
|
|
257
|
+
const y = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
|
-
const [
|
|
260
|
-
|
|
259
|
+
const [f, z] = b;
|
|
260
|
+
y[0] = l[0] !== !1 ? f - l[0] : 0, y[1] = l[1] !== !1 ? z - l[1] : 0;
|
|
261
261
|
} else
|
|
262
|
-
|
|
263
|
-
this.restrictToAxis && !
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const [
|
|
267
|
-
|
|
268
|
-
const j =
|
|
269
|
-
if (
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
262
|
+
y[0] = l[0] !== !1 ? o - l[0] : 0, y[1] = l[1] !== !1 ? u - l[1] : 0;
|
|
263
|
+
this.restrictToAxis && !e._blocked && this.restrictToAxis(y);
|
|
264
|
+
const P = e.offset, T = e._active && !e._blocked || e.active;
|
|
265
|
+
T && (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 = H(n.bounds, e)), this.setup && this.setup()), e.movement = y, this.computeOffset()));
|
|
266
|
+
const [k, S] = e.offset, [[A, I], [D, $]] = e._bounds;
|
|
267
|
+
e.overflow = [k < A ? -1 : k > I ? 1 : 0, S < D ? -1 : S > $ ? 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 j = e._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
+
if (e.offset = Qt(e._bounds, e.offset, j), e.delta = E.sub(e.offset, P), this.computeMovement(), T && (!e.last || a > he)) {
|
|
270
|
+
e.delta = E.sub(e.offset, P);
|
|
271
|
+
const f = e.delta.map(Math.abs);
|
|
272
|
+
E.addTo(e.distance, f), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && a > 0 && (e.velocity = [f[0] / a, f[1] / a], e.timeDelta = a);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
emit() {
|
|
276
|
-
const t = this.state,
|
|
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(m(m(m({}, e), t), {}, {
|
|
279
279
|
[this.aliasKey]: t.values
|
|
280
280
|
}));
|
|
281
281
|
s !== void 0 && (t.memo = s);
|
|
@@ -284,16 +284,16 @@ class oe {
|
|
|
284
284
|
this.eventStore.clean(), this.timeoutStore.clean();
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
function
|
|
288
|
-
const n = Math.abs(
|
|
289
|
-
if (n > s && n >
|
|
287
|
+
function ge([r, t], e) {
|
|
288
|
+
const n = Math.abs(r), s = Math.abs(t);
|
|
289
|
+
if (n > s && n > e)
|
|
290
290
|
return "x";
|
|
291
|
-
if (s > n && s >
|
|
291
|
+
if (s > n && s > e)
|
|
292
292
|
return "y";
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class me extends pe {
|
|
295
295
|
constructor(...t) {
|
|
296
|
-
super(...t),
|
|
296
|
+
super(...t), C(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
298
298
|
reset() {
|
|
299
299
|
super.reset(), this.state.axis = void 0;
|
|
@@ -302,18 +302,18 @@ class ce extends oe {
|
|
|
302
302
|
this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
|
|
303
303
|
}
|
|
304
304
|
computeOffset() {
|
|
305
|
-
this.state.offset =
|
|
305
|
+
this.state.offset = E.add(this.state.lastOffset, this.state.movement);
|
|
306
306
|
}
|
|
307
307
|
computeMovement() {
|
|
308
|
-
this.state.movement =
|
|
308
|
+
this.state.movement = E.sub(this.state.offset, this.state.lastOffset);
|
|
309
309
|
}
|
|
310
310
|
axisIntent(t) {
|
|
311
|
-
const
|
|
312
|
-
if (!
|
|
313
|
-
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[
|
|
314
|
-
|
|
311
|
+
const e = this.state, n = this.config;
|
|
312
|
+
if (!e.axis && t) {
|
|
313
|
+
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[Ot(t)] : n.axisThreshold;
|
|
314
|
+
e.axis = ge(e._movement, s);
|
|
315
315
|
}
|
|
316
|
-
|
|
316
|
+
e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
|
|
317
317
|
}
|
|
318
318
|
restrictToAxis(t) {
|
|
319
319
|
if (this.config.axis || this.config.lockDirection)
|
|
@@ -327,98 +327,98 @@ class ce extends oe {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const
|
|
331
|
-
enabled(
|
|
332
|
-
return
|
|
330
|
+
const Tt = (r) => r, St = 0.15, ct = {
|
|
331
|
+
enabled(r = !0) {
|
|
332
|
+
return r;
|
|
333
333
|
},
|
|
334
|
-
eventOptions(
|
|
335
|
-
return
|
|
334
|
+
eventOptions(r, t, e) {
|
|
335
|
+
return m(m({}, e.shared.eventOptions), r);
|
|
336
336
|
},
|
|
337
|
-
preventDefault(
|
|
338
|
-
return
|
|
337
|
+
preventDefault(r = !1) {
|
|
338
|
+
return r;
|
|
339
339
|
},
|
|
340
|
-
triggerAllEvents(
|
|
341
|
-
return
|
|
340
|
+
triggerAllEvents(r = !1) {
|
|
341
|
+
return r;
|
|
342
342
|
},
|
|
343
|
-
rubberband(
|
|
344
|
-
switch (
|
|
343
|
+
rubberband(r = 0) {
|
|
344
|
+
switch (r) {
|
|
345
345
|
case !0:
|
|
346
|
-
return [
|
|
346
|
+
return [St, St];
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
350
|
-
return
|
|
350
|
+
return E.toVector(r);
|
|
351
351
|
}
|
|
352
352
|
},
|
|
353
|
-
from(
|
|
354
|
-
if (typeof
|
|
355
|
-
if (
|
|
353
|
+
from(r) {
|
|
354
|
+
if (typeof r == "function") return r;
|
|
355
|
+
if (r != null) return E.toVector(r);
|
|
356
356
|
},
|
|
357
|
-
transform(
|
|
358
|
-
const n =
|
|
357
|
+
transform(r, t, e) {
|
|
358
|
+
const n = r || e.shared.transform;
|
|
359
359
|
if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
|
|
360
|
-
const s = n ||
|
|
361
|
-
return (
|
|
362
|
-
const
|
|
363
|
-
return (!isFinite(
|
|
360
|
+
const s = n || Tt;
|
|
361
|
+
return (a) => {
|
|
362
|
+
const o = s(a);
|
|
363
|
+
return (!isFinite(o[0]) || !isFinite(o[1])) && console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${o[0]},${[1]}]`), o;
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
return n ||
|
|
366
|
+
return n || Tt;
|
|
367
367
|
},
|
|
368
|
-
threshold(
|
|
369
|
-
return
|
|
368
|
+
threshold(r) {
|
|
369
|
+
return E.toVector(r, 0);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
373
|
-
domTarget(
|
|
374
|
-
if (
|
|
372
|
+
process.env.NODE_ENV === "development" && Object.assign(ct, {
|
|
373
|
+
domTarget(r) {
|
|
374
|
+
if (r !== void 0)
|
|
375
375
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
376
376
|
return NaN;
|
|
377
377
|
},
|
|
378
|
-
lockDirection(
|
|
379
|
-
if (
|
|
378
|
+
lockDirection(r) {
|
|
379
|
+
if (r !== void 0)
|
|
380
380
|
throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");
|
|
381
381
|
return NaN;
|
|
382
382
|
},
|
|
383
|
-
initial(
|
|
384
|
-
if (
|
|
383
|
+
initial(r) {
|
|
384
|
+
if (r !== void 0)
|
|
385
385
|
throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");
|
|
386
386
|
return NaN;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
const
|
|
390
|
-
axis(
|
|
391
|
-
axis:
|
|
389
|
+
const ve = 0, K = m(m({}, ct), {}, {
|
|
390
|
+
axis(r, t, {
|
|
391
|
+
axis: e
|
|
392
392
|
}) {
|
|
393
|
-
if (this.lockDirection =
|
|
393
|
+
if (this.lockDirection = e === "lock", !this.lockDirection) return e;
|
|
394
394
|
},
|
|
395
|
-
axisThreshold(
|
|
396
|
-
return
|
|
395
|
+
axisThreshold(r = ve) {
|
|
396
|
+
return r;
|
|
397
397
|
},
|
|
398
|
-
bounds(
|
|
399
|
-
if (typeof
|
|
400
|
-
return (
|
|
401
|
-
if ("current" in
|
|
402
|
-
return () =>
|
|
403
|
-
if (typeof HTMLElement == "function" &&
|
|
404
|
-
return
|
|
398
|
+
bounds(r = {}) {
|
|
399
|
+
if (typeof r == "function")
|
|
400
|
+
return (a) => K.bounds(r(a));
|
|
401
|
+
if ("current" in r)
|
|
402
|
+
return () => r.current;
|
|
403
|
+
if (typeof HTMLElement == "function" && r instanceof HTMLElement)
|
|
404
|
+
return r;
|
|
405
405
|
const {
|
|
406
406
|
left: t = -1 / 0,
|
|
407
|
-
right:
|
|
407
|
+
right: e = 1 / 0,
|
|
408
408
|
top: n = -1 / 0,
|
|
409
409
|
bottom: s = 1 / 0
|
|
410
|
-
} =
|
|
411
|
-
return [[t,
|
|
410
|
+
} = r;
|
|
411
|
+
return [[t, e], [n, s]];
|
|
412
412
|
}
|
|
413
|
-
}),
|
|
414
|
-
ArrowRight: (
|
|
415
|
-
ArrowLeft: (
|
|
416
|
-
ArrowUp: (
|
|
417
|
-
ArrowDown: (
|
|
413
|
+
}), It = {
|
|
414
|
+
ArrowRight: (r, t = 1) => [r * t, 0],
|
|
415
|
+
ArrowLeft: (r, t = 1) => [-1 * r * t, 0],
|
|
416
|
+
ArrowUp: (r, t = 1) => [0, -1 * r * t],
|
|
417
|
+
ArrowDown: (r, t = 1) => [0, r * t]
|
|
418
418
|
};
|
|
419
|
-
class
|
|
419
|
+
class ye extends me {
|
|
420
420
|
constructor(...t) {
|
|
421
|
-
super(...t),
|
|
421
|
+
super(...t), C(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
423
423
|
reset() {
|
|
424
424
|
super.reset();
|
|
@@ -428,11 +428,11 @@ class le extends ce {
|
|
|
428
428
|
setup() {
|
|
429
429
|
const t = this.state;
|
|
430
430
|
if (t._bounds instanceof HTMLElement) {
|
|
431
|
-
const
|
|
432
|
-
left:
|
|
433
|
-
right:
|
|
434
|
-
top:
|
|
435
|
-
bottom:
|
|
431
|
+
const e = t._bounds.getBoundingClientRect(), n = t.currentTarget.getBoundingClientRect(), s = {
|
|
432
|
+
left: e.left - n.left + t.offset[0],
|
|
433
|
+
right: e.right - n.right + t.offset[0],
|
|
434
|
+
top: e.top - n.top + t.offset[1],
|
|
435
|
+
bottom: e.bottom - n.bottom + t.offset[1]
|
|
436
436
|
};
|
|
437
437
|
t._bounds = K.bounds(s);
|
|
438
438
|
}
|
|
@@ -450,29 +450,29 @@ class le extends ce {
|
|
|
450
450
|
this.pointerClean(), this.state._pointerActive = !1, this.state._keyboardActive = !1, super.clean();
|
|
451
451
|
}
|
|
452
452
|
pointerDown(t) {
|
|
453
|
-
const
|
|
454
|
-
if (t.buttons != null && (Array.isArray(
|
|
453
|
+
const e = this.config, n = this.state;
|
|
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
|
-
|
|
456
|
+
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = st(t), n._pointerActive = !0, this.computeValues(wt(t)), this.computeInitial(), e.preventScrollAxis && Ot(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
|
-
const
|
|
460
|
-
|
|
459
|
+
const e = this.state;
|
|
460
|
+
e._active = !0, e._preventScroll = !0, e._delayed = !1, this.compute(t), this.emit();
|
|
461
461
|
}
|
|
462
462
|
pointerMove(t) {
|
|
463
|
-
const
|
|
464
|
-
if (!
|
|
465
|
-
const s =
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
if (document.pointerLockElement === t.target ?
|
|
469
|
-
this.timeoutStore.remove("dragDelay"),
|
|
463
|
+
const e = this.state, n = this.config;
|
|
464
|
+
if (!e._pointerActive) return;
|
|
465
|
+
const s = st(t);
|
|
466
|
+
if (e._pointerId !== void 0 && s !== e._pointerId) return;
|
|
467
|
+
const a = wt(t);
|
|
468
|
+
if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = E.sub(a, e._values), this.computeValues(a)), E.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
|
|
469
|
+
this.timeoutStore.remove("dragDelay"), e.active = !1, this.startPointerDrag(t);
|
|
470
470
|
return;
|
|
471
471
|
}
|
|
472
|
-
if (n.preventScrollAxis && !
|
|
473
|
-
if (
|
|
474
|
-
if (
|
|
475
|
-
|
|
472
|
+
if (n.preventScrollAxis && !e._preventScroll)
|
|
473
|
+
if (e.axis)
|
|
474
|
+
if (e.axis === n.preventScrollAxis || n.preventScrollAxis === "xy") {
|
|
475
|
+
e._active = !1, this.clean();
|
|
476
476
|
return;
|
|
477
477
|
} else {
|
|
478
478
|
this.timeoutStore.remove("startPointerDrag"), this.startPointerDrag(t);
|
|
@@ -489,19 +489,19 @@ class le extends ce {
|
|
|
489
489
|
} catch {
|
|
490
490
|
process.env.NODE_ENV === "development" && console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.");
|
|
491
491
|
}
|
|
492
|
-
const
|
|
493
|
-
if (!
|
|
494
|
-
const s =
|
|
495
|
-
if (
|
|
492
|
+
const e = this.state, n = this.config;
|
|
493
|
+
if (!e._active || !e._pointerActive) return;
|
|
494
|
+
const s = st(t);
|
|
495
|
+
if (e._pointerId !== void 0 && s !== e._pointerId) return;
|
|
496
496
|
this.state._pointerActive = !1, this.setActive(), this.compute(t);
|
|
497
|
-
const [
|
|
498
|
-
if (
|
|
499
|
-
|
|
497
|
+
const [a, o] = e._distance;
|
|
498
|
+
if (e.tap = a <= n.tapsThreshold && o <= n.tapsThreshold, e.tap && n.filterTaps)
|
|
499
|
+
e._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [
|
|
502
|
-
if (
|
|
503
|
-
const
|
|
504
|
-
|
|
501
|
+
const [u, d] = e._delta, [g, l] = e._movement, [b, y] = n.swipe.velocity, [P, T] = n.swipe.distance, k = n.swipe.duration;
|
|
502
|
+
if (e.elapsedTime < k) {
|
|
503
|
+
const S = Math.abs(u / e.timeDelta), A = Math.abs(d / e.timeDelta);
|
|
504
|
+
S > b && Math.abs(g) > P && (e.swipe[0] = Math.sign(u)), A > y && Math.abs(l) > T && (e.swipe[1] = Math.sign(d));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -510,16 +510,16 @@ class le extends ce {
|
|
|
510
510
|
!this.state.tap && t.detail > 0 && (t.preventDefault(), t.stopPropagation());
|
|
511
511
|
}
|
|
512
512
|
setupPointer(t) {
|
|
513
|
-
const
|
|
513
|
+
const e = this.config, n = e.device;
|
|
514
514
|
if (process.env.NODE_ENV === "development")
|
|
515
515
|
try {
|
|
516
|
-
if (n === "pointer" &&
|
|
516
|
+
if (n === "pointer" && e.preventScrollDelay === void 0) {
|
|
517
517
|
const s = "uv" in t ? t.sourceEvent.currentTarget : t.currentTarget;
|
|
518
518
|
window.getComputedStyle(s).touchAction === "auto" && console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.", s);
|
|
519
519
|
}
|
|
520
520
|
} catch {
|
|
521
521
|
}
|
|
522
|
-
|
|
522
|
+
e.pointerLock && t.currentTarget.requestPointerLock(), e.pointerCapture || (this.eventStore.add(this.sharedConfig.window, n, "change", this.pointerMove.bind(this)), this.eventStore.add(this.sharedConfig.window, n, "end", this.pointerUp.bind(this)), this.eventStore.add(this.sharedConfig.window, n, "cancel", this.pointerUp.bind(this)));
|
|
523
523
|
}
|
|
524
524
|
pointerClean() {
|
|
525
525
|
this.config.pointerLock && document.pointerLockElement === this.state.currentTarget && document.exitPointerLock();
|
|
@@ -528,11 +528,11 @@ class le extends ce {
|
|
|
528
528
|
this.state._preventScroll && t.cancelable && t.preventDefault();
|
|
529
529
|
}
|
|
530
530
|
setupScrollPrevention(t) {
|
|
531
|
-
this.state._preventScroll = !1,
|
|
532
|
-
const
|
|
531
|
+
this.state._preventScroll = !1, be(t);
|
|
532
|
+
const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
|
533
533
|
passive: !1
|
|
534
534
|
});
|
|
535
|
-
this.eventStore.add(this.sharedConfig.window, "touch", "end",
|
|
535
|
+
this.eventStore.add(this.sharedConfig.window, "touch", "end", e), this.eventStore.add(this.sharedConfig.window, "touch", "cancel", e), this.timeoutStore.add("startPointerDrag", this.startPointerDrag.bind(this), this.config.preventScrollDelay, t);
|
|
536
536
|
}
|
|
537
537
|
setupDelayTrigger(t) {
|
|
538
538
|
this.state._delayed = !0, this.timeoutStore.add("dragDelay", () => {
|
|
@@ -540,40 +540,40 @@ class le extends ce {
|
|
|
540
540
|
}, this.config.delay);
|
|
541
541
|
}
|
|
542
542
|
keyDown(t) {
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
543
|
+
const e = It[t.key];
|
|
544
|
+
if (e) {
|
|
545
545
|
const n = this.state, s = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
546
|
-
this.start(t), n._delta =
|
|
546
|
+
this.start(t), n._delta = e(this.config.keyboardDisplacement, s), n._keyboardActive = !0, E.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 It && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
|
|
551
551
|
}
|
|
552
552
|
bind(t) {
|
|
553
|
-
const
|
|
554
|
-
t(
|
|
553
|
+
const e = this.config.device;
|
|
554
|
+
t(e, "start", this.pointerDown.bind(this)), this.config.pointerCapture && (t(e, "change", this.pointerMove.bind(this)), t(e, "end", this.pointerUp.bind(this)), t(e, "cancel", this.pointerUp.bind(this)), t("lostPointerCapture", "", this.pointerUp.bind(this))), this.config.keys && (t("key", "down", this.keyDown.bind(this)), t("key", "up", this.keyUp.bind(this))), this.config.filterTaps && t("click", "", this.pointerClick.bind(this), {
|
|
555
555
|
capture: !0,
|
|
556
556
|
passive: !1
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
function
|
|
561
|
-
"persist" in
|
|
560
|
+
function be(r) {
|
|
561
|
+
"persist" in r && typeof r.persist == "function" && r.persist();
|
|
562
562
|
}
|
|
563
563
|
const G = typeof window < "u" && window.document && window.document.createElement;
|
|
564
|
-
function
|
|
564
|
+
function Nt() {
|
|
565
565
|
return G && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
568
|
-
return
|
|
567
|
+
function _e() {
|
|
568
|
+
return Nt() || G && window.navigator.maxTouchPoints > 1;
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function xe() {
|
|
571
571
|
return G && "onpointerdown" in window;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function we() {
|
|
574
574
|
return G && "exitPointerLock" in window.document;
|
|
575
575
|
}
|
|
576
|
-
function
|
|
576
|
+
function Ee() {
|
|
577
577
|
try {
|
|
578
578
|
return "constructor" in GestureEvent;
|
|
579
579
|
} catch {
|
|
@@ -582,309 +582,309 @@ function me() {
|
|
|
582
582
|
}
|
|
583
583
|
const O = {
|
|
584
584
|
isBrowser: G,
|
|
585
|
-
gesture:
|
|
586
|
-
touch:
|
|
587
|
-
touchscreen:
|
|
588
|
-
pointer:
|
|
589
|
-
pointerLock:
|
|
590
|
-
},
|
|
585
|
+
gesture: Ee(),
|
|
586
|
+
touch: Nt(),
|
|
587
|
+
touchscreen: _e(),
|
|
588
|
+
pointer: xe(),
|
|
589
|
+
pointerLock: we()
|
|
590
|
+
}, Te = 250, Se = 180, Ie = 0.5, ke = 50, Ce = 250, De = 10, kt = {
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
},
|
|
595
|
-
device(
|
|
594
|
+
}, Mt = m(m({}, K), {}, {
|
|
595
|
+
device(r, t, {
|
|
596
596
|
pointer: {
|
|
597
|
-
touch:
|
|
597
|
+
touch: e = !1,
|
|
598
598
|
lock: n = !1,
|
|
599
599
|
mouse: s = !1
|
|
600
600
|
} = {}
|
|
601
601
|
}) {
|
|
602
|
-
return this.pointerLock = n && O.pointerLock, O.touch &&
|
|
602
|
+
return this.pointerLock = n && O.pointerLock, O.touch && e ? "touch" : this.pointerLock ? "mouse" : O.pointer && !s ? "pointer" : O.touch ? "touch" : "mouse";
|
|
603
603
|
},
|
|
604
|
-
preventScrollAxis(
|
|
605
|
-
preventScroll:
|
|
604
|
+
preventScrollAxis(r, t, {
|
|
605
|
+
preventScroll: e
|
|
606
606
|
}) {
|
|
607
|
-
if (this.preventScrollDelay = typeof
|
|
608
|
-
return
|
|
607
|
+
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? Te : void 0, !(!O.touchscreen || e === !1))
|
|
608
|
+
return r || (e !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
|
-
pointerCapture(
|
|
610
|
+
pointerCapture(r, t, {
|
|
611
611
|
pointer: {
|
|
612
|
-
capture:
|
|
612
|
+
capture: e = !0,
|
|
613
613
|
buttons: n = 1,
|
|
614
614
|
keys: s = !0
|
|
615
615
|
} = {}
|
|
616
616
|
}) {
|
|
617
|
-
return this.pointerButtons = n, this.keys = s, !this.pointerLock && this.device === "pointer" &&
|
|
617
|
+
return this.pointerButtons = n, this.keys = s, !this.pointerLock && this.device === "pointer" && e;
|
|
618
618
|
},
|
|
619
|
-
threshold(
|
|
620
|
-
filterTaps:
|
|
619
|
+
threshold(r, t, {
|
|
620
|
+
filterTaps: e = !1,
|
|
621
621
|
tapsThreshold: n = 3,
|
|
622
622
|
axis: s = void 0
|
|
623
623
|
}) {
|
|
624
|
-
const
|
|
625
|
-
return this.filterTaps =
|
|
624
|
+
const a = E.toVector(r, e ? n : s ? 1 : 0);
|
|
625
|
+
return this.filterTaps = e, this.tapsThreshold = n, a;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
628
|
-
velocity:
|
|
629
|
-
distance: t =
|
|
630
|
-
duration:
|
|
628
|
+
velocity: r = Ie,
|
|
629
|
+
distance: t = ke,
|
|
630
|
+
duration: e = Ce
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
|
-
velocity: this.transform(
|
|
634
|
-
distance: this.transform(
|
|
635
|
-
duration:
|
|
633
|
+
velocity: this.transform(E.toVector(r)),
|
|
634
|
+
distance: this.transform(E.toVector(t)),
|
|
635
|
+
duration: e
|
|
636
636
|
};
|
|
637
637
|
},
|
|
638
|
-
delay(
|
|
639
|
-
switch (
|
|
638
|
+
delay(r = 0) {
|
|
639
|
+
switch (r) {
|
|
640
640
|
case !0:
|
|
641
|
-
return
|
|
641
|
+
return Se;
|
|
642
642
|
case !1:
|
|
643
643
|
return 0;
|
|
644
644
|
default:
|
|
645
|
-
return
|
|
645
|
+
return r;
|
|
646
646
|
}
|
|
647
647
|
},
|
|
648
|
-
axisThreshold(
|
|
649
|
-
return
|
|
648
|
+
axisThreshold(r) {
|
|
649
|
+
return r ? m(m({}, kt), r) : kt;
|
|
650
650
|
},
|
|
651
|
-
keyboardDisplacement(
|
|
652
|
-
return
|
|
651
|
+
keyboardDisplacement(r = De) {
|
|
652
|
+
return r;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
656
|
-
useTouch(
|
|
657
|
-
if (
|
|
655
|
+
process.env.NODE_ENV === "development" && Object.assign(Mt, {
|
|
656
|
+
useTouch(r) {
|
|
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 } }`.");
|
|
659
659
|
return NaN;
|
|
660
660
|
},
|
|
661
|
-
experimental_preventWindowScrollY(
|
|
662
|
-
if (
|
|
661
|
+
experimental_preventWindowScrollY(r) {
|
|
662
|
+
if (r !== void 0)
|
|
663
663
|
throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");
|
|
664
664
|
return NaN;
|
|
665
665
|
},
|
|
666
|
-
swipeVelocity(
|
|
667
|
-
if (
|
|
666
|
+
swipeVelocity(r) {
|
|
667
|
+
if (r !== void 0)
|
|
668
668
|
throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");
|
|
669
669
|
return NaN;
|
|
670
670
|
},
|
|
671
|
-
swipeDistance(
|
|
672
|
-
if (
|
|
671
|
+
swipeDistance(r) {
|
|
672
|
+
if (r !== void 0)
|
|
673
673
|
throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");
|
|
674
674
|
return NaN;
|
|
675
675
|
},
|
|
676
|
-
swipeDuration(
|
|
677
|
-
if (
|
|
676
|
+
swipeDuration(r) {
|
|
677
|
+
if (r !== void 0)
|
|
678
678
|
throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");
|
|
679
679
|
return NaN;
|
|
680
680
|
}
|
|
681
681
|
});
|
|
682
|
-
|
|
683
|
-
device(
|
|
684
|
-
shared:
|
|
682
|
+
m(m({}, ct), {}, {
|
|
683
|
+
device(r, t, {
|
|
684
|
+
shared: e,
|
|
685
685
|
pointer: {
|
|
686
686
|
touch: n = !1
|
|
687
687
|
} = {}
|
|
688
688
|
}) {
|
|
689
|
-
if (
|
|
689
|
+
if (e.target && !O.touch && O.gesture) return "gesture";
|
|
690
690
|
if (O.touch && n) return "touch";
|
|
691
691
|
if (O.touchscreen) {
|
|
692
692
|
if (O.pointer) return "pointer";
|
|
693
693
|
if (O.touch) return "touch";
|
|
694
694
|
}
|
|
695
695
|
},
|
|
696
|
-
bounds(
|
|
697
|
-
scaleBounds:
|
|
696
|
+
bounds(r, t, {
|
|
697
|
+
scaleBounds: e = {},
|
|
698
698
|
angleBounds: n = {}
|
|
699
699
|
}) {
|
|
700
|
-
const s = (
|
|
701
|
-
const
|
|
700
|
+
const s = (o) => {
|
|
701
|
+
const u = Et(H(e, o), {
|
|
702
702
|
min: -1 / 0,
|
|
703
703
|
max: 1 / 0
|
|
704
704
|
});
|
|
705
|
-
return [
|
|
706
|
-
},
|
|
707
|
-
const
|
|
705
|
+
return [u.min, u.max];
|
|
706
|
+
}, a = (o) => {
|
|
707
|
+
const u = Et(H(n, o), {
|
|
708
708
|
min: -1 / 0,
|
|
709
709
|
max: 1 / 0
|
|
710
710
|
});
|
|
711
|
-
return [
|
|
711
|
+
return [u.min, u.max];
|
|
712
712
|
};
|
|
713
|
-
return typeof
|
|
713
|
+
return typeof e != "function" && typeof n != "function" ? [s(), a()] : (o) => [s(o), a(o)];
|
|
714
714
|
},
|
|
715
|
-
threshold(
|
|
716
|
-
return this.lockDirection =
|
|
715
|
+
threshold(r, t, e) {
|
|
716
|
+
return this.lockDirection = e.axis === "lock", E.toVector(r, this.lockDirection ? [0.1, 3] : 0);
|
|
717
717
|
},
|
|
718
|
-
modifierKey(
|
|
719
|
-
return
|
|
718
|
+
modifierKey(r) {
|
|
719
|
+
return r === void 0 ? "ctrlKey" : r;
|
|
720
720
|
},
|
|
721
|
-
pinchOnWheel(
|
|
722
|
-
return
|
|
721
|
+
pinchOnWheel(r = !0) {
|
|
722
|
+
return r;
|
|
723
723
|
}
|
|
724
724
|
});
|
|
725
|
-
|
|
726
|
-
mouseOnly: (
|
|
725
|
+
m(m({}, K), {}, {
|
|
726
|
+
mouseOnly: (r = !0) => r
|
|
727
727
|
});
|
|
728
|
-
|
|
729
|
-
mouseOnly: (
|
|
728
|
+
m(m({}, K), {}, {
|
|
729
|
+
mouseOnly: (r = !0) => r
|
|
730
730
|
});
|
|
731
|
-
const
|
|
732
|
-
function
|
|
733
|
-
|
|
731
|
+
const Rt = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map();
|
|
732
|
+
function $e(r) {
|
|
733
|
+
Rt.set(r.key, r.engine), at.set(r.key, r.resolver);
|
|
734
734
|
}
|
|
735
|
-
const
|
|
735
|
+
const Pe = {
|
|
736
736
|
key: "drag",
|
|
737
|
-
engine:
|
|
738
|
-
resolver:
|
|
737
|
+
engine: ye,
|
|
738
|
+
resolver: Mt
|
|
739
739
|
};
|
|
740
|
-
function
|
|
741
|
-
if (
|
|
742
|
-
var
|
|
743
|
-
for (
|
|
744
|
-
s = n[
|
|
745
|
-
return
|
|
740
|
+
function Oe(r, t) {
|
|
741
|
+
if (r == null) return {};
|
|
742
|
+
var e = {}, n = Object.keys(r), s, a;
|
|
743
|
+
for (a = 0; a < n.length; a++)
|
|
744
|
+
s = n[a], !(t.indexOf(s) >= 0) && (e[s] = r[s]);
|
|
745
|
+
return e;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
748
|
-
if (
|
|
749
|
-
var
|
|
747
|
+
function Ae(r, t) {
|
|
748
|
+
if (r == null) return {};
|
|
749
|
+
var e = Oe(r, t), n, s;
|
|
750
750
|
if (Object.getOwnPropertySymbols) {
|
|
751
|
-
var
|
|
752
|
-
for (s = 0; s <
|
|
753
|
-
n =
|
|
751
|
+
var a = Object.getOwnPropertySymbols(r);
|
|
752
|
+
for (s = 0; s < a.length; s++)
|
|
753
|
+
n = a[s], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(r, n) && (e[n] = r[n]);
|
|
754
754
|
}
|
|
755
|
-
return
|
|
755
|
+
return e;
|
|
756
756
|
}
|
|
757
|
-
const
|
|
758
|
-
target(
|
|
759
|
-
if (
|
|
760
|
-
return () => "current" in
|
|
757
|
+
const Ne = {
|
|
758
|
+
target(r) {
|
|
759
|
+
if (r)
|
|
760
|
+
return () => "current" in r ? r.current : r;
|
|
761
761
|
},
|
|
762
|
-
enabled(
|
|
763
|
-
return
|
|
762
|
+
enabled(r = !0) {
|
|
763
|
+
return r;
|
|
764
764
|
},
|
|
765
|
-
window(
|
|
766
|
-
return
|
|
765
|
+
window(r = O.isBrowser ? window : void 0) {
|
|
766
|
+
return r;
|
|
767
767
|
},
|
|
768
768
|
eventOptions({
|
|
769
|
-
passive:
|
|
769
|
+
passive: r = !0,
|
|
770
770
|
capture: t = !1
|
|
771
771
|
} = {}) {
|
|
772
772
|
return {
|
|
773
|
-
passive:
|
|
773
|
+
passive: r,
|
|
774
774
|
capture: t
|
|
775
775
|
};
|
|
776
776
|
},
|
|
777
|
-
transform(
|
|
778
|
-
return
|
|
777
|
+
transform(r) {
|
|
778
|
+
return r;
|
|
779
779
|
}
|
|
780
|
-
},
|
|
781
|
-
function
|
|
782
|
-
const
|
|
780
|
+
}, Me = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
781
|
+
function Y(r = {}, t) {
|
|
782
|
+
const e = {};
|
|
783
783
|
for (const [n, s] of Object.entries(t))
|
|
784
784
|
switch (typeof s) {
|
|
785
785
|
case "function":
|
|
786
786
|
if (process.env.NODE_ENV === "development") {
|
|
787
|
-
const
|
|
788
|
-
Number.isNaN(
|
|
787
|
+
const a = s.call(e, r[n], n, r);
|
|
788
|
+
Number.isNaN(a) || (e[n] = a);
|
|
789
789
|
} else
|
|
790
|
-
|
|
790
|
+
e[n] = s.call(e, r[n], n, r);
|
|
791
791
|
break;
|
|
792
792
|
case "object":
|
|
793
|
-
|
|
793
|
+
e[n] = Y(r[n], s);
|
|
794
794
|
break;
|
|
795
795
|
case "boolean":
|
|
796
|
-
s && (
|
|
796
|
+
s && (e[n] = r[n]);
|
|
797
797
|
break;
|
|
798
798
|
}
|
|
799
|
-
return
|
|
799
|
+
return e;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
802
|
-
const n =
|
|
801
|
+
function Re(r, t, e = {}) {
|
|
802
|
+
const n = r, {
|
|
803
803
|
target: s,
|
|
804
|
-
eventOptions:
|
|
805
|
-
window:
|
|
806
|
-
enabled:
|
|
807
|
-
transform:
|
|
808
|
-
} = n,
|
|
809
|
-
if (
|
|
804
|
+
eventOptions: a,
|
|
805
|
+
window: o,
|
|
806
|
+
enabled: u,
|
|
807
|
+
transform: d
|
|
808
|
+
} = n, g = Ae(n, Me);
|
|
809
|
+
if (e.shared = Y({
|
|
810
810
|
target: s,
|
|
811
|
-
eventOptions:
|
|
812
|
-
window:
|
|
813
|
-
enabled:
|
|
814
|
-
transform:
|
|
815
|
-
},
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
shared:
|
|
819
|
-
},
|
|
811
|
+
eventOptions: a,
|
|
812
|
+
window: o,
|
|
813
|
+
enabled: u,
|
|
814
|
+
transform: d
|
|
815
|
+
}, Ne), t) {
|
|
816
|
+
const l = at.get(t);
|
|
817
|
+
e[t] = Y(m({
|
|
818
|
+
shared: e.shared
|
|
819
|
+
}, g), l);
|
|
820
820
|
} else
|
|
821
|
-
for (const
|
|
822
|
-
const
|
|
823
|
-
if (
|
|
824
|
-
|
|
825
|
-
shared:
|
|
826
|
-
},
|
|
827
|
-
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(
|
|
828
|
-
if (
|
|
821
|
+
for (const l in g) {
|
|
822
|
+
const b = at.get(l);
|
|
823
|
+
if (b)
|
|
824
|
+
e[l] = Y(m({
|
|
825
|
+
shared: e.shared
|
|
826
|
+
}, g[l]), b);
|
|
827
|
+
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(l)) {
|
|
828
|
+
if (l === "domTarget")
|
|
829
829
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
830
|
-
console.warn(`[@use-gesture]: Unknown config key \`${
|
|
830
|
+
console.warn(`[@use-gesture]: Unknown config key \`${l}\` was used. Please read the documentation for further information.`);
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
|
-
return
|
|
833
|
+
return e;
|
|
834
834
|
}
|
|
835
|
-
class
|
|
836
|
-
constructor(t,
|
|
837
|
-
|
|
838
|
-
}
|
|
839
|
-
add(t,
|
|
840
|
-
const
|
|
841
|
-
t.addEventListener(
|
|
842
|
-
const
|
|
843
|
-
t.removeEventListener(
|
|
835
|
+
class Vt {
|
|
836
|
+
constructor(t, e) {
|
|
837
|
+
C(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
|
|
838
|
+
}
|
|
839
|
+
add(t, e, n, s, a) {
|
|
840
|
+
const o = this._listeners, u = oe(e, n), d = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, g = m(m({}, d), a);
|
|
841
|
+
t.addEventListener(u, s, g);
|
|
842
|
+
const l = () => {
|
|
843
|
+
t.removeEventListener(u, s, g), o.delete(l);
|
|
844
844
|
};
|
|
845
|
-
return
|
|
845
|
+
return o.add(l), l;
|
|
846
846
|
}
|
|
847
847
|
clean() {
|
|
848
848
|
this._listeners.forEach((t) => t()), this._listeners.clear();
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
class
|
|
851
|
+
class Ve {
|
|
852
852
|
constructor() {
|
|
853
|
-
|
|
853
|
+
C(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
855
|
-
add(t,
|
|
856
|
-
this.remove(t), this._timeouts.set(t, window.setTimeout(
|
|
855
|
+
add(t, e, n = 140, ...s) {
|
|
856
|
+
this.remove(t), this._timeouts.set(t, window.setTimeout(e, n, ...s));
|
|
857
857
|
}
|
|
858
858
|
remove(t) {
|
|
859
|
-
const
|
|
860
|
-
|
|
859
|
+
const e = this._timeouts.get(t);
|
|
860
|
+
e && window.clearTimeout(e);
|
|
861
861
|
}
|
|
862
862
|
clean() {
|
|
863
863
|
this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
class
|
|
866
|
+
class Le {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
|
|
868
|
+
C(this, "gestures", /* @__PURE__ */ new Set()), C(this, "_targetEventStore", new Vt(this)), C(this, "gestureEventStores", {}), C(this, "gestureTimeoutStores", {}), C(this, "handlers", {}), C(this, "config", {}), C(this, "pointerIds", /* @__PURE__ */ new Set()), C(this, "touchIds", /* @__PURE__ */ new Set()), C(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
|
+
}), je(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(ue(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
|
}
|
|
883
|
-
applyHandlers(t,
|
|
884
|
-
this.handlers = t, this.nativeHandlers =
|
|
883
|
+
applyHandlers(t, e) {
|
|
884
|
+
this.handlers = t, this.nativeHandlers = e;
|
|
885
885
|
}
|
|
886
|
-
applyConfig(t,
|
|
887
|
-
this.config =
|
|
886
|
+
applyConfig(t, e) {
|
|
887
|
+
this.config = Re(t, e, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -895,361 +895,350 @@ class $e {
|
|
|
895
895
|
return this.config.shared.target && this.bind(), () => this._targetEventStore.clean();
|
|
896
896
|
}
|
|
897
897
|
bind(...t) {
|
|
898
|
-
const
|
|
898
|
+
const e = this.config.shared, n = {};
|
|
899
899
|
let s;
|
|
900
|
-
if (!(
|
|
901
|
-
if (
|
|
902
|
-
for (const
|
|
903
|
-
const
|
|
904
|
-
if (
|
|
905
|
-
const
|
|
906
|
-
new
|
|
900
|
+
if (!(e.target && (s = e.target(), !s))) {
|
|
901
|
+
if (e.enabled) {
|
|
902
|
+
for (const o of this.gestures) {
|
|
903
|
+
const u = this.config[o], d = Ct(n, u.eventOptions, !!s);
|
|
904
|
+
if (u.enabled) {
|
|
905
|
+
const g = Rt.get(o);
|
|
906
|
+
new g(this, t, o).bind(d);
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
const
|
|
910
|
-
for (const
|
|
911
|
-
o
|
|
912
|
-
event:
|
|
909
|
+
const a = Ct(n, e.eventOptions, !!s);
|
|
910
|
+
for (const o in this.nativeHandlers)
|
|
911
|
+
a(o, "", (u) => this.nativeHandlers[o](m(m({}, this.state.shared), {}, {
|
|
912
|
+
event: u,
|
|
913
913
|
args: t
|
|
914
914
|
})), void 0, !0);
|
|
915
915
|
}
|
|
916
|
-
for (const
|
|
917
|
-
n[
|
|
916
|
+
for (const a in n)
|
|
917
|
+
n[a] = de(...n[a]);
|
|
918
918
|
if (!s) return n;
|
|
919
|
-
for (const
|
|
919
|
+
for (const a in n) {
|
|
920
920
|
const {
|
|
921
|
-
device:
|
|
922
|
-
capture:
|
|
923
|
-
passive:
|
|
924
|
-
} =
|
|
925
|
-
this._targetEventStore.add(s,
|
|
926
|
-
capture:
|
|
927
|
-
passive:
|
|
921
|
+
device: o,
|
|
922
|
+
capture: u,
|
|
923
|
+
passive: d
|
|
924
|
+
} = ie(a);
|
|
925
|
+
this._targetEventStore.add(s, o, "", n[a], {
|
|
926
|
+
capture: u,
|
|
927
|
+
passive: d
|
|
928
928
|
});
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
function
|
|
934
|
-
|
|
933
|
+
function L(r, t) {
|
|
934
|
+
r.gestures.add(t), r.gestureEventStores[t] = new Vt(r, t), r.gestureTimeoutStores[t] = new Ve();
|
|
935
935
|
}
|
|
936
|
-
function
|
|
937
|
-
t.drag &&
|
|
936
|
+
function je(r, t) {
|
|
937
|
+
t.drag && L(r, "drag"), t.wheel && L(r, "wheel"), t.scroll && L(r, "scroll"), t.move && L(r, "move"), t.pinch && L(r, "pinch"), t.hover && L(r, "hover");
|
|
938
938
|
}
|
|
939
|
-
const
|
|
940
|
-
var
|
|
941
|
-
const
|
|
942
|
-
let
|
|
943
|
-
|
|
939
|
+
const Ct = (r, t, e) => (n, s, a, o = {}, u = !1) => {
|
|
940
|
+
var d, g;
|
|
941
|
+
const l = (d = o.capture) !== null && d !== void 0 ? d : t.capture, b = (g = o.passive) !== null && g !== void 0 ? g : t.passive;
|
|
942
|
+
let y = u ? n : ne(n, s, l);
|
|
943
|
+
e && b && (y += "Passive"), r[y] = r[y] || [], r[y].push(a);
|
|
944
944
|
};
|
|
945
|
-
function
|
|
946
|
-
const s =
|
|
947
|
-
if (s.applyHandlers(
|
|
945
|
+
function Be(r, t = {}, e, n) {
|
|
946
|
+
const s = rt.useMemo(() => new Le(r), []);
|
|
947
|
+
if (s.applyHandlers(r, n), s.applyConfig(t, e), rt.useEffect(s.effect.bind(s)), rt.useEffect(() => s.clean.bind(s), []), t.target === void 0)
|
|
948
948
|
return s.bind.bind(s);
|
|
949
949
|
}
|
|
950
|
-
function
|
|
951
|
-
return
|
|
952
|
-
drag:
|
|
950
|
+
function Ue(r, t) {
|
|
951
|
+
return $e(Pe), Be({
|
|
952
|
+
drag: r
|
|
953
953
|
}, t || {}, "drag");
|
|
954
954
|
}
|
|
955
|
-
const
|
|
956
|
-
function
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
n(
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
return
|
|
966
|
-
var
|
|
967
|
-
(
|
|
968
|
-
|
|
969
|
-
|
|
955
|
+
const it = "RSC::Event";
|
|
956
|
+
function Ke() {
|
|
957
|
+
const r = w(null), t = w(null);
|
|
958
|
+
return t.current === null && (t.current = {
|
|
959
|
+
useListenToCustomEvent(e) {
|
|
960
|
+
U(() => {
|
|
961
|
+
r.current || (r.current = document.createElement("div"));
|
|
962
|
+
function n(s) {
|
|
963
|
+
e(s.detail);
|
|
964
|
+
}
|
|
965
|
+
return r.current.addEventListener(it, n, !1), () => {
|
|
966
|
+
var s;
|
|
967
|
+
(s = r.current) == null || s.removeEventListener(
|
|
968
|
+
it,
|
|
969
|
+
n,
|
|
970
970
|
!1
|
|
971
971
|
);
|
|
972
972
|
};
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
973
|
+
}, [e]);
|
|
974
|
+
},
|
|
975
|
+
emitEvent(e) {
|
|
976
|
+
if (r.current) {
|
|
977
|
+
const n = new CustomEvent(it, {
|
|
978
|
+
detail: e
|
|
979
|
+
});
|
|
980
|
+
r.current.dispatchEvent(n);
|
|
981
|
+
}
|
|
981
982
|
}
|
|
982
|
-
}
|
|
983
|
-
return {
|
|
984
|
-
useListenToCustomEvent: t,
|
|
985
|
-
emitEvent: r
|
|
986
|
-
};
|
|
983
|
+
}), t.current;
|
|
987
984
|
}
|
|
988
|
-
function
|
|
989
|
-
let t =
|
|
985
|
+
function Ge(r) {
|
|
986
|
+
let t = r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, "");
|
|
990
987
|
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
988
|
}
|
|
992
|
-
function
|
|
993
|
-
init:
|
|
989
|
+
function Xe({
|
|
990
|
+
init: r = !0,
|
|
994
991
|
items: t,
|
|
995
|
-
withLoop:
|
|
992
|
+
withLoop: e = !1,
|
|
996
993
|
id: n,
|
|
997
994
|
gutter: s = [{ breakpoint: 0, gutter: 0, startEndGutter: 0 }],
|
|
998
|
-
itemsPerSlide:
|
|
999
|
-
carouselAxis:
|
|
1000
|
-
startingPosition:
|
|
1001
|
-
enableGestures:
|
|
1002
|
-
slideWhenDragThresholdIsReached:
|
|
1003
|
-
slideType:
|
|
1004
|
-
initialActiveItem:
|
|
995
|
+
itemsPerSlide: a = [{ breakpoint: 0, itemsPerSlide: 1 }],
|
|
996
|
+
carouselAxis: o = "x",
|
|
997
|
+
startingPosition: u = "start",
|
|
998
|
+
enableGestures: d = !0,
|
|
999
|
+
slideWhenDragThresholdIsReached: g = !0,
|
|
1000
|
+
slideType: l = "item",
|
|
1001
|
+
initialActiveItem: b = 0
|
|
1005
1002
|
}) {
|
|
1006
|
-
const [
|
|
1007
|
-
|
|
1003
|
+
const [y, P] = Xt(!1), T = w(r), k = w(null), S = w(null), A = w(0), I = w(0), D = w(!e), $ = w(!1), j = w(0), f = w(0), z = w(t);
|
|
1004
|
+
z.current = t;
|
|
1005
|
+
const ut = w(e);
|
|
1006
|
+
ut.current = e;
|
|
1007
|
+
const lt = w(!1);
|
|
1008
|
+
function ft(i) {
|
|
1008
1009
|
if (i === void 0) return 0;
|
|
1009
1010
|
if (typeof i == "number")
|
|
1010
1011
|
return t[i] ? i : (console.warn(
|
|
1011
1012
|
`initialActiveItem: item at index ${i} doesn't exist.`
|
|
1012
1013
|
), 0);
|
|
1013
|
-
const
|
|
1014
|
-
return
|
|
1014
|
+
const c = t.findIndex((h) => h.id === i);
|
|
1015
|
+
return c < 0 ? (console.warn(`initialActiveItem: item with id "${i}" doesn't exist.`), 0) : c;
|
|
1015
1016
|
}
|
|
1016
|
-
const W =
|
|
1017
|
+
const W = Ht(), q = $t({
|
|
1017
1018
|
value: 0,
|
|
1018
1019
|
ref: W,
|
|
1019
1020
|
onChange({ value: i }) {
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1021
|
+
const c = o === "x" ? `translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${i.value}px + var(--${n}-offset-modifier)), 0px)`;
|
|
1022
|
+
S.current.style.transform = c;
|
|
1022
1023
|
}
|
|
1023
|
-
}),
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
id: `prev-repeated-item-${i.id}`,
|
|
1027
|
-
isClonedItem: !0
|
|
1028
|
-
})),
|
|
1029
|
-
...t,
|
|
1030
|
-
...t.map((i) => ({
|
|
1031
|
-
...i,
|
|
1032
|
-
id: `next-repeated-item-${i.id}`,
|
|
1033
|
-
isClonedItem: !0
|
|
1034
|
-
}))
|
|
1035
|
-
] : t, { useListenToCustomEvent: ct, emitEvent: B } = Ne();
|
|
1036
|
-
function ut() {
|
|
1037
|
-
const { totalGutterCssVar: i } = lt();
|
|
1024
|
+
}), Lt = e ? t.length * 3 : t.length, { useListenToCustomEvent: dt, emitEvent: B } = Ke();
|
|
1025
|
+
function ht() {
|
|
1026
|
+
const { totalGutterCssVar: i } = pt();
|
|
1038
1027
|
return i;
|
|
1039
1028
|
}
|
|
1040
|
-
function
|
|
1041
|
-
if (
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1029
|
+
function jt() {
|
|
1030
|
+
if (k.current) {
|
|
1031
|
+
const c = window.getComputedStyle(
|
|
1032
|
+
k.current
|
|
1044
1033
|
).getPropertyValue(`--${n}-items-per-slide`).trim();
|
|
1045
|
-
return Number(
|
|
1034
|
+
return Number(c) || 1;
|
|
1046
1035
|
}
|
|
1047
1036
|
return 1;
|
|
1048
1037
|
}
|
|
1049
1038
|
function J(i) {
|
|
1050
|
-
|
|
1039
|
+
T.current && ($.current || R({
|
|
1051
1040
|
type: "next",
|
|
1052
1041
|
toIndex: i,
|
|
1053
1042
|
actionType: "click"
|
|
1054
1043
|
}));
|
|
1055
1044
|
}
|
|
1056
1045
|
function Q(i) {
|
|
1057
|
-
|
|
1046
|
+
T.current && (D.current || R({
|
|
1058
1047
|
type: "prev",
|
|
1059
1048
|
toIndex: i,
|
|
1060
1049
|
actionType: "click"
|
|
1061
1050
|
}));
|
|
1062
1051
|
}
|
|
1063
|
-
function
|
|
1052
|
+
function R({
|
|
1064
1053
|
type: i,
|
|
1065
|
-
shouldAnimate:
|
|
1066
|
-
toIndex:
|
|
1067
|
-
actionType:
|
|
1054
|
+
shouldAnimate: c = !0,
|
|
1055
|
+
toIndex: h,
|
|
1056
|
+
actionType: v
|
|
1068
1057
|
}) {
|
|
1069
|
-
var
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
let
|
|
1073
|
-
if (i === "next" && (
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1058
|
+
var gt, mt;
|
|
1059
|
+
const _ = !c;
|
|
1060
|
+
D.current = !1, $.current = !1;
|
|
1061
|
+
let p = q.value.get(), x = 0;
|
|
1062
|
+
if (i === "next" && (f.current += 1), i === "prev" && (f.current === 0 ? f.current = t.length - 1 : f.current -= 1), h !== void 0 && (f.current = h), i === "next") {
|
|
1063
|
+
const M = Z(
|
|
1064
|
+
e ? I.current * (t.length * 2) : 0
|
|
1076
1065
|
);
|
|
1077
|
-
|
|
1066
|
+
x = -(f.current * I.current), e && f.current === t.length && (f.current = 0, p = p + I.current * t.length, x = 0), !e && (Math.abs(x) >= M || f.current === t.length - 1) && ($.current = !0, x = -M);
|
|
1078
1067
|
}
|
|
1079
|
-
i === "prev" && (
|
|
1080
|
-
const N =
|
|
1081
|
-
|
|
1068
|
+
i === "prev" && (x = -(f.current * I.current), f.current === t.length - 1 && (p = p - t.length * I.current), !e && x >= 0 && (D.current = !0, x = 0)), A.current = x;
|
|
1069
|
+
const N = e ? f.current % t.length : f.current, V = e ? t.length + f.current % t.length : f.current;
|
|
1070
|
+
v === "resize" ? (x = -(f.current * I.current), B({
|
|
1082
1071
|
eventName: "onResize",
|
|
1083
|
-
sliceActionType:
|
|
1072
|
+
sliceActionType: v,
|
|
1084
1073
|
slideDirection: i,
|
|
1085
1074
|
currentItem: {
|
|
1086
|
-
id: ((
|
|
1075
|
+
id: ((gt = t.at(N)) == null ? void 0 : gt.id) ?? "",
|
|
1087
1076
|
index: N,
|
|
1088
1077
|
trackIndex: V,
|
|
1089
|
-
startReached:
|
|
1090
|
-
endReached:
|
|
1078
|
+
startReached: D.current,
|
|
1079
|
+
endReached: $.current
|
|
1091
1080
|
}
|
|
1092
1081
|
})) : B({
|
|
1093
1082
|
eventName: "onSlideStartChange",
|
|
1094
|
-
sliceActionType:
|
|
1083
|
+
sliceActionType: v,
|
|
1095
1084
|
slideDirection: i,
|
|
1096
1085
|
nextItem: {
|
|
1097
1086
|
index: N,
|
|
1098
|
-
id: ((
|
|
1087
|
+
id: ((mt = t.at(N)) == null ? void 0 : mt.id) ?? "",
|
|
1099
1088
|
trackIndex: V,
|
|
1100
|
-
startReached:
|
|
1101
|
-
endReached:
|
|
1089
|
+
startReached: D.current,
|
|
1090
|
+
endReached: $.current
|
|
1102
1091
|
}
|
|
1103
1092
|
}), W.start({
|
|
1104
|
-
immediate:
|
|
1093
|
+
immediate: _,
|
|
1105
1094
|
from: {
|
|
1106
|
-
value:
|
|
1095
|
+
value: p
|
|
1107
1096
|
},
|
|
1108
1097
|
to: {
|
|
1109
|
-
value:
|
|
1098
|
+
value: x
|
|
1110
1099
|
},
|
|
1111
|
-
onChange({ value:
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1100
|
+
onChange({ value: M }) {
|
|
1101
|
+
const F = o === "x" ? `translate3d(calc(${M.value}px + var(--${n}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${M.value}px + var(--${n}-offset-modifier)), 0px)`;
|
|
1102
|
+
S.current.style.transform = F;
|
|
1114
1103
|
},
|
|
1115
|
-
onRest({ finished:
|
|
1116
|
-
var
|
|
1117
|
-
if (
|
|
1118
|
-
const
|
|
1104
|
+
onRest({ finished: M }) {
|
|
1105
|
+
var F;
|
|
1106
|
+
if (M) {
|
|
1107
|
+
const vt = e ? f.current % t.length : f.current, Ft = e ? t.length + f.current % t.length : f.current;
|
|
1119
1108
|
B({
|
|
1120
1109
|
eventName: "onSlideChangeComplete",
|
|
1121
|
-
sliceActionType:
|
|
1110
|
+
sliceActionType: v,
|
|
1122
1111
|
slideDirection: i,
|
|
1123
1112
|
currentItem: {
|
|
1124
|
-
index:
|
|
1125
|
-
id: ((
|
|
1126
|
-
trackIndex:
|
|
1127
|
-
startReached:
|
|
1128
|
-
endReached:
|
|
1113
|
+
index: vt,
|
|
1114
|
+
id: ((F = t.at(vt)) == null ? void 0 : F.id) ?? "",
|
|
1115
|
+
trackIndex: Ft,
|
|
1116
|
+
startReached: D.current,
|
|
1117
|
+
endReached: $.current
|
|
1129
1118
|
}
|
|
1130
1119
|
});
|
|
1131
1120
|
}
|
|
1132
1121
|
}
|
|
1133
1122
|
});
|
|
1134
1123
|
}
|
|
1135
|
-
function
|
|
1136
|
-
const i =
|
|
1137
|
-
let
|
|
1138
|
-
return
|
|
1124
|
+
function Bt() {
|
|
1125
|
+
const i = S.current;
|
|
1126
|
+
let c = 0;
|
|
1127
|
+
return l === "item" ? c = i.children[0].getBoundingClientRect()[o === "x" ? "width" : "height"] + ht() : c = i.getBoundingClientRect()[o === "x" ? "width" : "height"] + ht(), c;
|
|
1139
1128
|
}
|
|
1140
1129
|
function Z(i) {
|
|
1141
|
-
const
|
|
1142
|
-
return
|
|
1143
|
-
}
|
|
1144
|
-
function
|
|
1145
|
-
let i = 0,
|
|
1146
|
-
if (
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
),
|
|
1150
|
-
|
|
1151
|
-
|
|
1130
|
+
const c = S.current;
|
|
1131
|
+
return c[o === "x" ? "scrollWidth" : "scrollHeight"] - c.getBoundingClientRect()[o === "x" ? "width" : "height"] - i;
|
|
1132
|
+
}
|
|
1133
|
+
function pt() {
|
|
1134
|
+
let i = 0, c = 0;
|
|
1135
|
+
if (k.current) {
|
|
1136
|
+
const h = window.getComputedStyle(
|
|
1137
|
+
k.current
|
|
1138
|
+
), v = h.getPropertyValue(`--${n}-start-end-gutter`).trim();
|
|
1139
|
+
v.includes("px") && (i = Number(
|
|
1140
|
+
v.replace("px", "")
|
|
1152
1141
|
));
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1142
|
+
const _ = h.getPropertyValue(`--${n}-gutter`).trim();
|
|
1143
|
+
_.includes("px") && (c = Number(_.replace("px", "")));
|
|
1155
1144
|
}
|
|
1156
|
-
return { totalStartEndGutterCssVar: i, totalGutterCssVar:
|
|
1145
|
+
return { totalStartEndGutterCssVar: i, totalGutterCssVar: c };
|
|
1157
1146
|
}
|
|
1158
1147
|
U(() => {
|
|
1159
|
-
function i(
|
|
1160
|
-
const
|
|
1161
|
-
switch (
|
|
1148
|
+
function i(_) {
|
|
1149
|
+
const p = jt();
|
|
1150
|
+
switch (_) {
|
|
1162
1151
|
case "start":
|
|
1163
1152
|
return 0;
|
|
1164
1153
|
case "middle-start":
|
|
1165
|
-
return Math.floor((
|
|
1154
|
+
return Math.floor((p - 1) * 0.25);
|
|
1166
1155
|
case "center":
|
|
1167
|
-
return Math.floor((
|
|
1156
|
+
return Math.floor((p - 1) * 0.5);
|
|
1168
1157
|
case "middle-end":
|
|
1169
|
-
return Math.floor((
|
|
1158
|
+
return Math.floor((p - 1) * 0.75);
|
|
1170
1159
|
case "end":
|
|
1171
|
-
return
|
|
1160
|
+
return p - 1;
|
|
1172
1161
|
default:
|
|
1173
1162
|
return 0;
|
|
1174
1163
|
}
|
|
1175
1164
|
}
|
|
1176
|
-
function
|
|
1177
|
-
|
|
1178
|
-
const { totalStartEndGutterCssVar:
|
|
1179
|
-
let
|
|
1180
|
-
|
|
1165
|
+
function c() {
|
|
1166
|
+
I.current = Bt(), j.current = I.current / 4;
|
|
1167
|
+
const { totalStartEndGutterCssVar: _ } = pt();
|
|
1168
|
+
let p = 0;
|
|
1169
|
+
e && (p = I.current * t.length), p -= I.current * i(u), p -= _ / 2, k.current.style.setProperty(
|
|
1181
1170
|
`--${n}-offset-modifier`,
|
|
1182
|
-
`${-
|
|
1171
|
+
`${-p}px`
|
|
1183
1172
|
);
|
|
1184
1173
|
}
|
|
1185
|
-
function
|
|
1186
|
-
if (
|
|
1187
|
-
const
|
|
1188
|
-
B({ eventName: "onInit", index:
|
|
1174
|
+
function h(_) {
|
|
1175
|
+
if (k.current && (c(), P(!0), _)) {
|
|
1176
|
+
const p = ft(b), x = e ? t.length + p % t.length : p;
|
|
1177
|
+
B({ eventName: "onInit", index: p, trackIndex: x });
|
|
1189
1178
|
}
|
|
1190
1179
|
}
|
|
1191
|
-
function
|
|
1192
|
-
|
|
1180
|
+
function v() {
|
|
1181
|
+
h(), R({
|
|
1193
1182
|
type: "resize",
|
|
1194
|
-
toIndex:
|
|
1183
|
+
toIndex: f.current,
|
|
1195
1184
|
shouldAnimate: !1,
|
|
1196
1185
|
actionType: "resize"
|
|
1197
1186
|
});
|
|
1198
1187
|
}
|
|
1199
|
-
if (
|
|
1200
|
-
return
|
|
1201
|
-
window.removeEventListener("resize",
|
|
1188
|
+
if (r)
|
|
1189
|
+
return T.current = !0, lt.current ? v() : (h(!0), lt.current = !0), window.addEventListener("resize", v), () => {
|
|
1190
|
+
window.removeEventListener("resize", v);
|
|
1202
1191
|
};
|
|
1203
|
-
}, [
|
|
1204
|
-
const i =
|
|
1205
|
-
|
|
1192
|
+
}, [r, n, o]), U(() => {
|
|
1193
|
+
const i = ft(b);
|
|
1194
|
+
r && i !== f.current && R({
|
|
1206
1195
|
type: "next",
|
|
1207
1196
|
toIndex: i,
|
|
1208
1197
|
actionType: "resize",
|
|
1209
1198
|
shouldAnimate: !1
|
|
1210
1199
|
});
|
|
1211
|
-
}, [
|
|
1212
|
-
const
|
|
1200
|
+
}, [r, b]);
|
|
1201
|
+
const tt = d, Ut = Ue(
|
|
1213
1202
|
(i) => {
|
|
1214
|
-
if (!
|
|
1203
|
+
if (!T.current)
|
|
1215
1204
|
return;
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1205
|
+
const c = i.dragging, h = i.offset[o === "x" ? 0 : 1], v = i.movement[o === "x" ? 0 : 1], _ = v > j.current, p = v < -j.current, x = i.velocity;
|
|
1206
|
+
c && (B({
|
|
1218
1207
|
...i,
|
|
1219
1208
|
eventName: "onDrag",
|
|
1220
1209
|
slideActionType: "drag"
|
|
1221
1210
|
}), W.start({
|
|
1222
|
-
value:
|
|
1211
|
+
value: h,
|
|
1223
1212
|
immediate: !0,
|
|
1224
1213
|
config: {
|
|
1225
|
-
velocity:
|
|
1214
|
+
velocity: x
|
|
1226
1215
|
},
|
|
1227
1216
|
onChange({ value: N }) {
|
|
1228
|
-
const V =
|
|
1229
|
-
|
|
1217
|
+
const V = o === "x" ? `translate3d(calc(${N.value}px + var(--${n}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${N.value}px + var(--${n}-offset-modifier)), 0px)`;
|
|
1218
|
+
S.current.style.transform = V;
|
|
1230
1219
|
}
|
|
1231
|
-
}),
|
|
1220
|
+
}), g && (_ || p) && i.cancel()), i.last && (_ ? (R({
|
|
1232
1221
|
actionType: "drag",
|
|
1233
1222
|
type: "prev"
|
|
1234
|
-
}), i.cancel()) :
|
|
1223
|
+
}), i.cancel()) : p ? (R({
|
|
1235
1224
|
actionType: "drag",
|
|
1236
1225
|
type: "next"
|
|
1237
1226
|
}), i.cancel()) : (W.start({
|
|
1238
1227
|
value: A.current,
|
|
1239
1228
|
config: {
|
|
1240
|
-
velocity:
|
|
1229
|
+
velocity: x
|
|
1241
1230
|
},
|
|
1242
1231
|
onChange({ value: N }) {
|
|
1243
|
-
const V =
|
|
1244
|
-
|
|
1232
|
+
const V = o === "x" ? `translate3d(calc(${N.value}px + var(--${n}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${N.value}px + var(--${n}-offset-modifier)), 0px)`;
|
|
1233
|
+
S.current.style.transform = V;
|
|
1245
1234
|
}
|
|
1246
1235
|
}), i.cancel()));
|
|
1247
1236
|
},
|
|
1248
1237
|
{
|
|
1249
|
-
enabled:
|
|
1250
|
-
axis:
|
|
1251
|
-
rubberband: !
|
|
1252
|
-
...
|
|
1238
|
+
enabled: tt,
|
|
1239
|
+
axis: o,
|
|
1240
|
+
rubberband: !e,
|
|
1241
|
+
...e ? {} : {
|
|
1253
1242
|
bounds: () => ({
|
|
1254
1243
|
right: 0,
|
|
1255
1244
|
left: -Z(0),
|
|
@@ -1259,27 +1248,26 @@ function Ue({
|
|
|
1259
1248
|
},
|
|
1260
1249
|
from: () => [q.value.get(), q.value.get()]
|
|
1261
1250
|
}
|
|
1262
|
-
)
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
__html: Le(`
|
|
1251
|
+
), Kt = qt((i) => {
|
|
1252
|
+
var p;
|
|
1253
|
+
const c = z.current, v = ut.current ? c.length + f.current % c.length : f.current;
|
|
1254
|
+
if (typeof i == "number") return v === i;
|
|
1255
|
+
const _ = f.current % c.length;
|
|
1256
|
+
return i === ((p = c[_]) == null ? void 0 : p.id);
|
|
1257
|
+
}, []), Gt = nt(
|
|
1258
|
+
() => Array.from({ length: t.length }, (i, c) => () => {
|
|
1259
|
+
const h = e ? f.current % t.length : f.current;
|
|
1260
|
+
return e ? c === (h + 1) % t.length : h + 1 >= t.length ? !1 : c === h + 1;
|
|
1261
|
+
}),
|
|
1262
|
+
[t.length, e]
|
|
1263
|
+
), zt = nt(
|
|
1264
|
+
() => Array.from({ length: t.length }, (i, c) => () => {
|
|
1265
|
+
const h = e ? f.current % t.length : f.current;
|
|
1266
|
+
return e ? c === (h - 1 + t.length) % t.length : h - 1 < 0 ? !1 : c === h - 1;
|
|
1267
|
+
}),
|
|
1268
|
+
[t.length, e]
|
|
1269
|
+
), Wt = nt(
|
|
1270
|
+
() => Ge(`
|
|
1283
1271
|
[data-part-internal="${n}-Container"] {
|
|
1284
1272
|
display: flex;
|
|
1285
1273
|
width: 100%;
|
|
@@ -1288,19 +1276,19 @@ function Ue({
|
|
|
1288
1276
|
--${n}-items-per-slide: 1;
|
|
1289
1277
|
--${n}-offset-position: 0px;
|
|
1290
1278
|
--${n}-offset-modifier: 0px;
|
|
1291
|
-
--${n}-scroll-x-value: ${
|
|
1292
|
-
--${n}-scroll-y-value: ${
|
|
1279
|
+
--${n}-scroll-x-value: ${o === "x" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
|
|
1280
|
+
--${n}-scroll-y-value: ${o === "y" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
|
|
1293
1281
|
--${n}-gutter: 0px;
|
|
1294
1282
|
--${n}-start-end-gutter: 0px;
|
|
1295
|
-
touch-action: ${
|
|
1283
|
+
touch-action: ${tt ? o === "x" ? "pan-y" : "pan-x" : "auto"};
|
|
1296
1284
|
}
|
|
1297
1285
|
[data-part-internal="${n}-Track"] {
|
|
1298
1286
|
display: flex;
|
|
1299
1287
|
position: relative;
|
|
1300
1288
|
--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));
|
|
1301
|
-
left: ${
|
|
1302
|
-
top: ${
|
|
1303
|
-
flex-direction: ${
|
|
1289
|
+
left: ${e && o === "x" && !y ? "var(--initial-offset-modifier)" : "0px"};
|
|
1290
|
+
top: ${e && o === "y" && !y ? "var(--initial-offset-modifier)" : "0px"};
|
|
1291
|
+
flex-direction: ${o === "x" ? "row" : "column"};
|
|
1304
1292
|
width: 100%;
|
|
1305
1293
|
height: 100%;
|
|
1306
1294
|
gap: var(--${n}-gutter);
|
|
@@ -1310,8 +1298,8 @@ function Ue({
|
|
|
1310
1298
|
display: flex;
|
|
1311
1299
|
flex: 1 0 calc(100% / var(--${n}-items-per-slide) - calc(var(--${n}-gutter) * (var(--${n}-items-per-slide) - 1)) / var(--${n}-items-per-slide) - calc(var(--${n}-start-end-gutter) / var(--${n}-items-per-slide)));
|
|
1312
1300
|
}
|
|
1313
|
-
${s && s.length > 0 ? s.sort((i,
|
|
1314
|
-
|
|
1301
|
+
${s && s.length > 0 ? s.slice().sort((i, c) => i.breakpoint - c.breakpoint).map(
|
|
1302
|
+
(i) => `
|
|
1315
1303
|
@media ${i.media || `(min-width: ${i.breakpoint}px)`} {
|
|
1316
1304
|
[data-part-internal="${n}-Container"] {
|
|
1317
1305
|
--${n}-gutter: ${i.gutter || 0}px;
|
|
@@ -1319,52 +1307,76 @@ function Ue({
|
|
|
1319
1307
|
}
|
|
1320
1308
|
}
|
|
1321
1309
|
`
|
|
1322
|
-
|
|
1323
|
-
${
|
|
1324
|
-
|
|
1310
|
+
).join("") : ""}
|
|
1311
|
+
${a && a.length > 0 ? a.slice().sort((i, c) => i.breakpoint - c.breakpoint).map(
|
|
1312
|
+
(i) => `
|
|
1325
1313
|
@media ${i.media || `(min-width: ${i.breakpoint}px)`} {
|
|
1326
1314
|
[data-part-internal="${n}-Container"] {
|
|
1327
1315
|
--${n}-items-per-slide: ${i.itemsPerSlide || 1};
|
|
1328
1316
|
}
|
|
1329
1317
|
}
|
|
1330
1318
|
`
|
|
1331
|
-
|
|
1332
|
-
`)
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1319
|
+
).join("") : ""}
|
|
1320
|
+
`),
|
|
1321
|
+
[
|
|
1322
|
+
n,
|
|
1323
|
+
o,
|
|
1324
|
+
tt,
|
|
1325
|
+
t.length,
|
|
1326
|
+
e,
|
|
1327
|
+
y,
|
|
1328
|
+
s,
|
|
1329
|
+
a
|
|
1330
|
+
]
|
|
1331
|
+
);
|
|
1332
|
+
return {
|
|
1333
|
+
carouselFragment: /* @__PURE__ */ Yt(
|
|
1334
|
+
"div",
|
|
1335
|
+
{
|
|
1336
|
+
ref: k,
|
|
1337
|
+
className: "ReactSpringCarouselContainer",
|
|
1338
|
+
"data-part": "Container",
|
|
1339
|
+
"data-part-internal": `${n}-Container`,
|
|
1340
|
+
...Ut(),
|
|
1341
|
+
children: [
|
|
1342
|
+
/* @__PURE__ */ et("style", { dangerouslySetInnerHTML: { __html: Wt } }),
|
|
1343
|
+
/* @__PURE__ */ et(
|
|
1337
1344
|
"div",
|
|
1338
1345
|
{
|
|
1339
|
-
ref:
|
|
1346
|
+
ref: S,
|
|
1340
1347
|
className: "ReactSpringCarouselTrack",
|
|
1341
1348
|
"data-part": "Track",
|
|
1342
1349
|
"data-part-internal": `${n}-Track`,
|
|
1343
1350
|
onScroll: () => {
|
|
1344
|
-
|
|
1351
|
+
D.current = !1, $.current = !1;
|
|
1345
1352
|
},
|
|
1346
|
-
children:
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1353
|
+
children: Array.from({ length: Lt }, (i, c) => {
|
|
1354
|
+
const h = e ? c % t.length : c, v = t[h], _ = e && (c < t.length || c >= t.length * 2), p = Gt[h], x = zt[h];
|
|
1355
|
+
return /* @__PURE__ */ et(
|
|
1356
|
+
"div",
|
|
1357
|
+
{
|
|
1358
|
+
className: "ReactSpringCarouselItem",
|
|
1359
|
+
"data-part": "Item",
|
|
1360
|
+
"data-part-internal": `${n}-Item`,
|
|
1361
|
+
"data-id": v.id,
|
|
1362
|
+
children: typeof v.renderItem == "function" ? v.renderItem({
|
|
1363
|
+
useListenToCustomEvent: dt,
|
|
1364
|
+
index: c,
|
|
1365
|
+
isClonedItem: _,
|
|
1366
|
+
isActiveItem: Kt,
|
|
1367
|
+
isNextItem: p,
|
|
1368
|
+
isPrevItem: x
|
|
1369
|
+
}) : v.renderItem
|
|
1370
|
+
},
|
|
1371
|
+
`${v.id}-${c}`
|
|
1372
|
+
);
|
|
1373
|
+
})
|
|
1362
1374
|
}
|
|
1363
1375
|
)
|
|
1364
1376
|
]
|
|
1365
1377
|
}
|
|
1366
1378
|
),
|
|
1367
|
-
useListenToCustomEvent:
|
|
1379
|
+
useListenToCustomEvent: dt,
|
|
1368
1380
|
slideToNextItem: () => J(),
|
|
1369
1381
|
slideToPrevItem: () => Q(),
|
|
1370
1382
|
slideToItem: (i) => {
|
|
@@ -1375,110 +1387,110 @@ function Ue({
|
|
|
1375
1387
|
);
|
|
1376
1388
|
return;
|
|
1377
1389
|
}
|
|
1378
|
-
i >
|
|
1390
|
+
i > f.current ? J(i) : Q(i);
|
|
1379
1391
|
}
|
|
1380
1392
|
if (typeof i == "string") {
|
|
1381
|
-
const
|
|
1382
|
-
if (
|
|
1393
|
+
const c = t.findIndex((h) => h.id === i);
|
|
1394
|
+
if (c < 0) {
|
|
1383
1395
|
console.warn(
|
|
1384
1396
|
`The item you're trying to slide doesn't exist. id: ${i}`
|
|
1385
1397
|
);
|
|
1386
1398
|
return;
|
|
1387
1399
|
}
|
|
1388
|
-
|
|
1400
|
+
c > f.current ? J(c) : Q(c);
|
|
1389
1401
|
}
|
|
1390
1402
|
}
|
|
1391
1403
|
};
|
|
1392
1404
|
}
|
|
1393
|
-
function
|
|
1405
|
+
function ze(r) {
|
|
1394
1406
|
let t = 0;
|
|
1395
|
-
const
|
|
1396
|
-
return
|
|
1407
|
+
const e = getComputedStyle(r).getPropertyValue("gap");
|
|
1408
|
+
return e.includes("px") && (t = Number(e.replace("px", ""))), t;
|
|
1397
1409
|
}
|
|
1398
|
-
function
|
|
1399
|
-
return
|
|
1410
|
+
function Dt(r) {
|
|
1411
|
+
return r.scrollWidth - r.clientWidth;
|
|
1400
1412
|
}
|
|
1401
|
-
function
|
|
1402
|
-
const t =
|
|
1403
|
-
return t.getBoundingClientRect().width +
|
|
1413
|
+
function ot(r) {
|
|
1414
|
+
const t = r.children[0], e = ze(r);
|
|
1415
|
+
return t.getBoundingClientRect().width + e;
|
|
1404
1416
|
}
|
|
1405
|
-
function
|
|
1406
|
-
const
|
|
1417
|
+
function qe({ container: r, onReach: t }) {
|
|
1418
|
+
const e = w("start"), n = w(0), [, s] = $t(() => ({
|
|
1407
1419
|
x: 0
|
|
1408
1420
|
}));
|
|
1409
|
-
function
|
|
1421
|
+
function a(u) {
|
|
1410
1422
|
s.start({
|
|
1411
1423
|
from: {
|
|
1412
|
-
x:
|
|
1424
|
+
x: r.current.scrollLeft
|
|
1413
1425
|
},
|
|
1414
1426
|
to: {
|
|
1415
|
-
x:
|
|
1427
|
+
x: u
|
|
1416
1428
|
},
|
|
1417
|
-
onChange({ value:
|
|
1418
|
-
|
|
1429
|
+
onChange({ value: d }) {
|
|
1430
|
+
r.current && (r.current.scrollLeft = d.x);
|
|
1419
1431
|
}
|
|
1420
1432
|
});
|
|
1421
1433
|
}
|
|
1422
|
-
function
|
|
1423
|
-
if (!
|
|
1434
|
+
function o(u) {
|
|
1435
|
+
if (!r.current || u === "next" && e.current === "end" || u === "prev" && e.current === "start")
|
|
1424
1436
|
return;
|
|
1425
|
-
let
|
|
1426
|
-
if (
|
|
1427
|
-
const
|
|
1428
|
-
|
|
1437
|
+
let d = 0;
|
|
1438
|
+
if (u === "next" && (n.current += 1), u === "prev" && (n.current -= 1), d = n.current * ot(r.current), u === "next") {
|
|
1439
|
+
const g = Dt(r.current);
|
|
1440
|
+
d > g && (e.current = "end", d = g, t && t("end"));
|
|
1429
1441
|
}
|
|
1430
|
-
|
|
1442
|
+
u === "prev" && d <= 0 && (e.current = "start", n.current = 0, d = 0, t && t("start")), a(d);
|
|
1431
1443
|
}
|
|
1432
1444
|
return U(() => {
|
|
1433
|
-
function
|
|
1434
|
-
var
|
|
1435
|
-
const
|
|
1436
|
-
index:
|
|
1437
|
-
start:
|
|
1438
|
-
end:
|
|
1439
|
-
})),
|
|
1440
|
-
(
|
|
1445
|
+
function u() {
|
|
1446
|
+
var I;
|
|
1447
|
+
const P = ot(r.current), T = ((I = [...r.current.children].at(0)) == null ? void 0 : I.getBoundingClientRect().width) || 0, k = Array(r.current.childElementCount).fill(0).map((D, $) => ({
|
|
1448
|
+
index: $,
|
|
1449
|
+
start: P * $,
|
|
1450
|
+
end: P * ($ + 1)
|
|
1451
|
+
})), S = r.current.scrollLeft + T, A = k.find(
|
|
1452
|
+
(D) => S >= D.start && S < D.end
|
|
1441
1453
|
);
|
|
1442
1454
|
n.current = (A == null ? void 0 : A.index) || 0;
|
|
1443
1455
|
}
|
|
1444
|
-
function
|
|
1456
|
+
function d() {
|
|
1445
1457
|
s.stop();
|
|
1446
1458
|
}
|
|
1447
|
-
function
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1459
|
+
function g(P) {
|
|
1460
|
+
const T = P.target;
|
|
1461
|
+
T.scrollLeft === 0 ? (n.current = 0, e.current = "start", t && t("start")) : T.scrollLeft >= Dt(T) ? (e.current = "end", t && t("end")) : e.current !== "idle" && (e.current = "idle", t && t("idle"));
|
|
1450
1462
|
}
|
|
1451
|
-
let
|
|
1452
|
-
function
|
|
1453
|
-
|
|
1454
|
-
|
|
1463
|
+
let l, b = 0;
|
|
1464
|
+
function y() {
|
|
1465
|
+
b = r.current.scrollLeft, clearTimeout(l), l = setTimeout(function() {
|
|
1466
|
+
r.current.scrollLeft === b && u();
|
|
1455
1467
|
}, 200);
|
|
1456
1468
|
}
|
|
1457
|
-
if (
|
|
1458
|
-
return
|
|
1469
|
+
if (r.current)
|
|
1470
|
+
return r.current.addEventListener("wheel", d, {
|
|
1459
1471
|
passive: !0
|
|
1460
|
-
}),
|
|
1461
|
-
|
|
1472
|
+
}), r.current.addEventListener("scroll", g), r.current.addEventListener("scroll", y), () => {
|
|
1473
|
+
r.current && (r.current.removeEventListener("scroll", y), r.current.removeEventListener("scroll", g), r.current.removeEventListener("wheel", d));
|
|
1462
1474
|
};
|
|
1463
|
-
}, [
|
|
1464
|
-
if (
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1475
|
+
}, [r, t]), U(() => {
|
|
1476
|
+
if (r.current) {
|
|
1477
|
+
const u = new ResizeObserver(() => {
|
|
1478
|
+
a(n.current * ot(r.current));
|
|
1467
1479
|
});
|
|
1468
|
-
return
|
|
1469
|
-
|
|
1480
|
+
return u.observe(r.current), () => {
|
|
1481
|
+
u.disconnect();
|
|
1470
1482
|
};
|
|
1471
1483
|
}
|
|
1472
1484
|
}, []), {
|
|
1473
1485
|
scrollToNext() {
|
|
1474
|
-
|
|
1486
|
+
o("next");
|
|
1475
1487
|
},
|
|
1476
1488
|
scrollToPrev() {
|
|
1477
|
-
|
|
1489
|
+
o("prev");
|
|
1478
1490
|
}
|
|
1479
1491
|
};
|
|
1480
1492
|
}
|
|
1481
1493
|
export {
|
|
1482
|
-
|
|
1483
|
-
|
|
1494
|
+
Xe as useSpringCarousel,
|
|
1495
|
+
qe as useSpringScroll
|
|
1484
1496
|
};
|