react-spring-carousel 3.0.0-beta078 → 3.0.0-beta080
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.cjs.js +1 -239
- package/dist/index.cjs2.js +1 -0
- package/dist/index.cjs3.js +5 -0
- package/dist/index.cjs4.js +1 -0
- package/dist/index.es.js +12 -0
- package/dist/index.es2.js +6 -0
- package/dist/index.es3.js +1087 -0
- package/dist/index.es4.js +254 -0
- package/dist/use-gesture-react.esm-662f7bb4.cjs +1 -0
- package/dist/use-gesture-react.esm-9eb8841a.js +1004 -0
- package/dist/useThumbsModule-08e90459.js +723 -0
- package/dist/useThumbsModule-f2f898fc.cjs +27 -0
- package/package.json +4 -4
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -25598
- package/dist/index.esm.js.map +0 -1
|
@@ -0,0 +1,1004 @@
|
|
|
1
|
+
import I, { useRef as nt, useEffect as rt } from "react";
|
|
2
|
+
const P = "RSC::Event";
|
|
3
|
+
function qt() {
|
|
4
|
+
const s = nt(null);
|
|
5
|
+
function t(n) {
|
|
6
|
+
rt(() => {
|
|
7
|
+
s.current || (s.current = document.createElement("div"));
|
|
8
|
+
function r(i) {
|
|
9
|
+
n(i.detail);
|
|
10
|
+
}
|
|
11
|
+
if (s.current)
|
|
12
|
+
return s.current.addEventListener(P, r, !1), () => {
|
|
13
|
+
var i;
|
|
14
|
+
(i = s.current) == null || i.removeEventListener(P, r, !1);
|
|
15
|
+
};
|
|
16
|
+
}, [n]);
|
|
17
|
+
}
|
|
18
|
+
function e(n) {
|
|
19
|
+
if (s.current) {
|
|
20
|
+
const r = new CustomEvent(P, {
|
|
21
|
+
detail: n
|
|
22
|
+
});
|
|
23
|
+
s.current.dispatchEvent(r);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
useListenToCustomEvent: t,
|
|
28
|
+
emitEvent: e
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function it(s, t, e) {
|
|
32
|
+
return Math.max(t, Math.min(s, e));
|
|
33
|
+
}
|
|
34
|
+
const d = {
|
|
35
|
+
toVector(s, t) {
|
|
36
|
+
return s === void 0 && (s = t), Array.isArray(s) ? s : [s, s];
|
|
37
|
+
},
|
|
38
|
+
add(s, t) {
|
|
39
|
+
return [s[0] + t[0], s[1] + t[1]];
|
|
40
|
+
},
|
|
41
|
+
sub(s, t) {
|
|
42
|
+
return [s[0] - t[0], s[1] - t[1]];
|
|
43
|
+
},
|
|
44
|
+
addTo(s, t) {
|
|
45
|
+
s[0] += t[0], s[1] += t[1];
|
|
46
|
+
},
|
|
47
|
+
subTo(s, t) {
|
|
48
|
+
s[0] -= t[0], s[1] -= t[1];
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
function M(s, t, e) {
|
|
52
|
+
return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(s, e * 5) : s * t * e / (t + e * s);
|
|
53
|
+
}
|
|
54
|
+
function N(s, t, e, n = 0.15) {
|
|
55
|
+
return n === 0 ? it(s, t, e) : s < t ? -M(t - s, e - t, n) + t : s > e ? +M(s - e, e - t, n) + e : s;
|
|
56
|
+
}
|
|
57
|
+
function ot(s, [t, e], [n, r]) {
|
|
58
|
+
const [[i, o], [c, f]] = s;
|
|
59
|
+
return [N(t, i, o, n), N(e, c, f, r)];
|
|
60
|
+
}
|
|
61
|
+
function at(s, t) {
|
|
62
|
+
if (typeof s != "object" || s === null)
|
|
63
|
+
return s;
|
|
64
|
+
var e = s[Symbol.toPrimitive];
|
|
65
|
+
if (e !== void 0) {
|
|
66
|
+
var n = e.call(s, t || "default");
|
|
67
|
+
if (typeof n != "object")
|
|
68
|
+
return n;
|
|
69
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
70
|
+
}
|
|
71
|
+
return (t === "string" ? String : Number)(s);
|
|
72
|
+
}
|
|
73
|
+
function ct(s) {
|
|
74
|
+
var t = at(s, "string");
|
|
75
|
+
return typeof t == "symbol" ? t : String(t);
|
|
76
|
+
}
|
|
77
|
+
function l(s, t, e) {
|
|
78
|
+
return t = ct(t), t in s ? Object.defineProperty(s, t, {
|
|
79
|
+
value: e,
|
|
80
|
+
enumerable: !0,
|
|
81
|
+
configurable: !0,
|
|
82
|
+
writable: !0
|
|
83
|
+
}) : s[t] = e, s;
|
|
84
|
+
}
|
|
85
|
+
function U(s, t) {
|
|
86
|
+
var e = Object.keys(s);
|
|
87
|
+
if (Object.getOwnPropertySymbols) {
|
|
88
|
+
var n = Object.getOwnPropertySymbols(s);
|
|
89
|
+
t && (n = n.filter(function(r) {
|
|
90
|
+
return Object.getOwnPropertyDescriptor(s, r).enumerable;
|
|
91
|
+
})), e.push.apply(e, n);
|
|
92
|
+
}
|
|
93
|
+
return e;
|
|
94
|
+
}
|
|
95
|
+
function u(s) {
|
|
96
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
97
|
+
var e = arguments[t] != null ? arguments[t] : {};
|
|
98
|
+
t % 2 ? U(Object(e), !0).forEach(function(n) {
|
|
99
|
+
l(s, n, e[n]);
|
|
100
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(e)) : U(Object(e)).forEach(function(n) {
|
|
101
|
+
Object.defineProperty(s, n, Object.getOwnPropertyDescriptor(e, n));
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return s;
|
|
105
|
+
}
|
|
106
|
+
const H = {
|
|
107
|
+
pointer: {
|
|
108
|
+
start: "down",
|
|
109
|
+
change: "move",
|
|
110
|
+
end: "up"
|
|
111
|
+
},
|
|
112
|
+
mouse: {
|
|
113
|
+
start: "down",
|
|
114
|
+
change: "move",
|
|
115
|
+
end: "up"
|
|
116
|
+
},
|
|
117
|
+
touch: {
|
|
118
|
+
start: "start",
|
|
119
|
+
change: "move",
|
|
120
|
+
end: "end"
|
|
121
|
+
},
|
|
122
|
+
gesture: {
|
|
123
|
+
start: "start",
|
|
124
|
+
change: "change",
|
|
125
|
+
end: "end"
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
function K(s) {
|
|
129
|
+
return s ? s[0].toUpperCase() + s.slice(1) : "";
|
|
130
|
+
}
|
|
131
|
+
const ut = ["enter", "leave"];
|
|
132
|
+
function ft(s = !1, t) {
|
|
133
|
+
return s && !ut.includes(t);
|
|
134
|
+
}
|
|
135
|
+
function ht(s, t = "", e = !1) {
|
|
136
|
+
const n = H[s], r = n && n[t] || t;
|
|
137
|
+
return "on" + K(s) + K(r) + (ft(e, r) ? "Capture" : "");
|
|
138
|
+
}
|
|
139
|
+
const dt = ["gotpointercapture", "lostpointercapture"];
|
|
140
|
+
function lt(s) {
|
|
141
|
+
let t = s.substring(2).toLowerCase();
|
|
142
|
+
const e = !!~t.indexOf("passive");
|
|
143
|
+
e && (t = t.replace("passive", ""));
|
|
144
|
+
const n = dt.includes(t) ? "capturecapture" : "capture", r = !!~t.indexOf(n);
|
|
145
|
+
return r && (t = t.replace("capture", "")), {
|
|
146
|
+
device: t,
|
|
147
|
+
capture: r,
|
|
148
|
+
passive: e
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function pt(s, t = "") {
|
|
152
|
+
const e = H[s], n = e && e[t] || t;
|
|
153
|
+
return s + n;
|
|
154
|
+
}
|
|
155
|
+
function O(s) {
|
|
156
|
+
return "touches" in s;
|
|
157
|
+
}
|
|
158
|
+
function G(s) {
|
|
159
|
+
return O(s) ? "touch" : "pointerType" in s ? s.pointerType : "mouse";
|
|
160
|
+
}
|
|
161
|
+
function mt(s) {
|
|
162
|
+
return Array.from(s.touches).filter((t) => {
|
|
163
|
+
var e, n;
|
|
164
|
+
return t.target === s.currentTarget || ((e = s.currentTarget) === null || e === void 0 || (n = e.contains) === null || n === void 0 ? void 0 : n.call(e, t.target));
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function gt(s) {
|
|
168
|
+
return s.type === "touchend" || s.type === "touchcancel" ? s.changedTouches : s.targetTouches;
|
|
169
|
+
}
|
|
170
|
+
function X(s) {
|
|
171
|
+
return O(s) ? gt(s)[0] : s;
|
|
172
|
+
}
|
|
173
|
+
function _t(s) {
|
|
174
|
+
return mt(s).map((t) => t.identifier);
|
|
175
|
+
}
|
|
176
|
+
function x(s) {
|
|
177
|
+
const t = X(s);
|
|
178
|
+
return O(s) ? t.identifier : t.pointerId;
|
|
179
|
+
}
|
|
180
|
+
function R(s) {
|
|
181
|
+
const t = X(s);
|
|
182
|
+
return [t.clientX, t.clientY];
|
|
183
|
+
}
|
|
184
|
+
function yt(s) {
|
|
185
|
+
const t = {};
|
|
186
|
+
if ("buttons" in s && (t.buttons = s.buttons), "shiftKey" in s) {
|
|
187
|
+
const {
|
|
188
|
+
shiftKey: e,
|
|
189
|
+
altKey: n,
|
|
190
|
+
metaKey: r,
|
|
191
|
+
ctrlKey: i
|
|
192
|
+
} = s;
|
|
193
|
+
Object.assign(t, {
|
|
194
|
+
shiftKey: e,
|
|
195
|
+
altKey: n,
|
|
196
|
+
metaKey: r,
|
|
197
|
+
ctrlKey: i
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return t;
|
|
201
|
+
}
|
|
202
|
+
function k(s, ...t) {
|
|
203
|
+
return typeof s == "function" ? s(...t) : s;
|
|
204
|
+
}
|
|
205
|
+
function vt() {
|
|
206
|
+
}
|
|
207
|
+
function bt(...s) {
|
|
208
|
+
return s.length === 0 ? vt : s.length === 1 ? s[0] : function() {
|
|
209
|
+
let t;
|
|
210
|
+
for (const e of s)
|
|
211
|
+
t = e.apply(this, arguments) || t;
|
|
212
|
+
return t;
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function V(s, t) {
|
|
216
|
+
return Object.assign({}, t, s || {});
|
|
217
|
+
}
|
|
218
|
+
const wt = 32;
|
|
219
|
+
class Et {
|
|
220
|
+
constructor(t, e, n) {
|
|
221
|
+
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());
|
|
222
|
+
}
|
|
223
|
+
get state() {
|
|
224
|
+
return this.ctrl.state[this.key];
|
|
225
|
+
}
|
|
226
|
+
set state(t) {
|
|
227
|
+
this.ctrl.state[this.key] = t;
|
|
228
|
+
}
|
|
229
|
+
get shared() {
|
|
230
|
+
return this.ctrl.state.shared;
|
|
231
|
+
}
|
|
232
|
+
get eventStore() {
|
|
233
|
+
return this.ctrl.gestureEventStores[this.key];
|
|
234
|
+
}
|
|
235
|
+
get timeoutStore() {
|
|
236
|
+
return this.ctrl.gestureTimeoutStores[this.key];
|
|
237
|
+
}
|
|
238
|
+
get config() {
|
|
239
|
+
return this.ctrl.config[this.key];
|
|
240
|
+
}
|
|
241
|
+
get sharedConfig() {
|
|
242
|
+
return this.ctrl.config.shared;
|
|
243
|
+
}
|
|
244
|
+
get handler() {
|
|
245
|
+
return this.ctrl.handlers[this.key];
|
|
246
|
+
}
|
|
247
|
+
reset() {
|
|
248
|
+
const {
|
|
249
|
+
state: t,
|
|
250
|
+
shared: e,
|
|
251
|
+
ingKey: n,
|
|
252
|
+
args: r
|
|
253
|
+
} = this;
|
|
254
|
+
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 = r, 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;
|
|
255
|
+
}
|
|
256
|
+
start(t) {
|
|
257
|
+
const e = this.state, n = this.config;
|
|
258
|
+
e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = n.from ? k(n.from, e) : e.offset, e.offset = e.lastOffset, e.startTime = e.timeStamp = t.timeStamp);
|
|
259
|
+
}
|
|
260
|
+
computeValues(t) {
|
|
261
|
+
const e = this.state;
|
|
262
|
+
e._values = t, e.values = this.config.transform(t);
|
|
263
|
+
}
|
|
264
|
+
computeInitial() {
|
|
265
|
+
const t = this.state;
|
|
266
|
+
t._initial = t._values, t.initial = t.values;
|
|
267
|
+
}
|
|
268
|
+
compute(t) {
|
|
269
|
+
const {
|
|
270
|
+
state: e,
|
|
271
|
+
config: n,
|
|
272
|
+
shared: r
|
|
273
|
+
} = this;
|
|
274
|
+
e.args = this.args;
|
|
275
|
+
let i = 0;
|
|
276
|
+
if (t && (e.event = t, n.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, r.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, r.locked = !!document.pointerLockElement, Object.assign(r, yt(t)), r.down = r.pressed = r.buttons % 2 === 1 || r.touches > 0, i = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
|
|
277
|
+
const _ = e._delta.map(Math.abs);
|
|
278
|
+
d.addTo(e._distance, _);
|
|
279
|
+
}
|
|
280
|
+
this.axisIntent && this.axisIntent(t);
|
|
281
|
+
const [o, c] = e._movement, [f, h] = n.threshold, {
|
|
282
|
+
_step: a,
|
|
283
|
+
values: g
|
|
284
|
+
} = e;
|
|
285
|
+
if (n.hasCustomTransform ? (a[0] === !1 && (a[0] = Math.abs(o) >= f && g[0]), a[1] === !1 && (a[1] = Math.abs(c) >= h && g[1])) : (a[0] === !1 && (a[0] = Math.abs(o) >= f && Math.sign(o) * f), a[1] === !1 && (a[1] = Math.abs(c) >= h && Math.sign(c) * h)), e.intentional = a[0] !== !1 || a[1] !== !1, !e.intentional)
|
|
286
|
+
return;
|
|
287
|
+
const p = [0, 0];
|
|
288
|
+
if (n.hasCustomTransform) {
|
|
289
|
+
const [_, st] = g;
|
|
290
|
+
p[0] = a[0] !== !1 ? _ - a[0] : 0, p[1] = a[1] !== !1 ? st - a[1] : 0;
|
|
291
|
+
} else
|
|
292
|
+
p[0] = a[0] !== !1 ? o - a[0] : 0, p[1] = a[1] !== !1 ? c - a[1] : 0;
|
|
293
|
+
this.restrictToAxis && !e._blocked && this.restrictToAxis(p);
|
|
294
|
+
const w = e.offset, E = e._active && !e._blocked || e.active;
|
|
295
|
+
E && (e.first = e._active && !e.active, e.last = !e._active && e.active, e.active = r[this.ingKey] = e._active, t && (e.first && ("bounds" in n && (e._bounds = k(n.bounds, e)), this.setup && this.setup()), e.movement = p, this.computeOffset()));
|
|
296
|
+
const [T, D] = e.offset, [[A, Q], [Z, tt]] = e._bounds;
|
|
297
|
+
e.overflow = [T < A ? -1 : T > Q ? 1 : 0, D < Z ? -1 : D > tt ? 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;
|
|
298
|
+
const et = e._active ? n.rubberband || [0, 0] : [0, 0];
|
|
299
|
+
if (e.offset = ot(e._bounds, e.offset, et), e.delta = d.sub(e.offset, w), this.computeMovement(), E && (!e.last || i > wt)) {
|
|
300
|
+
e.delta = d.sub(e.offset, w);
|
|
301
|
+
const _ = e.delta.map(Math.abs);
|
|
302
|
+
d.addTo(e.distance, _), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && i > 0 && (e.velocity = [_[0] / i, _[1] / i], e.timeDelta = i);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
emit() {
|
|
306
|
+
const t = this.state, e = this.shared, n = this.config;
|
|
307
|
+
if (t._active || this.clean(), (t._blocked || !t.intentional) && !t._force && !n.triggerAllEvents)
|
|
308
|
+
return;
|
|
309
|
+
const r = this.handler(u(u(u({}, e), t), {}, {
|
|
310
|
+
[this.aliasKey]: t.values
|
|
311
|
+
}));
|
|
312
|
+
r !== void 0 && (t.memo = r);
|
|
313
|
+
}
|
|
314
|
+
clean() {
|
|
315
|
+
this.eventStore.clean(), this.timeoutStore.clean();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function Tt([s, t], e) {
|
|
319
|
+
const n = Math.abs(s), r = Math.abs(t);
|
|
320
|
+
if (n > r && n > e)
|
|
321
|
+
return "x";
|
|
322
|
+
if (r > n && r > e)
|
|
323
|
+
return "y";
|
|
324
|
+
}
|
|
325
|
+
class Dt extends Et {
|
|
326
|
+
constructor(...t) {
|
|
327
|
+
super(...t), l(this, "aliasKey", "xy");
|
|
328
|
+
}
|
|
329
|
+
reset() {
|
|
330
|
+
super.reset(), this.state.axis = void 0;
|
|
331
|
+
}
|
|
332
|
+
init() {
|
|
333
|
+
this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
|
|
334
|
+
}
|
|
335
|
+
computeOffset() {
|
|
336
|
+
this.state.offset = d.add(this.state.lastOffset, this.state.movement);
|
|
337
|
+
}
|
|
338
|
+
computeMovement() {
|
|
339
|
+
this.state.movement = d.sub(this.state.offset, this.state.lastOffset);
|
|
340
|
+
}
|
|
341
|
+
axisIntent(t) {
|
|
342
|
+
const e = this.state, n = this.config;
|
|
343
|
+
if (!e.axis && t) {
|
|
344
|
+
const r = typeof n.axisThreshold == "object" ? n.axisThreshold[G(t)] : n.axisThreshold;
|
|
345
|
+
e.axis = Tt(e._movement, r);
|
|
346
|
+
}
|
|
347
|
+
e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
|
|
348
|
+
}
|
|
349
|
+
restrictToAxis(t) {
|
|
350
|
+
if (this.config.axis || this.config.lockDirection)
|
|
351
|
+
switch (this.state.axis) {
|
|
352
|
+
case "x":
|
|
353
|
+
t[1] = 0;
|
|
354
|
+
break;
|
|
355
|
+
case "y":
|
|
356
|
+
t[0] = 0;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const j = (s) => s, B = 0.15, L = {
|
|
362
|
+
enabled(s = !0) {
|
|
363
|
+
return s;
|
|
364
|
+
},
|
|
365
|
+
eventOptions(s, t, e) {
|
|
366
|
+
return u(u({}, e.shared.eventOptions), s);
|
|
367
|
+
},
|
|
368
|
+
preventDefault(s = !1) {
|
|
369
|
+
return s;
|
|
370
|
+
},
|
|
371
|
+
triggerAllEvents(s = !1) {
|
|
372
|
+
return s;
|
|
373
|
+
},
|
|
374
|
+
rubberband(s = 0) {
|
|
375
|
+
switch (s) {
|
|
376
|
+
case !0:
|
|
377
|
+
return [B, B];
|
|
378
|
+
case !1:
|
|
379
|
+
return [0, 0];
|
|
380
|
+
default:
|
|
381
|
+
return d.toVector(s);
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
from(s) {
|
|
385
|
+
if (typeof s == "function")
|
|
386
|
+
return s;
|
|
387
|
+
if (s != null)
|
|
388
|
+
return d.toVector(s);
|
|
389
|
+
},
|
|
390
|
+
transform(s, t, e) {
|
|
391
|
+
const n = s || e.shared.transform;
|
|
392
|
+
if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
|
|
393
|
+
const r = n || j;
|
|
394
|
+
return (i) => {
|
|
395
|
+
const o = r(i);
|
|
396
|
+
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;
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
return n || j;
|
|
400
|
+
},
|
|
401
|
+
threshold(s) {
|
|
402
|
+
return d.toVector(s, 0);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
process.env.NODE_ENV === "development" && Object.assign(L, {
|
|
406
|
+
domTarget(s) {
|
|
407
|
+
if (s !== void 0)
|
|
408
|
+
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
409
|
+
return NaN;
|
|
410
|
+
},
|
|
411
|
+
lockDirection(s) {
|
|
412
|
+
if (s !== void 0)
|
|
413
|
+
throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");
|
|
414
|
+
return NaN;
|
|
415
|
+
},
|
|
416
|
+
initial(s) {
|
|
417
|
+
if (s !== void 0)
|
|
418
|
+
throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");
|
|
419
|
+
return NaN;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
const St = 0, v = u(u({}, L), {}, {
|
|
423
|
+
axis(s, t, {
|
|
424
|
+
axis: e
|
|
425
|
+
}) {
|
|
426
|
+
if (this.lockDirection = e === "lock", !this.lockDirection)
|
|
427
|
+
return e;
|
|
428
|
+
},
|
|
429
|
+
axisThreshold(s = St) {
|
|
430
|
+
return s;
|
|
431
|
+
},
|
|
432
|
+
bounds(s = {}) {
|
|
433
|
+
if (typeof s == "function")
|
|
434
|
+
return (i) => v.bounds(s(i));
|
|
435
|
+
if ("current" in s)
|
|
436
|
+
return () => s.current;
|
|
437
|
+
if (typeof HTMLElement == "function" && s instanceof HTMLElement)
|
|
438
|
+
return s;
|
|
439
|
+
const {
|
|
440
|
+
left: t = -1 / 0,
|
|
441
|
+
right: e = 1 / 0,
|
|
442
|
+
top: n = -1 / 0,
|
|
443
|
+
bottom: r = 1 / 0
|
|
444
|
+
} = s;
|
|
445
|
+
return [[t, e], [n, r]];
|
|
446
|
+
}
|
|
447
|
+
}), Y = {
|
|
448
|
+
ArrowRight: (s, t = 1) => [s * t, 0],
|
|
449
|
+
ArrowLeft: (s, t = 1) => [-1 * s * t, 0],
|
|
450
|
+
ArrowUp: (s, t = 1) => [0, -1 * s * t],
|
|
451
|
+
ArrowDown: (s, t = 1) => [0, s * t]
|
|
452
|
+
};
|
|
453
|
+
class kt extends Dt {
|
|
454
|
+
constructor(...t) {
|
|
455
|
+
super(...t), l(this, "ingKey", "dragging");
|
|
456
|
+
}
|
|
457
|
+
reset() {
|
|
458
|
+
super.reset();
|
|
459
|
+
const t = this.state;
|
|
460
|
+
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);
|
|
461
|
+
}
|
|
462
|
+
setup() {
|
|
463
|
+
const t = this.state;
|
|
464
|
+
if (t._bounds instanceof HTMLElement) {
|
|
465
|
+
const e = t._bounds.getBoundingClientRect(), n = t.currentTarget.getBoundingClientRect(), r = {
|
|
466
|
+
left: e.left - n.left + t.offset[0],
|
|
467
|
+
right: e.right - n.right + t.offset[0],
|
|
468
|
+
top: e.top - n.top + t.offset[1],
|
|
469
|
+
bottom: e.bottom - n.bottom + t.offset[1]
|
|
470
|
+
};
|
|
471
|
+
t._bounds = v.bounds(r);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
cancel() {
|
|
475
|
+
const t = this.state;
|
|
476
|
+
t.canceled || (t.canceled = !0, t._active = !1, setTimeout(() => {
|
|
477
|
+
this.compute(), this.emit();
|
|
478
|
+
}, 0));
|
|
479
|
+
}
|
|
480
|
+
setActive() {
|
|
481
|
+
this.state._active = this.state._pointerActive || this.state._keyboardActive;
|
|
482
|
+
}
|
|
483
|
+
clean() {
|
|
484
|
+
this.pointerClean(), this.state._pointerActive = !1, this.state._keyboardActive = !1, super.clean();
|
|
485
|
+
}
|
|
486
|
+
pointerDown(t) {
|
|
487
|
+
const e = this.config, n = this.state;
|
|
488
|
+
if (t.buttons != null && (Array.isArray(e.pointerButtons) ? !e.pointerButtons.includes(t.buttons) : e.pointerButtons !== -1 && e.pointerButtons !== t.buttons))
|
|
489
|
+
return;
|
|
490
|
+
const r = this.ctrl.setEventIds(t);
|
|
491
|
+
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(r && r.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = x(t), n._pointerActive = !0, this.computeValues(R(t)), this.computeInitial(), e.preventScrollAxis && G(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : e.delay > 0 ? (this.setupDelayTrigger(t), e.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
|
|
492
|
+
}
|
|
493
|
+
startPointerDrag(t) {
|
|
494
|
+
const e = this.state;
|
|
495
|
+
e._active = !0, e._preventScroll = !0, e._delayed = !1, this.compute(t), this.emit();
|
|
496
|
+
}
|
|
497
|
+
pointerMove(t) {
|
|
498
|
+
const e = this.state, n = this.config;
|
|
499
|
+
if (!e._pointerActive || e.type === t.type && t.timeStamp === e.timeStamp)
|
|
500
|
+
return;
|
|
501
|
+
const r = x(t);
|
|
502
|
+
if (e._pointerId !== void 0 && r !== e._pointerId)
|
|
503
|
+
return;
|
|
504
|
+
const i = R(t);
|
|
505
|
+
if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = d.sub(i, e._values), this.computeValues(i)), d.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
|
|
506
|
+
this.timeoutStore.remove("dragDelay"), e.active = !1, this.startPointerDrag(t);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (n.preventScrollAxis && !e._preventScroll)
|
|
510
|
+
if (e.axis)
|
|
511
|
+
if (e.axis === n.preventScrollAxis || n.preventScrollAxis === "xy") {
|
|
512
|
+
e._active = !1, this.clean();
|
|
513
|
+
return;
|
|
514
|
+
} else {
|
|
515
|
+
this.timeoutStore.remove("startPointerDrag"), this.startPointerDrag(t);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
else
|
|
519
|
+
return;
|
|
520
|
+
this.emit();
|
|
521
|
+
}
|
|
522
|
+
pointerUp(t) {
|
|
523
|
+
this.ctrl.setEventIds(t);
|
|
524
|
+
try {
|
|
525
|
+
this.config.pointerCapture && t.target.hasPointerCapture(t.pointerId) && t.target.releasePointerCapture(t.pointerId);
|
|
526
|
+
} catch {
|
|
527
|
+
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.");
|
|
528
|
+
}
|
|
529
|
+
const e = this.state, n = this.config;
|
|
530
|
+
if (!e._active || !e._pointerActive)
|
|
531
|
+
return;
|
|
532
|
+
const r = x(t);
|
|
533
|
+
if (e._pointerId !== void 0 && r !== e._pointerId)
|
|
534
|
+
return;
|
|
535
|
+
this.state._pointerActive = !1, this.setActive(), this.compute(t);
|
|
536
|
+
const [i, o] = e._distance;
|
|
537
|
+
if (e.tap = i <= n.tapsThreshold && o <= n.tapsThreshold, e.tap && n.filterTaps)
|
|
538
|
+
e._force = !0;
|
|
539
|
+
else {
|
|
540
|
+
const [c, f] = e._delta, [h, a] = e._movement, [g, p] = n.swipe.velocity, [w, E] = n.swipe.distance, T = n.swipe.duration;
|
|
541
|
+
if (e.elapsedTime < T) {
|
|
542
|
+
const D = Math.abs(c / e.timeDelta), A = Math.abs(f / e.timeDelta);
|
|
543
|
+
D > g && Math.abs(h) > w && (e.swipe[0] = Math.sign(c)), A > p && Math.abs(a) > E && (e.swipe[1] = Math.sign(f));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
this.emit();
|
|
547
|
+
}
|
|
548
|
+
pointerClick(t) {
|
|
549
|
+
!this.state.tap && t.detail > 0 && (t.preventDefault(), t.stopPropagation());
|
|
550
|
+
}
|
|
551
|
+
setupPointer(t) {
|
|
552
|
+
const e = this.config, n = e.device;
|
|
553
|
+
if (process.env.NODE_ENV === "development")
|
|
554
|
+
try {
|
|
555
|
+
if (n === "pointer" && e.preventScrollDelay === void 0) {
|
|
556
|
+
const r = "uv" in t ? t.sourceEvent.currentTarget : t.currentTarget;
|
|
557
|
+
window.getComputedStyle(r).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.", r);
|
|
558
|
+
}
|
|
559
|
+
} catch {
|
|
560
|
+
}
|
|
561
|
+
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)));
|
|
562
|
+
}
|
|
563
|
+
pointerClean() {
|
|
564
|
+
this.config.pointerLock && document.pointerLockElement === this.state.currentTarget && document.exitPointerLock();
|
|
565
|
+
}
|
|
566
|
+
preventScroll(t) {
|
|
567
|
+
this.state._preventScroll && t.cancelable && t.preventDefault();
|
|
568
|
+
}
|
|
569
|
+
setupScrollPrevention(t) {
|
|
570
|
+
this.state._preventScroll = !1, Ot(t);
|
|
571
|
+
const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
|
572
|
+
passive: !1
|
|
573
|
+
});
|
|
574
|
+
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);
|
|
575
|
+
}
|
|
576
|
+
setupDelayTrigger(t) {
|
|
577
|
+
this.state._delayed = !0, this.timeoutStore.add("dragDelay", () => {
|
|
578
|
+
this.state._step = [0, 0], this.startPointerDrag(t);
|
|
579
|
+
}, this.config.delay);
|
|
580
|
+
}
|
|
581
|
+
keyDown(t) {
|
|
582
|
+
const e = Y[t.key];
|
|
583
|
+
if (e) {
|
|
584
|
+
const n = this.state, r = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
585
|
+
this.start(t), n._delta = e(this.config.keyboardDisplacement, r), n._keyboardActive = !0, d.addTo(n._movement, n._delta), this.compute(t), this.emit();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
keyUp(t) {
|
|
589
|
+
t.key in Y && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
|
|
590
|
+
}
|
|
591
|
+
bind(t) {
|
|
592
|
+
const e = this.config.device;
|
|
593
|
+
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), {
|
|
594
|
+
capture: !0,
|
|
595
|
+
passive: !1
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function Ot(s) {
|
|
600
|
+
"persist" in s && typeof s.persist == "function" && s.persist();
|
|
601
|
+
}
|
|
602
|
+
const b = typeof window < "u" && window.document && window.document.createElement;
|
|
603
|
+
function At() {
|
|
604
|
+
return b && "ontouchstart" in window;
|
|
605
|
+
}
|
|
606
|
+
function W() {
|
|
607
|
+
return At() || b && window.navigator.maxTouchPoints > 1;
|
|
608
|
+
}
|
|
609
|
+
function It() {
|
|
610
|
+
return b && "onpointerdown" in window;
|
|
611
|
+
}
|
|
612
|
+
function Pt() {
|
|
613
|
+
return b && "exitPointerLock" in window.document;
|
|
614
|
+
}
|
|
615
|
+
function xt() {
|
|
616
|
+
try {
|
|
617
|
+
return "constructor" in GestureEvent;
|
|
618
|
+
} catch {
|
|
619
|
+
return !1;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
const m = {
|
|
623
|
+
isBrowser: b,
|
|
624
|
+
gesture: xt(),
|
|
625
|
+
touch: W(),
|
|
626
|
+
touchscreen: W(),
|
|
627
|
+
pointer: It(),
|
|
628
|
+
pointerLock: Pt()
|
|
629
|
+
}, Ct = 250, Lt = 180, Mt = 0.5, Nt = 50, Ut = 250, Kt = 10, F = {
|
|
630
|
+
mouse: 0,
|
|
631
|
+
touch: 0,
|
|
632
|
+
pen: 8
|
|
633
|
+
}, z = u(u({}, v), {}, {
|
|
634
|
+
device(s, t, {
|
|
635
|
+
pointer: {
|
|
636
|
+
touch: e = !1,
|
|
637
|
+
lock: n = !1,
|
|
638
|
+
mouse: r = !1
|
|
639
|
+
} = {}
|
|
640
|
+
}) {
|
|
641
|
+
return this.pointerLock = n && m.pointerLock, m.touch && e ? "touch" : this.pointerLock ? "mouse" : m.pointer && !r ? "pointer" : m.touch ? "touch" : "mouse";
|
|
642
|
+
},
|
|
643
|
+
preventScrollAxis(s, t, {
|
|
644
|
+
preventScroll: e
|
|
645
|
+
}) {
|
|
646
|
+
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && s ? Ct : void 0, !(!m.touchscreen || e === !1))
|
|
647
|
+
return s || (e !== void 0 ? "y" : void 0);
|
|
648
|
+
},
|
|
649
|
+
pointerCapture(s, t, {
|
|
650
|
+
pointer: {
|
|
651
|
+
capture: e = !0,
|
|
652
|
+
buttons: n = 1,
|
|
653
|
+
keys: r = !0
|
|
654
|
+
} = {}
|
|
655
|
+
}) {
|
|
656
|
+
return this.pointerButtons = n, this.keys = r, !this.pointerLock && this.device === "pointer" && e;
|
|
657
|
+
},
|
|
658
|
+
threshold(s, t, {
|
|
659
|
+
filterTaps: e = !1,
|
|
660
|
+
tapsThreshold: n = 3,
|
|
661
|
+
axis: r = void 0
|
|
662
|
+
}) {
|
|
663
|
+
const i = d.toVector(s, e ? n : r ? 1 : 0);
|
|
664
|
+
return this.filterTaps = e, this.tapsThreshold = n, i;
|
|
665
|
+
},
|
|
666
|
+
swipe({
|
|
667
|
+
velocity: s = Mt,
|
|
668
|
+
distance: t = Nt,
|
|
669
|
+
duration: e = Ut
|
|
670
|
+
} = {}) {
|
|
671
|
+
return {
|
|
672
|
+
velocity: this.transform(d.toVector(s)),
|
|
673
|
+
distance: this.transform(d.toVector(t)),
|
|
674
|
+
duration: e
|
|
675
|
+
};
|
|
676
|
+
},
|
|
677
|
+
delay(s = 0) {
|
|
678
|
+
switch (s) {
|
|
679
|
+
case !0:
|
|
680
|
+
return Lt;
|
|
681
|
+
case !1:
|
|
682
|
+
return 0;
|
|
683
|
+
default:
|
|
684
|
+
return s;
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
axisThreshold(s) {
|
|
688
|
+
return s ? u(u({}, F), s) : F;
|
|
689
|
+
},
|
|
690
|
+
keyboardDisplacement(s = Kt) {
|
|
691
|
+
return s;
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
process.env.NODE_ENV === "development" && Object.assign(z, {
|
|
695
|
+
useTouch(s) {
|
|
696
|
+
if (s !== void 0)
|
|
697
|
+
throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");
|
|
698
|
+
return NaN;
|
|
699
|
+
},
|
|
700
|
+
experimental_preventWindowScrollY(s) {
|
|
701
|
+
if (s !== void 0)
|
|
702
|
+
throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");
|
|
703
|
+
return NaN;
|
|
704
|
+
},
|
|
705
|
+
swipeVelocity(s) {
|
|
706
|
+
if (s !== void 0)
|
|
707
|
+
throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");
|
|
708
|
+
return NaN;
|
|
709
|
+
},
|
|
710
|
+
swipeDistance(s) {
|
|
711
|
+
if (s !== void 0)
|
|
712
|
+
throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");
|
|
713
|
+
return NaN;
|
|
714
|
+
},
|
|
715
|
+
swipeDuration(s) {
|
|
716
|
+
if (s !== void 0)
|
|
717
|
+
throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");
|
|
718
|
+
return NaN;
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
u(u({}, L), {}, {
|
|
722
|
+
device(s, t, {
|
|
723
|
+
shared: e,
|
|
724
|
+
pointer: {
|
|
725
|
+
touch: n = !1
|
|
726
|
+
} = {}
|
|
727
|
+
}) {
|
|
728
|
+
if (e.target && !m.touch && m.gesture)
|
|
729
|
+
return "gesture";
|
|
730
|
+
if (m.touch && n)
|
|
731
|
+
return "touch";
|
|
732
|
+
if (m.touchscreen) {
|
|
733
|
+
if (m.pointer)
|
|
734
|
+
return "pointer";
|
|
735
|
+
if (m.touch)
|
|
736
|
+
return "touch";
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
bounds(s, t, {
|
|
740
|
+
scaleBounds: e = {},
|
|
741
|
+
angleBounds: n = {}
|
|
742
|
+
}) {
|
|
743
|
+
const r = (o) => {
|
|
744
|
+
const c = V(k(e, o), {
|
|
745
|
+
min: -1 / 0,
|
|
746
|
+
max: 1 / 0
|
|
747
|
+
});
|
|
748
|
+
return [c.min, c.max];
|
|
749
|
+
}, i = (o) => {
|
|
750
|
+
const c = V(k(n, o), {
|
|
751
|
+
min: -1 / 0,
|
|
752
|
+
max: 1 / 0
|
|
753
|
+
});
|
|
754
|
+
return [c.min, c.max];
|
|
755
|
+
};
|
|
756
|
+
return typeof e != "function" && typeof n != "function" ? [r(), i()] : (o) => [r(o), i(o)];
|
|
757
|
+
},
|
|
758
|
+
threshold(s, t, e) {
|
|
759
|
+
return this.lockDirection = e.axis === "lock", d.toVector(s, this.lockDirection ? [0.1, 3] : 0);
|
|
760
|
+
},
|
|
761
|
+
modifierKey(s) {
|
|
762
|
+
return s === void 0 ? "ctrlKey" : s;
|
|
763
|
+
},
|
|
764
|
+
pinchOnWheel(s = !0) {
|
|
765
|
+
return s;
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
u(u({}, v), {}, {
|
|
769
|
+
mouseOnly: (s = !0) => s
|
|
770
|
+
});
|
|
771
|
+
u(u({}, v), {}, {
|
|
772
|
+
mouseOnly: (s = !0) => s
|
|
773
|
+
});
|
|
774
|
+
const q = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
|
|
775
|
+
function Rt(s) {
|
|
776
|
+
q.set(s.key, s.engine), C.set(s.key, s.resolver);
|
|
777
|
+
}
|
|
778
|
+
const Vt = {
|
|
779
|
+
key: "drag",
|
|
780
|
+
engine: kt,
|
|
781
|
+
resolver: z
|
|
782
|
+
};
|
|
783
|
+
function jt(s, t) {
|
|
784
|
+
if (s == null)
|
|
785
|
+
return {};
|
|
786
|
+
var e = {}, n = Object.keys(s), r, i;
|
|
787
|
+
for (i = 0; i < n.length; i++)
|
|
788
|
+
r = n[i], !(t.indexOf(r) >= 0) && (e[r] = s[r]);
|
|
789
|
+
return e;
|
|
790
|
+
}
|
|
791
|
+
function Bt(s, t) {
|
|
792
|
+
if (s == null)
|
|
793
|
+
return {};
|
|
794
|
+
var e = jt(s, t), n, r;
|
|
795
|
+
if (Object.getOwnPropertySymbols) {
|
|
796
|
+
var i = Object.getOwnPropertySymbols(s);
|
|
797
|
+
for (r = 0; r < i.length; r++)
|
|
798
|
+
n = i[r], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(s, n) && (e[n] = s[n]);
|
|
799
|
+
}
|
|
800
|
+
return e;
|
|
801
|
+
}
|
|
802
|
+
const Yt = {
|
|
803
|
+
target(s) {
|
|
804
|
+
if (s)
|
|
805
|
+
return () => "current" in s ? s.current : s;
|
|
806
|
+
},
|
|
807
|
+
enabled(s = !0) {
|
|
808
|
+
return s;
|
|
809
|
+
},
|
|
810
|
+
window(s = m.isBrowser ? window : void 0) {
|
|
811
|
+
return s;
|
|
812
|
+
},
|
|
813
|
+
eventOptions({
|
|
814
|
+
passive: s = !0,
|
|
815
|
+
capture: t = !1
|
|
816
|
+
} = {}) {
|
|
817
|
+
return {
|
|
818
|
+
passive: s,
|
|
819
|
+
capture: t
|
|
820
|
+
};
|
|
821
|
+
},
|
|
822
|
+
transform(s) {
|
|
823
|
+
return s;
|
|
824
|
+
}
|
|
825
|
+
}, Wt = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
826
|
+
function S(s = {}, t) {
|
|
827
|
+
const e = {};
|
|
828
|
+
for (const [n, r] of Object.entries(t))
|
|
829
|
+
switch (typeof r) {
|
|
830
|
+
case "function":
|
|
831
|
+
if (process.env.NODE_ENV === "development") {
|
|
832
|
+
const i = r.call(e, s[n], n, s);
|
|
833
|
+
Number.isNaN(i) || (e[n] = i);
|
|
834
|
+
} else
|
|
835
|
+
e[n] = r.call(e, s[n], n, s);
|
|
836
|
+
break;
|
|
837
|
+
case "object":
|
|
838
|
+
e[n] = S(s[n], r);
|
|
839
|
+
break;
|
|
840
|
+
case "boolean":
|
|
841
|
+
r && (e[n] = s[n]);
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
return e;
|
|
845
|
+
}
|
|
846
|
+
function Ft(s, t, e = {}) {
|
|
847
|
+
const n = s, {
|
|
848
|
+
target: r,
|
|
849
|
+
eventOptions: i,
|
|
850
|
+
window: o,
|
|
851
|
+
enabled: c,
|
|
852
|
+
transform: f
|
|
853
|
+
} = n, h = Bt(n, Wt);
|
|
854
|
+
if (e.shared = S({
|
|
855
|
+
target: r,
|
|
856
|
+
eventOptions: i,
|
|
857
|
+
window: o,
|
|
858
|
+
enabled: c,
|
|
859
|
+
transform: f
|
|
860
|
+
}, Yt), t) {
|
|
861
|
+
const a = C.get(t);
|
|
862
|
+
e[t] = S(u({
|
|
863
|
+
shared: e.shared
|
|
864
|
+
}, h), a);
|
|
865
|
+
} else
|
|
866
|
+
for (const a in h) {
|
|
867
|
+
const g = C.get(a);
|
|
868
|
+
if (g)
|
|
869
|
+
e[a] = S(u({
|
|
870
|
+
shared: e.shared
|
|
871
|
+
}, h[a]), g);
|
|
872
|
+
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(a)) {
|
|
873
|
+
if (a === "domTarget")
|
|
874
|
+
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
875
|
+
console.warn(`[@use-gesture]: Unknown config key \`${a}\` was used. Please read the documentation for further information.`);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return e;
|
|
879
|
+
}
|
|
880
|
+
class J {
|
|
881
|
+
constructor(t, e) {
|
|
882
|
+
l(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
|
|
883
|
+
}
|
|
884
|
+
add(t, e, n, r, i) {
|
|
885
|
+
const o = this._listeners, c = pt(e, n), f = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, h = u(u({}, f), i);
|
|
886
|
+
t.addEventListener(c, r, h);
|
|
887
|
+
const a = () => {
|
|
888
|
+
t.removeEventListener(c, r, h), o.delete(a);
|
|
889
|
+
};
|
|
890
|
+
return o.add(a), a;
|
|
891
|
+
}
|
|
892
|
+
clean() {
|
|
893
|
+
this._listeners.forEach((t) => t()), this._listeners.clear();
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
class $t {
|
|
897
|
+
constructor() {
|
|
898
|
+
l(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
899
|
+
}
|
|
900
|
+
add(t, e, n = 140, ...r) {
|
|
901
|
+
this.remove(t), this._timeouts.set(t, window.setTimeout(e, n, ...r));
|
|
902
|
+
}
|
|
903
|
+
remove(t) {
|
|
904
|
+
const e = this._timeouts.get(t);
|
|
905
|
+
e && window.clearTimeout(e);
|
|
906
|
+
}
|
|
907
|
+
clean() {
|
|
908
|
+
this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
class Ht {
|
|
912
|
+
constructor(t) {
|
|
913
|
+
l(this, "gestures", /* @__PURE__ */ new Set()), l(this, "_targetEventStore", new J(this)), l(this, "gestureEventStores", {}), l(this, "gestureTimeoutStores", {}), l(this, "handlers", {}), l(this, "config", {}), l(this, "pointerIds", /* @__PURE__ */ new Set()), l(this, "touchIds", /* @__PURE__ */ new Set()), l(this, "state", {
|
|
914
|
+
shared: {
|
|
915
|
+
shiftKey: !1,
|
|
916
|
+
metaKey: !1,
|
|
917
|
+
ctrlKey: !1,
|
|
918
|
+
altKey: !1
|
|
919
|
+
}
|
|
920
|
+
}), Gt(this, t);
|
|
921
|
+
}
|
|
922
|
+
setEventIds(t) {
|
|
923
|
+
if (O(t))
|
|
924
|
+
return this.touchIds = new Set(_t(t)), this.touchIds;
|
|
925
|
+
if ("pointerId" in t)
|
|
926
|
+
return t.type === "pointerup" || t.type === "pointercancel" ? this.pointerIds.delete(t.pointerId) : t.type === "pointerdown" && this.pointerIds.add(t.pointerId), this.pointerIds;
|
|
927
|
+
}
|
|
928
|
+
applyHandlers(t, e) {
|
|
929
|
+
this.handlers = t, this.nativeHandlers = e;
|
|
930
|
+
}
|
|
931
|
+
applyConfig(t, e) {
|
|
932
|
+
this.config = Ft(t, e, this.config);
|
|
933
|
+
}
|
|
934
|
+
clean() {
|
|
935
|
+
this._targetEventStore.clean();
|
|
936
|
+
for (const t of this.gestures)
|
|
937
|
+
this.gestureEventStores[t].clean(), this.gestureTimeoutStores[t].clean();
|
|
938
|
+
}
|
|
939
|
+
effect() {
|
|
940
|
+
return this.config.shared.target && this.bind(), () => this._targetEventStore.clean();
|
|
941
|
+
}
|
|
942
|
+
bind(...t) {
|
|
943
|
+
const e = this.config.shared, n = {};
|
|
944
|
+
let r;
|
|
945
|
+
if (!(e.target && (r = e.target(), !r))) {
|
|
946
|
+
if (e.enabled) {
|
|
947
|
+
for (const o of this.gestures) {
|
|
948
|
+
const c = this.config[o], f = $(n, c.eventOptions, !!r);
|
|
949
|
+
if (c.enabled) {
|
|
950
|
+
const h = q.get(o);
|
|
951
|
+
new h(this, t, o).bind(f);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
const i = $(n, e.eventOptions, !!r);
|
|
955
|
+
for (const o in this.nativeHandlers)
|
|
956
|
+
i(o, "", (c) => this.nativeHandlers[o](u(u({}, this.state.shared), {}, {
|
|
957
|
+
event: c,
|
|
958
|
+
args: t
|
|
959
|
+
})), void 0, !0);
|
|
960
|
+
}
|
|
961
|
+
for (const i in n)
|
|
962
|
+
n[i] = bt(...n[i]);
|
|
963
|
+
if (!r)
|
|
964
|
+
return n;
|
|
965
|
+
for (const i in n) {
|
|
966
|
+
const {
|
|
967
|
+
device: o,
|
|
968
|
+
capture: c,
|
|
969
|
+
passive: f
|
|
970
|
+
} = lt(i);
|
|
971
|
+
this._targetEventStore.add(r, o, "", n[i], {
|
|
972
|
+
capture: c,
|
|
973
|
+
passive: f
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
function y(s, t) {
|
|
980
|
+
s.gestures.add(t), s.gestureEventStores[t] = new J(s, t), s.gestureTimeoutStores[t] = new $t();
|
|
981
|
+
}
|
|
982
|
+
function Gt(s, t) {
|
|
983
|
+
t.drag && y(s, "drag"), t.wheel && y(s, "wheel"), t.scroll && y(s, "scroll"), t.move && y(s, "move"), t.pinch && y(s, "pinch"), t.hover && y(s, "hover");
|
|
984
|
+
}
|
|
985
|
+
const $ = (s, t, e) => (n, r, i, o = {}, c = !1) => {
|
|
986
|
+
var f, h;
|
|
987
|
+
const a = (f = o.capture) !== null && f !== void 0 ? f : t.capture, g = (h = o.passive) !== null && h !== void 0 ? h : t.passive;
|
|
988
|
+
let p = c ? n : ht(n, r, a);
|
|
989
|
+
e && g && (p += "Passive"), s[p] = s[p] || [], s[p].push(i);
|
|
990
|
+
};
|
|
991
|
+
function Xt(s, t = {}, e, n) {
|
|
992
|
+
const r = I.useMemo(() => new Ht(s), []);
|
|
993
|
+
if (r.applyHandlers(s, n), r.applyConfig(t, e), I.useEffect(r.effect.bind(r)), I.useEffect(() => r.clean.bind(r), []), t.target === void 0)
|
|
994
|
+
return r.bind.bind(r);
|
|
995
|
+
}
|
|
996
|
+
function Jt(s, t) {
|
|
997
|
+
return Rt(Vt), Xt({
|
|
998
|
+
drag: s
|
|
999
|
+
}, t || {}, "drag");
|
|
1000
|
+
}
|
|
1001
|
+
export {
|
|
1002
|
+
Jt as a,
|
|
1003
|
+
qt as u
|
|
1004
|
+
};
|