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