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