react-spring-carousel 3.0.0-beta-1.0.39 → 3.0.0-beta-1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +189 -185
- package/dist/index.umd.js +7 -7
- package/package.json +12 -12
package/dist/index.es.js
CHANGED
|
@@ -61,8 +61,8 @@ function xe(r, e, t, n = 0.15) {
|
|
|
61
61
|
return n === 0 ? Ze(r, e, t) : r < e ? -we(e - r, t - e, n) + e : r > t ? +we(r - t, t - e, n) + t : r;
|
|
62
62
|
}
|
|
63
63
|
function et(r, [e, t], [n, i]) {
|
|
64
|
-
const [[c,
|
|
65
|
-
return [xe(e, c,
|
|
64
|
+
const [[c, o], [d, m]] = r;
|
|
65
|
+
return [xe(e, c, o, n), xe(t, d, m, i)];
|
|
66
66
|
}
|
|
67
67
|
function tt(r, e) {
|
|
68
68
|
if (typeof r != "object" || r === null) return r;
|
|
@@ -96,7 +96,7 @@ function Ie(r, e) {
|
|
|
96
96
|
}
|
|
97
97
|
return t;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function w(r) {
|
|
100
100
|
for (var e = 1; e < arguments.length; e++) {
|
|
101
101
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
102
102
|
e % 2 ? Ie(Object(t), !0).forEach(function(n) {
|
|
@@ -282,22 +282,22 @@ class mt {
|
|
|
282
282
|
D.addTo(t._distance, V);
|
|
283
283
|
}
|
|
284
284
|
this.axisIntent && this.axisIntent(e);
|
|
285
|
-
const [
|
|
285
|
+
const [o, d] = t._movement, [m, I] = n.threshold, {
|
|
286
286
|
_step: l,
|
|
287
|
-
values:
|
|
287
|
+
values: N
|
|
288
288
|
} = t;
|
|
289
|
-
if (n.hasCustomTransform ? (l[0] === !1 && (l[0] = Math.abs(
|
|
290
|
-
const
|
|
289
|
+
if (n.hasCustomTransform ? (l[0] === !1 && (l[0] = Math.abs(o) >= m && N[0]), l[1] === !1 && (l[1] = Math.abs(d) >= I && N[1])) : (l[0] === !1 && (l[0] = Math.abs(o) >= m && Math.sign(o) * m), l[1] === !1 && (l[1] = Math.abs(d) >= I && Math.sign(d) * I)), t.intentional = l[0] !== !1 || l[1] !== !1, !t.intentional) return;
|
|
290
|
+
const k = [0, 0];
|
|
291
291
|
if (n.hasCustomTransform) {
|
|
292
|
-
const [V, S] =
|
|
293
|
-
|
|
292
|
+
const [V, S] = N;
|
|
293
|
+
k[0] = l[0] !== !1 ? V - l[0] : 0, k[1] = l[1] !== !1 ? S - l[1] : 0;
|
|
294
294
|
} else
|
|
295
|
-
|
|
296
|
-
this.restrictToAxis && !t._blocked && this.restrictToAxis(
|
|
295
|
+
k[0] = l[0] !== !1 ? o - l[0] : 0, k[1] = l[1] !== !1 ? d - l[1] : 0;
|
|
296
|
+
this.restrictToAxis && !t._blocked && this.restrictToAxis(k);
|
|
297
297
|
const O = t.offset, $ = t._active && !t._blocked || t.active;
|
|
298
|
-
$ && (t.first = t._active && !t.active, t.last = !t._active && t.active, t.active = i[this.ingKey] = t._active, e && (t.first && ("bounds" in n && (t._bounds = ce(n.bounds, t)), this.setup && this.setup()), t.movement =
|
|
299
|
-
const [F,
|
|
300
|
-
t.overflow = [F < E ? -1 : F > L ? 1 : 0,
|
|
298
|
+
$ && (t.first = t._active && !t.active, t.last = !t._active && t.active, t.active = i[this.ingKey] = t._active, e && (t.first && ("bounds" in n && (t._bounds = ce(n.bounds, t)), this.setup && this.setup()), t.movement = k, this.computeOffset()));
|
|
299
|
+
const [F, x] = t.offset, [[E, L], [q, J]] = t._bounds;
|
|
300
|
+
t.overflow = [F < E ? -1 : F > L ? 1 : 0, x < q ? -1 : x > J ? 1 : 0], t._movementBound[0] = t.overflow[0] ? t._movementBound[0] === !1 ? t._movement[0] : t._movementBound[0] : !1, t._movementBound[1] = t.overflow[1] ? t._movementBound[1] === !1 ? t._movement[1] : t._movementBound[1] : !1;
|
|
301
301
|
const b = t._active ? n.rubberband || [0, 0] : [0, 0];
|
|
302
302
|
if (t.offset = et(t._bounds, t.offset, b), t.delta = D.sub(t.offset, O), this.computeMovement(), $ && (!t.last || c > gt)) {
|
|
303
303
|
t.delta = D.sub(t.offset, O);
|
|
@@ -308,7 +308,7 @@ class mt {
|
|
|
308
308
|
emit() {
|
|
309
309
|
const e = this.state, t = this.shared, n = this.config;
|
|
310
310
|
if (e._active || this.clean(), (e._blocked || !e.intentional) && !e._force && !n.triggerAllEvents) return;
|
|
311
|
-
const i = this.handler(
|
|
311
|
+
const i = this.handler(w(w(w({}, t), e), {}, {
|
|
312
312
|
[this.aliasKey]: e.values
|
|
313
313
|
}));
|
|
314
314
|
i !== void 0 && (e.memo = i);
|
|
@@ -360,12 +360,12 @@ class bt extends mt {
|
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
-
const
|
|
363
|
+
const ke = (r) => r, Te = 0.15, ve = {
|
|
364
364
|
enabled(r = !0) {
|
|
365
365
|
return r;
|
|
366
366
|
},
|
|
367
367
|
eventOptions(r, e, t) {
|
|
368
|
-
return
|
|
368
|
+
return w(w({}, t.shared.eventOptions), r);
|
|
369
369
|
},
|
|
370
370
|
preventDefault(r = !1) {
|
|
371
371
|
return r;
|
|
@@ -376,7 +376,7 @@ const Te = (r) => r, ke = 0.15, ve = {
|
|
|
376
376
|
rubberband(r = 0) {
|
|
377
377
|
switch (r) {
|
|
378
378
|
case !0:
|
|
379
|
-
return [
|
|
379
|
+
return [Te, Te];
|
|
380
380
|
case !1:
|
|
381
381
|
return [0, 0];
|
|
382
382
|
default:
|
|
@@ -390,13 +390,13 @@ const Te = (r) => r, ke = 0.15, ve = {
|
|
|
390
390
|
transform(r, e, t) {
|
|
391
391
|
const n = r || t.shared.transform;
|
|
392
392
|
if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
|
|
393
|
-
const i = n ||
|
|
393
|
+
const i = n || ke;
|
|
394
394
|
return (c) => {
|
|
395
|
-
const
|
|
396
|
-
return (!isFinite(
|
|
395
|
+
const o = i(c);
|
|
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
397
|
};
|
|
398
398
|
}
|
|
399
|
-
return n ||
|
|
399
|
+
return n || ke;
|
|
400
400
|
},
|
|
401
401
|
threshold(r) {
|
|
402
402
|
return D.toVector(r, 0);
|
|
@@ -419,7 +419,7 @@ process.env.NODE_ENV === "development" && Object.assign(ve, {
|
|
|
419
419
|
return NaN;
|
|
420
420
|
}
|
|
421
421
|
});
|
|
422
|
-
const yt = 0, ee =
|
|
422
|
+
const yt = 0, ee = w(w({}, ve), {}, {
|
|
423
423
|
axis(r, e, {
|
|
424
424
|
axis: t
|
|
425
425
|
}) {
|
|
@@ -527,14 +527,14 @@ class _t extends bt {
|
|
|
527
527
|
const i = pe(e);
|
|
528
528
|
if (t._pointerId !== void 0 && i !== t._pointerId) return;
|
|
529
529
|
this.state._pointerActive = !1, this.setActive(), this.compute(e);
|
|
530
|
-
const [c,
|
|
531
|
-
if (t.tap = c <= n.tapsThreshold &&
|
|
530
|
+
const [c, o] = t._distance;
|
|
531
|
+
if (t.tap = c <= n.tapsThreshold && o <= n.tapsThreshold, t.tap && n.filterTaps)
|
|
532
532
|
t._force = !0;
|
|
533
533
|
else {
|
|
534
|
-
const [d, m] = t._delta, [I, l] = t._movement, [
|
|
534
|
+
const [d, m] = t._delta, [I, l] = t._movement, [N, k] = n.swipe.velocity, [O, $] = n.swipe.distance, F = n.swipe.duration;
|
|
535
535
|
if (t.elapsedTime < F) {
|
|
536
|
-
const
|
|
537
|
-
|
|
536
|
+
const x = Math.abs(d / t.timeDelta), E = Math.abs(m / t.timeDelta);
|
|
537
|
+
x > N && Math.abs(I) > O && (t.swipe[0] = Math.sign(d)), E > k && Math.abs(l) > $ && (t.swipe[1] = Math.sign(m));
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
540
|
this.emit();
|
|
@@ -620,11 +620,11 @@ const R = {
|
|
|
620
620
|
touchscreen: xt(),
|
|
621
621
|
pointer: It(),
|
|
622
622
|
pointerLock: Et()
|
|
623
|
-
}, Dt = 250,
|
|
623
|
+
}, Dt = 250, kt = 180, Tt = 0.5, Ct = 50, Ot = 250, Pt = 10, Oe = {
|
|
624
624
|
mouse: 0,
|
|
625
625
|
touch: 0,
|
|
626
626
|
pen: 8
|
|
627
|
-
}, Le =
|
|
627
|
+
}, Le = w(w({}, ee), {}, {
|
|
628
628
|
device(r, e, {
|
|
629
629
|
pointer: {
|
|
630
630
|
touch: t = !1,
|
|
@@ -658,7 +658,7 @@ const R = {
|
|
|
658
658
|
return this.filterTaps = t, this.tapsThreshold = n, c;
|
|
659
659
|
},
|
|
660
660
|
swipe({
|
|
661
|
-
velocity: r =
|
|
661
|
+
velocity: r = Tt,
|
|
662
662
|
distance: e = Ct,
|
|
663
663
|
duration: t = Ot
|
|
664
664
|
} = {}) {
|
|
@@ -671,7 +671,7 @@ const R = {
|
|
|
671
671
|
delay(r = 0) {
|
|
672
672
|
switch (r) {
|
|
673
673
|
case !0:
|
|
674
|
-
return
|
|
674
|
+
return kt;
|
|
675
675
|
case !1:
|
|
676
676
|
return 0;
|
|
677
677
|
default:
|
|
@@ -679,7 +679,7 @@ const R = {
|
|
|
679
679
|
}
|
|
680
680
|
},
|
|
681
681
|
axisThreshold(r) {
|
|
682
|
-
return r ?
|
|
682
|
+
return r ? w(w({}, Oe), r) : Oe;
|
|
683
683
|
},
|
|
684
684
|
keyboardDisplacement(r = Pt) {
|
|
685
685
|
return r;
|
|
@@ -712,7 +712,7 @@ process.env.NODE_ENV === "development" && Object.assign(Le, {
|
|
|
712
712
|
return NaN;
|
|
713
713
|
}
|
|
714
714
|
});
|
|
715
|
-
|
|
715
|
+
w(w({}, ve), {}, {
|
|
716
716
|
device(r, e, {
|
|
717
717
|
shared: t,
|
|
718
718
|
pointer: {
|
|
@@ -730,20 +730,20 @@ _(_({}, ve), {}, {
|
|
|
730
730
|
scaleBounds: t = {},
|
|
731
731
|
angleBounds: n = {}
|
|
732
732
|
}) {
|
|
733
|
-
const i = (
|
|
734
|
-
const d = De(ce(t,
|
|
733
|
+
const i = (o) => {
|
|
734
|
+
const d = De(ce(t, o), {
|
|
735
735
|
min: -1 / 0,
|
|
736
736
|
max: 1 / 0
|
|
737
737
|
});
|
|
738
738
|
return [d.min, d.max];
|
|
739
|
-
}, c = (
|
|
740
|
-
const d = De(ce(n,
|
|
739
|
+
}, c = (o) => {
|
|
740
|
+
const d = De(ce(n, o), {
|
|
741
741
|
min: -1 / 0,
|
|
742
742
|
max: 1 / 0
|
|
743
743
|
});
|
|
744
744
|
return [d.min, d.max];
|
|
745
745
|
};
|
|
746
|
-
return typeof t != "function" && typeof n != "function" ? [i(), c()] : (
|
|
746
|
+
return typeof t != "function" && typeof n != "function" ? [i(), c()] : (o) => [i(o), c(o)];
|
|
747
747
|
},
|
|
748
748
|
threshold(r, e, t) {
|
|
749
749
|
return this.lockDirection = t.axis === "lock", D.toVector(r, this.lockDirection ? [0.1, 3] : 0);
|
|
@@ -755,10 +755,10 @@ _(_({}, ve), {}, {
|
|
|
755
755
|
return r;
|
|
756
756
|
}
|
|
757
757
|
});
|
|
758
|
-
|
|
758
|
+
w(w({}, ee), {}, {
|
|
759
759
|
mouseOnly: (r = !0) => r
|
|
760
760
|
});
|
|
761
|
-
|
|
761
|
+
w(w({}, ee), {}, {
|
|
762
762
|
mouseOnly: (r = !0) => r
|
|
763
763
|
});
|
|
764
764
|
const Ve = /* @__PURE__ */ new Map(), me = /* @__PURE__ */ new Map();
|
|
@@ -835,28 +835,28 @@ function Vt(r, e, t = {}) {
|
|
|
835
835
|
const n = r, {
|
|
836
836
|
target: i,
|
|
837
837
|
eventOptions: c,
|
|
838
|
-
window:
|
|
838
|
+
window: o,
|
|
839
839
|
enabled: d,
|
|
840
840
|
transform: m
|
|
841
841
|
} = n, I = Rt(n, Lt);
|
|
842
842
|
if (t.shared = oe({
|
|
843
843
|
target: i,
|
|
844
844
|
eventOptions: c,
|
|
845
|
-
window:
|
|
845
|
+
window: o,
|
|
846
846
|
enabled: d,
|
|
847
847
|
transform: m
|
|
848
848
|
}, $t), e) {
|
|
849
849
|
const l = me.get(e);
|
|
850
|
-
t[e] = oe(
|
|
850
|
+
t[e] = oe(w({
|
|
851
851
|
shared: t.shared
|
|
852
852
|
}, I), l);
|
|
853
853
|
} else
|
|
854
854
|
for (const l in I) {
|
|
855
|
-
const
|
|
856
|
-
if (
|
|
857
|
-
t[l] = oe(
|
|
855
|
+
const N = me.get(l);
|
|
856
|
+
if (N)
|
|
857
|
+
t[l] = oe(w({
|
|
858
858
|
shared: t.shared
|
|
859
|
-
}, I[l]),
|
|
859
|
+
}, I[l]), N);
|
|
860
860
|
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(l)) {
|
|
861
861
|
if (l === "domTarget")
|
|
862
862
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -870,12 +870,12 @@ class Be {
|
|
|
870
870
|
C(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = e, this._gestureKey = t;
|
|
871
871
|
}
|
|
872
872
|
add(e, t, n, i, c) {
|
|
873
|
-
const
|
|
873
|
+
const o = this._listeners, d = at(t, n), m = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, I = w(w({}, m), c);
|
|
874
874
|
e.addEventListener(d, i, I);
|
|
875
875
|
const l = () => {
|
|
876
|
-
e.removeEventListener(d, i, I),
|
|
876
|
+
e.removeEventListener(d, i, I), o.delete(l);
|
|
877
877
|
};
|
|
878
|
-
return
|
|
878
|
+
return o.add(l), l;
|
|
879
879
|
}
|
|
880
880
|
clean() {
|
|
881
881
|
this._listeners.forEach((e) => e()), this._listeners.clear();
|
|
@@ -932,16 +932,16 @@ class Ut {
|
|
|
932
932
|
let i;
|
|
933
933
|
if (!(t.target && (i = t.target(), !i))) {
|
|
934
934
|
if (t.enabled) {
|
|
935
|
-
for (const
|
|
936
|
-
const d = this.config[
|
|
935
|
+
for (const o of this.gestures) {
|
|
936
|
+
const d = this.config[o], m = Pe(n, d.eventOptions, !!i);
|
|
937
937
|
if (d.enabled) {
|
|
938
|
-
const I = Ve.get(
|
|
939
|
-
new I(this, e,
|
|
938
|
+
const I = Ve.get(o);
|
|
939
|
+
new I(this, e, o).bind(m);
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
942
|
const c = Pe(n, t.eventOptions, !!i);
|
|
943
|
-
for (const
|
|
944
|
-
c(
|
|
943
|
+
for (const o in this.nativeHandlers)
|
|
944
|
+
c(o, "", (d) => this.nativeHandlers[o](w(w({}, this.state.shared), {}, {
|
|
945
945
|
event: d,
|
|
946
946
|
args: e
|
|
947
947
|
})), void 0, !0);
|
|
@@ -951,11 +951,11 @@ class Ut {
|
|
|
951
951
|
if (!i) return n;
|
|
952
952
|
for (const c in n) {
|
|
953
953
|
const {
|
|
954
|
-
device:
|
|
954
|
+
device: o,
|
|
955
955
|
capture: d,
|
|
956
956
|
passive: m
|
|
957
957
|
} = ct(c);
|
|
958
|
-
this._targetEventStore.add(i,
|
|
958
|
+
this._targetEventStore.add(i, o, "", n[c], {
|
|
959
959
|
capture: d,
|
|
960
960
|
passive: m
|
|
961
961
|
});
|
|
@@ -969,11 +969,11 @@ function X(r, e) {
|
|
|
969
969
|
function jt(r, e) {
|
|
970
970
|
e.drag && X(r, "drag"), e.wheel && X(r, "wheel"), e.scroll && X(r, "scroll"), e.move && X(r, "move"), e.pinch && X(r, "pinch"), e.hover && X(r, "hover");
|
|
971
971
|
}
|
|
972
|
-
const Pe = (r, e, t) => (n, i, c,
|
|
972
|
+
const Pe = (r, e, t) => (n, i, c, o = {}, d = !1) => {
|
|
973
973
|
var m, I;
|
|
974
|
-
const l = (m =
|
|
975
|
-
let
|
|
976
|
-
t &&
|
|
974
|
+
const l = (m = o.capture) !== null && m !== void 0 ? m : e.capture, N = (I = o.passive) !== null && I !== void 0 ? I : e.passive;
|
|
975
|
+
let k = d ? n : st(n, i, l);
|
|
976
|
+
t && N && (k += "Passive"), r[k] = r[k] || [], r[k].push(c);
|
|
977
977
|
};
|
|
978
978
|
function Gt(r, e = {}, t, n) {
|
|
979
979
|
const i = de.useMemo(() => new Ut(r), []);
|
|
@@ -986,11 +986,11 @@ function Kt(r, e) {
|
|
|
986
986
|
}, e || {}, "drag");
|
|
987
987
|
}
|
|
988
988
|
function Ft(r) {
|
|
989
|
-
const { left: e, right: t, top: n, bottom: i } = r.getBoundingClientRect(), { innerWidth: c, innerHeight:
|
|
989
|
+
const { left: e, right: t, top: n, bottom: i } = r.getBoundingClientRect(), { innerWidth: c, innerHeight: o } = window;
|
|
990
990
|
return e < 0 || n < 0 ? {
|
|
991
991
|
isOut: !0,
|
|
992
992
|
direction: "start"
|
|
993
|
-
} : Math.floor(t) > Math.floor(c) || Math.floor(i) > Math.floor(
|
|
993
|
+
} : Math.floor(t) > Math.floor(c) || Math.floor(i) > Math.floor(o) ? {
|
|
994
994
|
isOut: !0,
|
|
995
995
|
direction: "end"
|
|
996
996
|
} : {
|
|
@@ -1011,35 +1011,35 @@ function Xt({
|
|
|
1011
1011
|
scrollAmount: n,
|
|
1012
1012
|
withLoop: i = !1,
|
|
1013
1013
|
enableGestures: c = !0,
|
|
1014
|
-
carouselAxis:
|
|
1014
|
+
carouselAxis: o = "x",
|
|
1015
1015
|
slideWhenDragThresholdIsReached: d = !0,
|
|
1016
1016
|
itemsPerSlide: m,
|
|
1017
1017
|
scrollAmountType: I,
|
|
1018
1018
|
gutter: l = 0,
|
|
1019
|
-
startEndGutter:
|
|
1020
|
-
fadeIn:
|
|
1019
|
+
startEndGutter: N = 0,
|
|
1020
|
+
fadeIn: k = !1
|
|
1021
1021
|
}) {
|
|
1022
|
-
const O = M(!1), $ = M([]), F = M(!1),
|
|
1023
|
-
...e.map((
|
|
1024
|
-
...
|
|
1025
|
-
id: `prev-repeated-item-${
|
|
1022
|
+
const O = M(!1), $ = M([]), F = M(!1), x = m ?? 1, E = I ?? "slide", L = i ? [
|
|
1023
|
+
...e.map((s) => ({
|
|
1024
|
+
...s,
|
|
1025
|
+
id: `prev-repeated-item-${s.id}`
|
|
1026
1026
|
})),
|
|
1027
1027
|
...e,
|
|
1028
|
-
...e.map((
|
|
1029
|
-
...
|
|
1030
|
-
id: `next-repeated-item-${
|
|
1028
|
+
...e.map((s) => ({
|
|
1029
|
+
...s,
|
|
1030
|
+
id: `next-repeated-item-${s.id}`
|
|
1031
1031
|
}))
|
|
1032
1032
|
] : e, q = M(n), J = M(0), b = Xe().replace(/:/g, ""), V = M(null), S = M(null), be = M(0), p = M(!0), h = M(!1), a = M(0), [B, re] = qe(() => ({
|
|
1033
1033
|
value: 0,
|
|
1034
|
-
onChange({ value:
|
|
1035
|
-
(t === "fixed" || t === "fluid") && (
|
|
1034
|
+
onChange({ value: s }) {
|
|
1035
|
+
(t === "fixed" || t === "fluid") && (o === "x" ? S.current.style.transform = `translate3d(${s.value}px, 0px, 0px)` : S.current.style.transform = `translate3d(${s.value}px, 0px, 0px)`), t === "freeScroll" && (S.current[o === "x" ? "scrollLeft" : "scrollTop"] = Math.abs(s.value));
|
|
1036
1036
|
}
|
|
1037
1037
|
})), { useListenToCustomEvent: Ue, emitEvent: W } = Qe();
|
|
1038
1038
|
function g() {
|
|
1039
1039
|
return Y(q.current ?? 0);
|
|
1040
1040
|
}
|
|
1041
1041
|
function G() {
|
|
1042
|
-
return S.current[
|
|
1042
|
+
return S.current[o === "x" ? "scrollWidth" : "scrollHeight"] - V.current.getBoundingClientRect()[o === "x" ? "width" : "height"];
|
|
1043
1043
|
}
|
|
1044
1044
|
function Q() {
|
|
1045
1045
|
ge("The carousel can't be initialized. List of errors:"), console.table($.current);
|
|
@@ -1049,63 +1049,63 @@ function Xt({
|
|
|
1049
1049
|
onWheel() {
|
|
1050
1050
|
B.value.stop();
|
|
1051
1051
|
},
|
|
1052
|
-
onScroll(
|
|
1053
|
-
const f =
|
|
1052
|
+
onScroll(s) {
|
|
1053
|
+
const f = s.currentTarget, v = o === "x" ? f.scrollLeft : f.scrollTop, u = o === "x" ? f.scrollWidth - f.clientWidth : f.scrollHeight - f.clientHeight;
|
|
1054
1054
|
v === 0 ? p.current = !0 : v === u ? h.current = !0 : (p.current = !1, h.current = !1);
|
|
1055
1055
|
}
|
|
1056
1056
|
} : {};
|
|
1057
1057
|
}
|
|
1058
1058
|
function Ge() {
|
|
1059
|
-
let
|
|
1059
|
+
let s = 0, f = 0;
|
|
1060
1060
|
const v = getComputedStyle(
|
|
1061
1061
|
document.documentElement
|
|
1062
1062
|
).getPropertyValue(`--${b}-react-spring-carousel-item-gutter`), u = getComputedStyle(
|
|
1063
1063
|
document.documentElement
|
|
1064
1064
|
).getPropertyValue(`--${b}-react-spring-carousel-item-gutter`);
|
|
1065
|
-
return u.includes("px") && (
|
|
1065
|
+
return u.includes("px") && (s = Number(u.replace("px", ""))), v.includes("px") && (f = Number(
|
|
1066
1066
|
v.replace("px", "")
|
|
1067
|
-
)), { totalGutterCssVar:
|
|
1067
|
+
)), { totalGutterCssVar: s, totalStartEndGutterCssVar: f };
|
|
1068
1068
|
}
|
|
1069
1069
|
function Ke() {
|
|
1070
|
-
return
|
|
1070
|
+
return x > 1 ? `calc(100% / ${x} - var(--${b}-react-spring-carousel-item-gutter) / ${x} * ${x - 1}) !important` : "100% !important";
|
|
1071
1071
|
}
|
|
1072
1072
|
function ne({
|
|
1073
|
-
type:
|
|
1073
|
+
type: s,
|
|
1074
1074
|
actionType: f,
|
|
1075
1075
|
newActiveItem: v
|
|
1076
1076
|
}) {
|
|
1077
1077
|
var U, K, H, Z, ie, ye, _e;
|
|
1078
|
-
let u = 0,
|
|
1078
|
+
let u = 0, y = B.value.get();
|
|
1079
1079
|
if (p.current = !1, h.current = !1, t === "fixed") {
|
|
1080
|
-
const
|
|
1081
|
-
if (
|
|
1082
|
-
const
|
|
1083
|
-
j && (h.current = !0), u = -(a.current * g()), z && (a.current = 0,
|
|
1080
|
+
const T = a.current;
|
|
1081
|
+
if (s === "prev" && (a.current = v ?? a.current - 1), s === "next" && (a.current = v ?? a.current + 1), i && E === "group" && x > 1 && s === "next") {
|
|
1082
|
+
const _ = e.length / x, j = Math.ceil(_) - 1 === a.current, z = Math.ceil(_) === a.current;
|
|
1083
|
+
j && (h.current = !0), u = -(a.current * g()), z && (a.current = 0, y = B.value.get() + g() * _, u = 0, h.current = !1, p.current = !0);
|
|
1084
1084
|
}
|
|
1085
|
-
if (i && E === "group" &&
|
|
1086
|
-
const
|
|
1087
|
-
u = -(a.current * g()), j && (p.current = !0), z && (p.current = !1, h.current = !0, a.current =
|
|
1085
|
+
if (i && E === "group" && x > 1 && s === "prev") {
|
|
1086
|
+
const _ = e.length / x, j = a.current === 0, z = a.current === -1;
|
|
1087
|
+
u = -(a.current * g()), j && (p.current = !0), z && (p.current = !1, h.current = !0, a.current = _ - 1, y = B.value.get() - g() * _, u = -g() * _ + g());
|
|
1088
1088
|
}
|
|
1089
|
-
if (!i && E === "group" &&
|
|
1090
|
-
const
|
|
1089
|
+
if (!i && E === "group" && x > 1) {
|
|
1090
|
+
const _ = e.length / x, j = 2 % _ !== 0, z = Math.ceil(_ - 1) === a.current, fe = a.current === 0;
|
|
1091
1091
|
u = -(a.current * g()), fe && (p.current = !0), z && (h.current = !0, j && (u = -G()));
|
|
1092
1092
|
}
|
|
1093
|
-
if (i &&
|
|
1094
|
-
const
|
|
1093
|
+
if (i && s === "next" && (E === "slide" || E === "group" && x === 1)) {
|
|
1094
|
+
const _ = ((U = e[a.current]) == null ? void 0 : U.id) === e[e.length - 1].id, j = L[e.length + a.current].id.includes(
|
|
1095
1095
|
"repeated-item"
|
|
1096
1096
|
);
|
|
1097
|
-
|
|
1097
|
+
_ && (h.current = !0), j && (a.current = 0, y = B.value.get() + g() * e.length, h.current = !1, p.current = !0), u = -(a.current * g());
|
|
1098
1098
|
}
|
|
1099
|
-
if (i &&
|
|
1100
|
-
const
|
|
1101
|
-
(fe) => fe.id === e[
|
|
1102
|
-
), j = ((K = e[a.current]) == null ? void 0 : K.id) === e[0].id, z = L[
|
|
1103
|
-
j && (p.current = !0), z && (p.current = !1, h.current = !0, a.current = e.length - 1,
|
|
1099
|
+
if (i && s === "prev" && (E === "slide" || E === "group" && x === 1)) {
|
|
1100
|
+
const _ = L.findIndex(
|
|
1101
|
+
(fe) => fe.id === e[T].id
|
|
1102
|
+
), j = ((K = e[a.current]) == null ? void 0 : K.id) === e[0].id, z = L[_ - 1].id.includes("repeated-item");
|
|
1103
|
+
j && (p.current = !0), z && (p.current = !1, h.current = !0, a.current = e.length - 1, y = B.value.get() - g() * e.length), u = -(a.current * g());
|
|
1104
1104
|
}
|
|
1105
|
-
!i && E === "slide" && (((H = e[a.current + 1]) == null ? void 0 : H.id) === e[e.length - 1].id ? h.current = !0 : a.current === 0 ? p.current = !0 : (p.current = !1, h.current = !1), u = -(a.current * g()),
|
|
1105
|
+
!i && E === "slide" && (((H = e[a.current + 1]) == null ? void 0 : H.id) === e[e.length - 1].id ? h.current = !0 : a.current === 0 ? p.current = !0 : (p.current = !1, h.current = !1), u = -(a.current * g()), s === "next" && Math.abs(u) > G() && (h.current = !0, u = -G())), W({
|
|
1106
1106
|
eventName: "onSlideStartChange",
|
|
1107
1107
|
sliceActionType: f,
|
|
1108
|
-
slideDirection:
|
|
1108
|
+
slideDirection: s,
|
|
1109
1109
|
nextItem: {
|
|
1110
1110
|
index: a.current,
|
|
1111
1111
|
id: e[a.current].id,
|
|
@@ -1115,26 +1115,26 @@ function Xt({
|
|
|
1115
1115
|
});
|
|
1116
1116
|
}
|
|
1117
1117
|
if (t === "fluid") {
|
|
1118
|
-
if (
|
|
1119
|
-
const
|
|
1118
|
+
if (s === "prev" && (a.current = v ?? a.current - 1), s === "next" && (a.current = v ?? a.current + 1), u = -(a.current * g()), s === "next" && i) {
|
|
1119
|
+
const T = ((Z = e[a.current]) == null ? void 0 : Z.id) === e[e.length - 1].id, _ = L[e.length + a.current].id.includes(
|
|
1120
1120
|
"repeated-item"
|
|
1121
1121
|
);
|
|
1122
|
-
|
|
1122
|
+
T && (h.current = !0), _ && (a.current = 0, y = B.value.get() + g() * e.length, u = 0, h.current = !1, p.current = !0);
|
|
1123
1123
|
}
|
|
1124
|
-
if (
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1124
|
+
if (s === "next" && !i) {
|
|
1125
|
+
const T = Math.abs(u) > G();
|
|
1126
|
+
T || T ? (h.current = !0, u = -G()) : (p.current = !1, h.current = !1);
|
|
1127
1127
|
}
|
|
1128
|
-
if (
|
|
1129
|
-
const
|
|
1128
|
+
if (s === "prev" && !i && ((ie = e[a.current]) == null ? void 0 : ie.id) === e[0].id && (p.current = !0), s === "prev" && i) {
|
|
1129
|
+
const T = ((ye = e[a.current]) == null ? void 0 : ye.id) === e[0].id, _ = (_e = L[e.length + a.current]) == null ? void 0 : _e.id.includes(
|
|
1130
1130
|
"repeated-item"
|
|
1131
1131
|
);
|
|
1132
|
-
|
|
1132
|
+
T && (p.current = !0), _ && (a.current = e.length - 1, y = B.value.get() - g() * e.length, u = -(g() * e.length - g()), p.current = !1, h.current = !0);
|
|
1133
1133
|
}
|
|
1134
1134
|
W({
|
|
1135
1135
|
eventName: "onSlideStartChange",
|
|
1136
1136
|
sliceActionType: f,
|
|
1137
|
-
slideDirection:
|
|
1137
|
+
slideDirection: s,
|
|
1138
1138
|
nextItem: {
|
|
1139
1139
|
startReached: p.current,
|
|
1140
1140
|
endReached: h.current,
|
|
@@ -1144,21 +1144,21 @@ function Xt({
|
|
|
1144
1144
|
});
|
|
1145
1145
|
}
|
|
1146
1146
|
if (t === "freeScroll") {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1147
|
+
const T = S.current[o === "x" ? "scrollLeft" : "scrollTop"], _ = o === "x" ? S.current.scrollWidth - S.current.clientWidth : S.current.scrollHeight - S.current.clientHeight;
|
|
1148
|
+
y = T, s === "prev" && (u = y - g(), u < 0 && (u = 0), y - g() <= 0 && (p.current = !0), W({
|
|
1149
1149
|
eventName: "onSlideStartChange",
|
|
1150
1150
|
sliceActionType: f,
|
|
1151
|
-
slideDirection:
|
|
1151
|
+
slideDirection: s,
|
|
1152
1152
|
nextItem: {
|
|
1153
1153
|
index: 0,
|
|
1154
1154
|
id: "",
|
|
1155
1155
|
startReached: p.current,
|
|
1156
1156
|
endReached: !1
|
|
1157
1157
|
}
|
|
1158
|
-
})),
|
|
1158
|
+
})), s === "next" && (u = y + g(), u > _ && (u = _), y + g() >= _ && (h.current = !0), W({
|
|
1159
1159
|
eventName: "onSlideStartChange",
|
|
1160
1160
|
sliceActionType: f,
|
|
1161
|
-
slideDirection:
|
|
1161
|
+
slideDirection: s,
|
|
1162
1162
|
nextItem: {
|
|
1163
1163
|
index: 0,
|
|
1164
1164
|
id: "",
|
|
@@ -1167,29 +1167,29 @@ function Xt({
|
|
|
1167
1167
|
}
|
|
1168
1168
|
}));
|
|
1169
1169
|
}
|
|
1170
|
-
const
|
|
1171
|
-
be.current =
|
|
1170
|
+
const P = Y(y), A = Y(u);
|
|
1171
|
+
be.current = A, re.start({
|
|
1172
1172
|
from: {
|
|
1173
|
-
value:
|
|
1173
|
+
value: P
|
|
1174
1174
|
},
|
|
1175
1175
|
to: {
|
|
1176
|
-
value:
|
|
1176
|
+
value: A
|
|
1177
1177
|
},
|
|
1178
|
-
onRest({ finished:
|
|
1179
|
-
|
|
1178
|
+
onRest({ finished: T }) {
|
|
1179
|
+
T && t === "fixed" && W({
|
|
1180
1180
|
eventName: "onSlideChangeComplete",
|
|
1181
1181
|
sliceActionType: f,
|
|
1182
|
-
slideDirection:
|
|
1182
|
+
slideDirection: s,
|
|
1183
1183
|
currentItem: {
|
|
1184
1184
|
index: a.current,
|
|
1185
1185
|
id: e[a.current].id,
|
|
1186
1186
|
startReached: p.current,
|
|
1187
1187
|
endReached: h.current
|
|
1188
1188
|
}
|
|
1189
|
-
}),
|
|
1189
|
+
}), T && t === "fluid" && W({
|
|
1190
1190
|
eventName: "onSlideChangeComplete",
|
|
1191
1191
|
sliceActionType: f,
|
|
1192
|
-
slideDirection:
|
|
1192
|
+
slideDirection: s,
|
|
1193
1193
|
currentItem: {
|
|
1194
1194
|
index: 0,
|
|
1195
1195
|
id: "",
|
|
@@ -1200,63 +1200,63 @@ function Xt({
|
|
|
1200
1200
|
}
|
|
1201
1201
|
});
|
|
1202
1202
|
}
|
|
1203
|
-
function ue(
|
|
1203
|
+
function ue(s, f) {
|
|
1204
1204
|
if (!O.current) {
|
|
1205
1205
|
Q();
|
|
1206
1206
|
return;
|
|
1207
1207
|
}
|
|
1208
|
-
if (t === "fixed" && i || t === "fixed" && !i && !h.current) {
|
|
1208
|
+
if (s === "drag" || t === "fixed" && i || t === "fixed" && !i && !h.current) {
|
|
1209
1209
|
const v = f ?? a.current + 1;
|
|
1210
1210
|
ne({
|
|
1211
1211
|
type: "next",
|
|
1212
|
-
actionType:
|
|
1212
|
+
actionType: s,
|
|
1213
1213
|
newActiveItem: v
|
|
1214
1214
|
});
|
|
1215
1215
|
}
|
|
1216
1216
|
(t === "fluid" && i || t === "fluid" && !i && !h.current || t === "freeScroll" && !h.current) && ne({
|
|
1217
1217
|
type: "next",
|
|
1218
|
-
actionType:
|
|
1218
|
+
actionType: s
|
|
1219
1219
|
});
|
|
1220
1220
|
}
|
|
1221
|
-
function le(
|
|
1221
|
+
function le(s, f) {
|
|
1222
1222
|
if (!O.current) {
|
|
1223
1223
|
Q();
|
|
1224
1224
|
return;
|
|
1225
1225
|
}
|
|
1226
|
-
if (t === "fixed" && i || t === "fixed" && !i && !p.current) {
|
|
1226
|
+
if (s === "drag" || t === "fixed" && i || t === "fixed" && !i && !p.current) {
|
|
1227
1227
|
const v = f ?? a.current - 1;
|
|
1228
1228
|
ne({
|
|
1229
1229
|
type: "prev",
|
|
1230
|
-
actionType:
|
|
1230
|
+
actionType: s,
|
|
1231
1231
|
newActiveItem: v
|
|
1232
1232
|
});
|
|
1233
1233
|
}
|
|
1234
1234
|
(t === "fluid" && i || t === "fluid" && !i && !p.current || t === "freeScroll" && !p.current) && ne({
|
|
1235
1235
|
type: "prev",
|
|
1236
|
-
actionType:
|
|
1236
|
+
actionType: s
|
|
1237
1237
|
});
|
|
1238
1238
|
}
|
|
1239
|
-
function Fe(
|
|
1239
|
+
function Fe(s) {
|
|
1240
1240
|
let f = 0;
|
|
1241
|
-
typeof
|
|
1241
|
+
typeof s == "string" ? f = e.findIndex((v) => v.id === s) : f = s, f > a.current && ue("click", f), f < a.current && le("click", f);
|
|
1242
1242
|
}
|
|
1243
1243
|
function We({
|
|
1244
|
-
getContainer:
|
|
1244
|
+
getContainer: s,
|
|
1245
1245
|
activeItem: f,
|
|
1246
1246
|
updateTotalValue: v
|
|
1247
1247
|
}) {
|
|
1248
|
-
const u =
|
|
1248
|
+
const u = s();
|
|
1249
1249
|
if (!(u instanceof HTMLElement)) {
|
|
1250
1250
|
console.warn(
|
|
1251
1251
|
`Container is not a valid html element: container is ${u}`
|
|
1252
1252
|
);
|
|
1253
1253
|
return;
|
|
1254
1254
|
}
|
|
1255
|
-
const
|
|
1256
|
-
if (
|
|
1257
|
-
const
|
|
1255
|
+
const y = u.children[f];
|
|
1256
|
+
if (y) {
|
|
1257
|
+
const P = u[o === "x" ? "scrollWidth" : "scrollHeight"] - u.getBoundingClientRect()[o === "x" ? "width" : "height"], U = y.offsetLeft + y.offsetWidth / 2 - u.clientWidth / 2, K = Ft(y);
|
|
1258
1258
|
if (K.isOut) {
|
|
1259
|
-
const H = K.direction === "start" ? U < 0 ? 0 : U : U >
|
|
1259
|
+
const H = K.direction === "start" ? U < 0 ? 0 : U : U > P ? P : U, Z = u[o === "x" ? "scrollLeft" : "scrollTop"];
|
|
1260
1260
|
new Je({
|
|
1261
1261
|
from: {
|
|
1262
1262
|
value: Z
|
|
@@ -1269,39 +1269,43 @@ function Xt({
|
|
|
1269
1269
|
}) : H
|
|
1270
1270
|
},
|
|
1271
1271
|
onChange({ value: ie }) {
|
|
1272
|
-
u[
|
|
1272
|
+
u[o === "x" ? "scrollLeft" : "scrollTop"] = ie.value;
|
|
1273
1273
|
}
|
|
1274
1274
|
});
|
|
1275
1275
|
}
|
|
1276
1276
|
}
|
|
1277
1277
|
}
|
|
1278
1278
|
const He = Kt(
|
|
1279
|
-
(
|
|
1279
|
+
(s) => {
|
|
1280
1280
|
if (!O.current) {
|
|
1281
1281
|
Q();
|
|
1282
1282
|
return;
|
|
1283
1283
|
}
|
|
1284
|
-
const f =
|
|
1284
|
+
const f = s.dragging, v = s.offset[o === "x" ? 0 : 1], u = s.movement[o === "x" ? 0 : 1], y = u > J.current, P = u < -J.current, A = s.velocity;
|
|
1285
1285
|
f && (W({
|
|
1286
|
-
...
|
|
1286
|
+
...s,
|
|
1287
1287
|
eventName: "onDrag",
|
|
1288
1288
|
slideActionType: "drag"
|
|
1289
1289
|
}), re.start({
|
|
1290
1290
|
value: v,
|
|
1291
1291
|
immediate: !0,
|
|
1292
1292
|
config: {
|
|
1293
|
-
velocity:
|
|
1293
|
+
velocity: A
|
|
1294
1294
|
}
|
|
1295
|
-
}), d && (
|
|
1295
|
+
}), d && (y || P) && (console.log("cancel", {
|
|
1296
|
+
slideWhenDragThresholdIsReached: d,
|
|
1297
|
+
prevItemTresholdReached: y,
|
|
1298
|
+
nextItemTresholdReached: P
|
|
1299
|
+
}), s.cancel())), s.last && (console.log("last"), y ? le("drag") : P ? ue("drag") : re.start({
|
|
1296
1300
|
value: be.current,
|
|
1297
1301
|
config: {
|
|
1298
|
-
velocity:
|
|
1302
|
+
velocity: A
|
|
1299
1303
|
}
|
|
1300
1304
|
}));
|
|
1301
1305
|
},
|
|
1302
1306
|
{
|
|
1303
1307
|
enabled: c && t !== "freeScroll",
|
|
1304
|
-
axis:
|
|
1308
|
+
axis: o,
|
|
1305
1309
|
rubberband: !i,
|
|
1306
1310
|
...i ? {} : {
|
|
1307
1311
|
bounds: () => ({
|
|
@@ -1315,16 +1319,16 @@ function Xt({
|
|
|
1315
1319
|
}
|
|
1316
1320
|
);
|
|
1317
1321
|
return Ae(() => {
|
|
1318
|
-
function
|
|
1322
|
+
function s() {
|
|
1319
1323
|
document.hidden ? (F.current = !0, O.current = !1) : (F.current = !1, O.current = !0);
|
|
1320
1324
|
}
|
|
1321
1325
|
function f() {
|
|
1322
1326
|
if (!(t === "fixed" && !i || t === "freeScroll"))
|
|
1323
|
-
if (t === "fixed" && E === "group" &&
|
|
1324
|
-
const
|
|
1325
|
-
S.current.style[
|
|
1327
|
+
if (t === "fixed" && E === "group" && x > 1) {
|
|
1328
|
+
const P = e.length * 3 / x;
|
|
1329
|
+
S.current.style[o === "x" ? "left" : "top"] = `-${Y(g() * P / 3)}px`;
|
|
1326
1330
|
} else
|
|
1327
|
-
S.current.style[
|
|
1331
|
+
S.current.style[o === "x" ? "left" : "top"] = `-${Y(g() * L.length / 3)}px`;
|
|
1328
1332
|
}
|
|
1329
1333
|
function v() {
|
|
1330
1334
|
u(), f(), re.start({
|
|
@@ -1333,23 +1337,23 @@ function Xt({
|
|
|
1333
1337
|
});
|
|
1334
1338
|
}
|
|
1335
1339
|
function u() {
|
|
1336
|
-
const
|
|
1337
|
-
let
|
|
1338
|
-
const U = t === "fixed" && E === "group" &&
|
|
1339
|
-
U ?
|
|
1340
|
-
S.current.getBoundingClientRect()[
|
|
1341
|
-
) :
|
|
1342
|
-
|
|
1340
|
+
const P = S.current.children[0];
|
|
1341
|
+
let A = 0;
|
|
1342
|
+
const U = t === "fixed" && E === "group" && x > 1;
|
|
1343
|
+
U ? A = Y(
|
|
1344
|
+
S.current.getBoundingClientRect()[o === "x" ? "width" : "height"]
|
|
1345
|
+
) : A = Y(
|
|
1346
|
+
P.getBoundingClientRect()[o === "x" ? "width" : "height"]
|
|
1343
1347
|
);
|
|
1344
1348
|
let { totalGutterCssVar: K, totalStartEndGutterCssVar: H } = Ge();
|
|
1345
|
-
return
|
|
1349
|
+
return A += K, U && (A -= H), q.current = A, A;
|
|
1346
1350
|
}
|
|
1347
|
-
function
|
|
1351
|
+
function y() {
|
|
1348
1352
|
if ($.current = [], L.length === 0 && ge(
|
|
1349
1353
|
"Init is true but no items are available; carousel will not be initialized"
|
|
1350
|
-
), t === "fixed" && E === "group" &&
|
|
1354
|
+
), t === "fixed" && E === "group" && x === 1 && ge(
|
|
1351
1355
|
"Using scrollAmountType='group' and itemsPerSlide={1} makes no difference; itemsPerSlide must be greater than 1."
|
|
1352
|
-
), t === "fixed" && E === "group" && e.length %
|
|
1356
|
+
), t === "fixed" && E === "group" && e.length % x !== 0 && $.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" && I !== void 0 && $.current.push(
|
|
1353
1357
|
'scrollAmountType="group" is not available for slideType="fluid"; please change one of them.'
|
|
1354
1358
|
), t === "fluid" && m !== void 0 && $.current.push(
|
|
1355
1359
|
`itemsPerSlide=${m} is not available for slideType="fluid"; please change one of them.`
|
|
@@ -1360,14 +1364,14 @@ function Xt({
|
|
|
1360
1364
|
u(), i && f(), J.current = g() / 4, O.current = !0;
|
|
1361
1365
|
}
|
|
1362
1366
|
if (r)
|
|
1363
|
-
return
|
|
1367
|
+
return y(), window.addEventListener("resize", v), document.addEventListener("visibilitychange", s), () => {
|
|
1364
1368
|
document.removeEventListener(
|
|
1365
1369
|
"visibilitychange",
|
|
1366
|
-
|
|
1370
|
+
s
|
|
1367
1371
|
), window.removeEventListener("resize", v);
|
|
1368
1372
|
};
|
|
1369
1373
|
O.current = !1;
|
|
1370
|
-
}, [q, r, t, i,
|
|
1374
|
+
}, [q, r, t, i, o]), {
|
|
1371
1375
|
carouselFragment: /* @__PURE__ */ ze(Ye, { children: [
|
|
1372
1376
|
/* @__PURE__ */ se(
|
|
1373
1377
|
"style",
|
|
@@ -1377,7 +1381,7 @@ function Xt({
|
|
|
1377
1381
|
__html: `
|
|
1378
1382
|
:root {
|
|
1379
1383
|
--${b}-react-spring-carousel-item-gutter: ${l}px;
|
|
1380
|
-
--${b}-react-spring-carousel-start-end-gutter: ${
|
|
1384
|
+
--${b}-react-spring-carousel-start-end-gutter: ${N}px;
|
|
1381
1385
|
}
|
|
1382
1386
|
.carousel-${b} {
|
|
1383
1387
|
display: flex;
|
|
@@ -1390,10 +1394,10 @@ function Xt({
|
|
|
1390
1394
|
display: flex;
|
|
1391
1395
|
width: calc(100% - var(--${b}-react-spring-carousel-start-end-gutter) * 2);
|
|
1392
1396
|
padding-left: var(--${b}-react-spring-carousel-start-end-gutter);
|
|
1393
|
-
touch-action: ${c ?
|
|
1394
|
-
flex-direction: ${
|
|
1395
|
-
overflow-x: ${t === "freeScroll" &&
|
|
1396
|
-
overflow-y: ${t === "freeScroll" &&
|
|
1397
|
+
touch-action: ${c ? o === "x" ? "pan-y" : "pan-x" : "auto"};
|
|
1398
|
+
flex-direction: ${o === "x" ? "row" : "column"};
|
|
1399
|
+
overflow-x: ${t === "freeScroll" && o === "x" ? "auto" : "initial"};
|
|
1400
|
+
overflow-y: ${t === "freeScroll" && o === "y" ? "auto" : "initial"};
|
|
1397
1401
|
}
|
|
1398
1402
|
.carousel-${b} .use-spring-carousel-track::after {
|
|
1399
1403
|
content: "";
|
|
@@ -1413,7 +1417,7 @@ function Xt({
|
|
|
1413
1417
|
.carousel-${b}[data-carousel-direction=y] .use-spring-carousel-item:not(:last-child) {
|
|
1414
1418
|
margin-bottom: var(--${b}-react-spring-carousel-item-gutter);
|
|
1415
1419
|
}
|
|
1416
|
-
${
|
|
1420
|
+
${k ? `.carousel-${b} .use-spring-carousel-item {
|
|
1417
1421
|
position: absolute;
|
|
1418
1422
|
top: 0;
|
|
1419
1423
|
left: 0;
|
|
@@ -1433,7 +1437,7 @@ function Xt({
|
|
|
1433
1437
|
{
|
|
1434
1438
|
className: `use-spring-carousel-container carousel-${b}`,
|
|
1435
1439
|
ref: V,
|
|
1436
|
-
"data-carousel-direction":
|
|
1440
|
+
"data-carousel-direction": o,
|
|
1437
1441
|
children: /* @__PURE__ */ se(
|
|
1438
1442
|
"div",
|
|
1439
1443
|
{
|
|
@@ -1441,14 +1445,14 @@ function Xt({
|
|
|
1441
1445
|
...He(),
|
|
1442
1446
|
ref: S,
|
|
1443
1447
|
...je(),
|
|
1444
|
-
children: L.map((
|
|
1448
|
+
children: L.map((s, f) => /* @__PURE__ */ se(
|
|
1445
1449
|
"div",
|
|
1446
1450
|
{
|
|
1447
1451
|
className: "use-spring-carousel-item",
|
|
1448
|
-
id:
|
|
1449
|
-
children:
|
|
1452
|
+
id: s.id,
|
|
1453
|
+
children: s.renderItem
|
|
1450
1454
|
},
|
|
1451
|
-
`${
|
|
1455
|
+
`${s.id}-${f}`
|
|
1452
1456
|
))
|
|
1453
1457
|
}
|
|
1454
1458
|
)
|
|
@@ -1458,12 +1462,12 @@ function Xt({
|
|
|
1458
1462
|
useListenToCustomEvent: Ue,
|
|
1459
1463
|
slideToNextItem: () => ue("click"),
|
|
1460
1464
|
slideToPrevItem: () => le("click"),
|
|
1461
|
-
slideToIem: (
|
|
1465
|
+
slideToIem: (s) => {
|
|
1462
1466
|
if (!O.current) {
|
|
1463
1467
|
Q();
|
|
1464
1468
|
return;
|
|
1465
1469
|
}
|
|
1466
|
-
Fe(
|
|
1470
|
+
Fe(s);
|
|
1467
1471
|
},
|
|
1468
1472
|
handleThumbsContainerScroll: We,
|
|
1469
1473
|
carouselId: b
|
package/dist/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(G,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react/jsx-runtime"),require("react"),require("@react-spring/web")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@react-spring/web"],R):(G=typeof globalThis<"u"?globalThis:G||self,R(G["react-spring-carousel"]={},G["react/jsx-runtime"],G.React,G["@react-spring/web"]))})(this,function(G,R,E,be){"use strict";const le="RSC::Event";function Be(){const r=E.useRef(null);function e(n){E.useEffect(()=>{r.current||(r.current=document.createElement("div"));function i(c){n(c.detail)}if(r.current)return r.current.addEventListener(le,i,!1),()=>{var c;(c=r.current)==null||c.removeEventListener(le,i,!1)}},[n])}function t(n){if(r.current){const i=new CustomEvent(le,{detail:n});r.current.dispatchEvent(i)}}return{useListenToCustomEvent:e,emitEvent:t}}function Ue(r,e,t){return Math.max(e,Math.min(r,t))}const S={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function ye(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function _e(r,e,t,n=.15){return n===0?Ue(r,e,t):r<e?-ye(e-r,t-e,n)+e:r>t?+ye(r-t,t-e,n)+t:r}function Ge(r,[e,t],[n,i]){const[[c,s],[d,m]]=r;return[_e(e,c,s,n),_e(t,d,m,i)]}function Ke(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Fe(r){var e=Ke(r,"string");return typeof e=="symbol"?e:String(e)}function C(r,e,t){return e=Fe(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function we(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function b(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?we(Object(t),!0).forEach(function(n){C(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):we(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const xe={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function Ie(r){return r?r[0].toUpperCase()+r.slice(1):""}const We=["enter","leave"];function He(r=!1,e){return r&&!We.includes(e)}function ze(r,e="",t=!1){const n=xe[r],i=n&&n[e]||e;return"on"+Ie(r)+Ie(i)+(He(t,i)?"Capture":"")}const Ye=["gotpointercapture","lostpointercapture"];function Xe(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ye.includes(e)?"capturecapture":"capture",i=!!~e.indexOf(n);return i&&(e=e.replace("capture","")),{device:e,capture:i,passive:t}}function qe(r,e=""){const t=xe[r],n=t&&t[e]||e;return r+n}function ie(r){return"touches"in r}function Ee(r){return ie(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Je(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Qe(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function Se(r){return ie(r)?Qe(r)[0]:r}function Ze(r){return Je(r).map(e=>e.identifier)}function fe(r){const e=Se(r);return ie(r)?e.identifier:e.pointerId}function Te(r){const e=Se(r);return[e.clientX,e.clientY]}function et(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:c}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:c})}return e}function se(r,...e){return typeof r=="function"?r(...e):r}function tt(){}function rt(...r){return r.length===0?tt:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function De(r,e){return Object.assign({},e,r||{})}const nt=32;class it{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:i}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?se(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:i}=this;t.args=this.args;let c=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,et(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,c=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const j=t._delta.map(Math.abs);S.addTo(t._distance,j)}this.axisIntent&&this.axisIntent(e);const[s,d]=t._movement,[m,I]=n.threshold,{_step:l,values:M}=t;if(n.hasCustomTransform?(l[0]===!1&&(l[0]=Math.abs(s)>=m&&M[0]),l[1]===!1&&(l[1]=Math.abs(d)>=I&&M[1])):(l[0]===!1&&(l[0]=Math.abs(s)>=m&&Math.sign(s)*m),l[1]===!1&&(l[1]=Math.abs(d)>=I&&Math.sign(d)*I)),t.intentional=l[0]!==!1||l[1]!==!1,!t.intentional)return;const k=[0,0];if(n.hasCustomTransform){const[j,D]=M;k[0]=l[0]!==!1?j-l[0]:0,k[1]=l[1]!==!1?D-l[1]:0}else k[0]=l[0]!==!1?s-l[0]:0,k[1]=l[1]!==!1?d-l[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(k);const P=t.offset,L=t._active&&!t._blocked||t.active;L&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=se(n.bounds,t)),this.setup&&this.setup()),t.movement=k,this.computeOffset()));const[z,w]=t.offset,[[T,V],[ee,te]]=t._bounds;t.overflow=[z<T?-1:z>V?1:0,w<ee?-1:w>te?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const y=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=Ge(t._bounds,t.offset,y),t.delta=S.sub(t.offset,P),this.computeMovement(),L&&(!t.last||c>nt)){t.delta=S.sub(t.offset,P);const j=t.delta.map(Math.abs);S.addTo(t.distance,j),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&c>0&&(t.velocity=[j[0]/c,j[1]/c],t.timeDelta=c)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const i=this.handler(b(b(b({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function st([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class ot extends it{constructor(...e){super(...e),C(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=S.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=S.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[Ee(e)]:n.axisThreshold;t.axis=st(t._movement,i)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const ke=r=>r,Ce=.15,de={enabled(r=!0){return r},eventOptions(r,e,t){return b(b({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[Ce,Ce];case!1:return[0,0];default:return S.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return S.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const i=n||ke;return c=>{const s=i(c);return(!isFinite(s[0])||!isFinite(s[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${s[0]},${[1]}]`),s}}return n||ke},threshold(r){return S.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(de,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const ct=0,Q=b(b({},de),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=ct){return r},bounds(r={}){if(typeof r=="function")return c=>Q.bounds(r(c));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:i=1/0}=r;return[[e,t],[n,i]]}}),Oe={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class at extends ot{constructor(...e){super(...e),C(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),i={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=Q.bounds(i)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const i=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=fe(e),n._pointerActive=!0,this.computeValues(Te(e)),this.computeInitial(),t.preventScrollAxis&&Ee(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const i=fe(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;const c=Te(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=S.sub(c,t._values),this.computeValues(c)),S.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{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.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const i=fe(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[c,s]=t._distance;if(t.tap=c<=n.tapsThreshold&&s<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[d,m]=t._delta,[I,l]=t._movement,[M,k]=n.swipe.velocity,[P,L]=n.swipe.distance,z=n.swipe.duration;if(t.elapsedTime<z){const w=Math.abs(d/t.timeDelta),T=Math.abs(m/t.timeDelta);w>M&&Math.abs(I)>P&&(t.swipe[0]=Math.sign(d)),T>k&&Math.abs(l)>L&&(t.swipe[1]=Math.sign(m))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const i="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(i).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.",i)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.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)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,ut(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=Oe[e.key];if(t){const n=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,i),n._keyboardActive=!0,S.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in Oe&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function ut(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const Z=typeof window<"u"&&window.document&&window.document.createElement;function Pe(){return Z&&"ontouchstart"in window}function lt(){return Pe()||Z&&window.navigator.maxTouchPoints>1}function ft(){return Z&&"onpointerdown"in window}function dt(){return Z&&"exitPointerLock"in window.document}function ht(){try{return"constructor"in GestureEvent}catch{return!1}}const N={isBrowser:Z,gesture:ht(),touch:Pe(),touchscreen:lt(),pointer:ft(),pointerLock:dt()},pt=250,gt=180,mt=.5,vt=50,bt=250,yt=10,Ae={mouse:0,touch:0,pen:8},Ne=b(b({},Q),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&N.pointerLock,N.touch&&t?"touch":this.pointerLock?"mouse":N.pointer&&!i?"pointer":N.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?pt:void 0,!(!N.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const c=S.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,c},swipe({velocity:r=mt,distance:e=vt,duration:t=bt}={}){return{velocity:this.transform(S.toVector(r)),distance:this.transform(S.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return gt;case!1:return 0;default:return r}},axisThreshold(r){return r?b(b({},Ae),r):Ae},keyboardDisplacement(r=yt){return r}});process.env.NODE_ENV==="development"&&Object.assign(Ne,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),b(b({},de),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!N.touch&&N.gesture)return"gesture";if(N.touch&&n)return"touch";if(N.touchscreen){if(N.pointer)return"pointer";if(N.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=s=>{const d=De(se(t,s),{min:-1/0,max:1/0});return[d.min,d.max]},c=s=>{const d=De(se(n,s),{min:-1/0,max:1/0});return[d.min,d.max]};return typeof t!="function"&&typeof n!="function"?[i(),c()]:s=>[i(s),c(s)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",S.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),b(b({},Q),{},{mouseOnly:(r=!0)=>r}),b(b({},Q),{},{mouseOnly:(r=!0)=>r});const Me=new Map,he=new Map;function _t(r){Me.set(r.key,r.engine),he.set(r.key,r.resolver)}const wt={key:"drag",engine:at,resolver:Ne};function xt(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,c;for(c=0;c<n.length;c++)i=n[c],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function It(r,e){if(r==null)return{};var t=xt(r,e),n,i;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(i=0;i<c.length;i++)n=c[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const Et={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=N.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},St=["target","eventOptions","window","enabled","transform"];function oe(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":if(process.env.NODE_ENV==="development"){const c=i.call(t,r[n],n,r);Number.isNaN(c)||(t[n]=c)}else t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=oe(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function Tt(r,e,t={}){const n=r,{target:i,eventOptions:c,window:s,enabled:d,transform:m}=n,I=It(n,St);if(t.shared=oe({target:i,eventOptions:c,window:s,enabled:d,transform:m},Et),e){const l=he.get(e);t[e]=oe(b({shared:t.shared},I),l)}else for(const l in I){const M=he.get(l);if(M)t[l]=oe(b({shared:t.shared},I[l]),M);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(l)){if(l==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${l}\` was used. Please read the documentation for further information.`)}}return t}class $e{constructor(e,t){C(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,c){const s=this._listeners,d=qe(t,n),m=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},I=b(b({},m),c);e.addEventListener(d,i,I);const l=()=>{e.removeEventListener(d,i,I),s.delete(l)};return s.add(l),l}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Dt{constructor(){C(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class kt{constructor(e){C(this,"gestures",new Set),C(this,"_targetEventStore",new $e(this)),C(this,"gestureEventStores",{}),C(this,"gestureTimeoutStores",{}),C(this,"handlers",{}),C(this,"config",{}),C(this,"pointerIds",new Set),C(this,"touchIds",new Set),C(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Ct(this,e)}setEventIds(e){if(ie(e))return this.touchIds=new Set(Ze(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=Tt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const s of this.gestures){const d=this.config[s],m=Le(n,d.eventOptions,!!i);if(d.enabled){const I=Me.get(s);new I(this,e,s).bind(m)}}const c=Le(n,t.eventOptions,!!i);for(const s in this.nativeHandlers)c(s,"",d=>this.nativeHandlers[s](b(b({},this.state.shared),{},{event:d,args:e})),void 0,!0)}for(const c in n)n[c]=rt(...n[c]);if(!i)return n;for(const c in n){const{device:s,capture:d,passive:m}=Xe(c);this._targetEventStore.add(i,s,"",n[c],{capture:d,passive:m})}}}}function J(r,e){r.gestures.add(e),r.gestureEventStores[e]=new $e(r,e),r.gestureTimeoutStores[e]=new Dt}function Ct(r,e){e.drag&&J(r,"drag"),e.wheel&&J(r,"wheel"),e.scroll&&J(r,"scroll"),e.move&&J(r,"move"),e.pinch&&J(r,"pinch"),e.hover&&J(r,"hover")}const Le=(r,e,t)=>(n,i,c,s={},d=!1)=>{var m,I;const l=(m=s.capture)!==null&&m!==void 0?m:e.capture,M=(I=s.passive)!==null&&I!==void 0?I:e.passive;let k=d?n:ze(n,i,l);t&&M&&(k+="Passive"),r[k]=r[k]||[],r[k].push(c)};function Ot(r,e={},t,n){const i=E.useMemo(()=>new kt(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),E.useEffect(i.effect.bind(i)),E.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function Pt(r,e){return _t(wt),Ot({drag:r},e||{},"drag")}function At(r){const{left:e,right:t,top:n,bottom:i}=r.getBoundingClientRect(),{innerWidth:c,innerHeight:s}=window;return e<0||n<0?{isOut:!0,direction:"start"}:Math.floor(t)>Math.floor(c)||Math.floor(i)>Math.floor(s)?{isOut:!0,direction:"end"}:{isOut:!1,direction:null}}function H(r){return parseFloat(r.toFixed(2))}function pe(r){process.env.NODE_ENV!=="production"&&console.warn(r)}function Nt({init:r=!0,items:e,slideType:t="fixed",scrollAmount:n,withLoop:i=!1,enableGestures:c=!0,carouselAxis:s="x",slideWhenDragThresholdIsReached:d=!0,itemsPerSlide:m,scrollAmountType:I,gutter:l=0,startEndGutter:M=0,fadeIn:k=!1}){const P=E.useRef(!1),L=E.useRef([]),z=E.useRef(!1),w=m??1,T=I??"slide",V=i?[...e.map(o=>({...o,id:`prev-repeated-item-${o.id}`})),...e,...e.map(o=>({...o,id:`next-repeated-item-${o.id}`}))]:e,ee=E.useRef(n),te=E.useRef(0),y=E.useId().replace(/:/g,""),j=E.useRef(null),D=E.useRef(null),Re=E.useRef(0),p=E.useRef(!0),h=E.useRef(!1),a=E.useRef(0),[B,ce]=be.useSpring(()=>({value:0,onChange({value:o}){(t==="fixed"||t==="fluid")&&(s==="x"?D.current.style.transform=`translate3d(${o.value}px, 0px, 0px)`:D.current.style.transform=`translate3d(${o.value}px, 0px, 0px)`),t==="freeScroll"&&(D.current[s==="x"?"scrollLeft":"scrollTop"]=Math.abs(o.value))}})),{useListenToCustomEvent:Mt,emitEvent:Y}=Be();function g(){return H(ee.current??0)}function F(){return D.current[s==="x"?"scrollWidth":"scrollHeight"]-j.current.getBoundingClientRect()[s==="x"?"width":"height"]}function re(){pe("The carousel can't be initialized. List of errors:"),console.table(L.current)}function $t(){return t==="freeScroll"?{onWheel(){B.value.stop()},onScroll(o){const f=o.currentTarget,v=s==="x"?f.scrollLeft:f.scrollTop,u=s==="x"?f.scrollWidth-f.clientWidth:f.scrollHeight-f.clientHeight;v===0?p.current=!0:v===u?h.current=!0:(p.current=!1,h.current=!1)}}:{}}function Lt(){let o=0,f=0;const v=getComputedStyle(document.documentElement).getPropertyValue(`--${y}-react-spring-carousel-item-gutter`),u=getComputedStyle(document.documentElement).getPropertyValue(`--${y}-react-spring-carousel-item-gutter`);return u.includes("px")&&(o=Number(u.replace("px",""))),v.includes("px")&&(f=Number(v.replace("px",""))),{totalGutterCssVar:o,totalStartEndGutterCssVar:f}}function Rt(){return w>1?`calc(100% / ${w} - var(--${y}-react-spring-carousel-item-gutter) / ${w} * ${w-1}) !important`:"100% !important"}function ae({type:o,actionType:f,newActiveItem:v}){var U,W,X,ne,ue,Ve,je;let u=0,x=B.value.get();if(p.current=!1,h.current=!1,t==="fixed"){const O=a.current;if(o==="prev"&&(a.current=v??a.current-1),o==="next"&&(a.current=v??a.current+1),i&&T==="group"&&w>1&&o==="next"){const _=e.length/w,K=Math.ceil(_)-1===a.current,q=Math.ceil(_)===a.current;K&&(h.current=!0),u=-(a.current*g()),q&&(a.current=0,x=B.value.get()+g()*_,u=0,h.current=!1,p.current=!0)}if(i&&T==="group"&&w>1&&o==="prev"){const _=e.length/w,K=a.current===0,q=a.current===-1;u=-(a.current*g()),K&&(p.current=!0),q&&(p.current=!1,h.current=!0,a.current=_-1,x=B.value.get()-g()*_,u=-g()*_+g())}if(!i&&T==="group"&&w>1){const _=e.length/w,K=2%_!==0,q=Math.ceil(_-1)===a.current,ve=a.current===0;u=-(a.current*g()),ve&&(p.current=!0),q&&(h.current=!0,K&&(u=-F()))}if(i&&o==="next"&&(T==="slide"||T==="group"&&w===1)){const _=((U=e[a.current])==null?void 0:U.id)===e[e.length-1].id,K=V[e.length+a.current].id.includes("repeated-item");_&&(h.current=!0),K&&(a.current=0,x=B.value.get()+g()*e.length,h.current=!1,p.current=!0),u=-(a.current*g())}if(i&&o==="prev"&&(T==="slide"||T==="group"&&w===1)){const _=V.findIndex(ve=>ve.id===e[O].id),K=((W=e[a.current])==null?void 0:W.id)===e[0].id,q=V[_-1].id.includes("repeated-item");K&&(p.current=!0),q&&(p.current=!1,h.current=!0,a.current=e.length-1,x=B.value.get()-g()*e.length),u=-(a.current*g())}!i&&T==="slide"&&(((X=e[a.current+1])==null?void 0:X.id)===e[e.length-1].id?h.current=!0:a.current===0?p.current=!0:(p.current=!1,h.current=!1),u=-(a.current*g()),o==="next"&&Math.abs(u)>F()&&(h.current=!0,u=-F())),Y({eventName:"onSlideStartChange",sliceActionType:f,slideDirection:o,nextItem:{index:a.current,id:e[a.current].id,startReached:p.current,endReached:h.current}})}if(t==="fluid"){if(o==="prev"&&(a.current=v??a.current-1),o==="next"&&(a.current=v??a.current+1),u=-(a.current*g()),o==="next"&&i){const O=((ne=e[a.current])==null?void 0:ne.id)===e[e.length-1].id,_=V[e.length+a.current].id.includes("repeated-item");O&&(h.current=!0),_&&(a.current=0,x=B.value.get()+g()*e.length,u=0,h.current=!1,p.current=!0)}if(o==="next"&&!i){const O=Math.abs(u)>F();O||O?(h.current=!0,u=-F()):(p.current=!1,h.current=!1)}if(o==="prev"&&!i&&((ue=e[a.current])==null?void 0:ue.id)===e[0].id&&(p.current=!0),o==="prev"&&i){const O=((Ve=e[a.current])==null?void 0:Ve.id)===e[0].id,_=(je=V[e.length+a.current])==null?void 0:je.id.includes("repeated-item");O&&(p.current=!0),_&&(a.current=e.length-1,x=B.value.get()-g()*e.length,u=-(g()*e.length-g()),p.current=!1,h.current=!0)}Y({eventName:"onSlideStartChange",sliceActionType:f,slideDirection:o,nextItem:{startReached:p.current,endReached:h.current,index:0,id:""}})}if(t==="freeScroll"){const O=D.current[s==="x"?"scrollLeft":"scrollTop"],_=s==="x"?D.current.scrollWidth-D.current.clientWidth:D.current.scrollHeight-D.current.clientHeight;x=O,o==="prev"&&(u=x-g(),u<0&&(u=0),x-g()<=0&&(p.current=!0),Y({eventName:"onSlideStartChange",sliceActionType:f,slideDirection:o,nextItem:{index:0,id:"",startReached:p.current,endReached:!1}})),o==="next"&&(u=x+g(),u>_&&(u=_),x+g()>=_&&(h.current=!0),Y({eventName:"onSlideStartChange",sliceActionType:f,slideDirection:o,nextItem:{index:0,id:"",startReached:!1,endReached:h.current}}))}const $=H(x),A=H(u);Re.current=A,ce.start({from:{value:$},to:{value:A},onRest({finished:O}){O&&t==="fixed"&&Y({eventName:"onSlideChangeComplete",sliceActionType:f,slideDirection:o,currentItem:{index:a.current,id:e[a.current].id,startReached:p.current,endReached:h.current}}),O&&t==="fluid"&&Y({eventName:"onSlideChangeComplete",sliceActionType:f,slideDirection:o,currentItem:{index:0,id:"",startReached:p.current,endReached:h.current}})}})}function ge(o,f){if(!P.current){re();return}if(t==="fixed"&&i||t==="fixed"&&!i&&!h.current){const v=f??a.current+1;ae({type:"next",actionType:o,newActiveItem:v})}(t==="fluid"&&i||t==="fluid"&&!i&&!h.current||t==="freeScroll"&&!h.current)&&ae({type:"next",actionType:o})}function me(o,f){if(!P.current){re();return}if(t==="fixed"&&i||t==="fixed"&&!i&&!p.current){const v=f??a.current-1;ae({type:"prev",actionType:o,newActiveItem:v})}(t==="fluid"&&i||t==="fluid"&&!i&&!p.current||t==="freeScroll"&&!p.current)&&ae({type:"prev",actionType:o})}function Vt(o){let f=0;typeof o=="string"?f=e.findIndex(v=>v.id===o):f=o,f>a.current&&ge("click",f),f<a.current&&me("click",f)}function jt({getContainer:o,activeItem:f,updateTotalValue:v}){const u=o();if(!(u instanceof HTMLElement)){console.warn(`Container is not a valid html element: container is ${u}`);return}const x=u.children[f];if(x){const $=u[s==="x"?"scrollWidth":"scrollHeight"]-u.getBoundingClientRect()[s==="x"?"width":"height"],U=x.offsetLeft+x.offsetWidth/2-u.clientWidth/2,W=At(x);if(W.isOut){const X=W.direction==="start"?U<0?0:U:U>$?$:U,ne=u[s==="x"?"scrollLeft":"scrollTop"];new be.Controller({from:{value:ne},to:{value:v?v({from:ne,to:X,itemOutOfViewport:W}):X},onChange({value:ue}){u[s==="x"?"scrollLeft":"scrollTop"]=ue.value}})}}}const Bt=Pt(o=>{if(!P.current){re();return}const f=o.dragging,v=o.offset[s==="x"?0:1],u=o.movement[s==="x"?0:1],x=u>te.current,$=u<-te.current,A=o.velocity;f&&(Y({...o,eventName:"onDrag",slideActionType:"drag"}),ce.start({value:v,immediate:!0,config:{velocity:A}}),d&&(x||$)&&o.cancel()),o.last&&(x?me("drag"):$?ge("drag"):ce.start({value:Re.current,config:{velocity:A}}))},{enabled:c&&t!=="freeScroll",axis:s,rubberband:!i,...i?{}:{bounds:()=>({right:0,left:-F(),top:-F(),bottom:0})},from:()=>[B.value.get(),B.value.get()]});return E.useEffect(()=>{function o(){document.hidden?(z.current=!0,P.current=!1):(z.current=!1,P.current=!0)}function f(){if(!(t==="fixed"&&!i||t==="freeScroll"))if(t==="fixed"&&T==="group"&&w>1){const $=e.length*3/w;D.current.style[s==="x"?"left":"top"]=`-${H(g()*$/3)}px`}else D.current.style[s==="x"?"left":"top"]=`-${H(g()*V.length/3)}px`}function v(){u(),f(),ce.start({immediate:!0,value:-(a.current*g())})}function u(){const $=D.current.children[0];let A=0;const U=t==="fixed"&&T==="group"&&w>1;U?A=H(D.current.getBoundingClientRect()[s==="x"?"width":"height"]):A=H($.getBoundingClientRect()[s==="x"?"width":"height"]);let{totalGutterCssVar:W,totalStartEndGutterCssVar:X}=Lt();return A+=W,U&&(A-=X),ee.current=A,A}function x(){if(L.current=[],V.length===0&&pe("Init is true but no items are available; carousel will not be initialized"),t==="fixed"&&T==="group"&&w===1&&pe("Using scrollAmountType='group' and itemsPerSlide={1} makes no difference; itemsPerSlide must be greater than 1."),t==="fixed"&&T==="group"&&e.length%w!==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"&&I!==void 0&&L.current.push('scrollAmountType="group" is not available for slideType="fluid"; please change one of them.'),t==="fluid"&&m!==void 0&&L.current.push(`itemsPerSlide=${m} is not available for slideType="fluid"; please change one of them.`),L.current.length>0){re();return}u(),i&&f(),te.current=g()/4,P.current=!0}if(r)return x(),window.addEventListener("resize",v),document.addEventListener("visibilitychange",o),()=>{document.removeEventListener("visibilitychange",o),window.removeEventListener("resize",v)};P.current=!1},[ee,r,t,i,s]),{carouselFragment:R.jsxs(R.Fragment,{children:[R.jsx("style",{id:`carousel-container-${y}`,dangerouslySetInnerHTML:{__html:`
|
|
1
|
+
(function(G,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react/jsx-runtime"),require("react"),require("@react-spring/web")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@react-spring/web"],R):(G=typeof globalThis<"u"?globalThis:G||self,R(G["react-spring-carousel"]={},G["react/jsx-runtime"],G.React,G["@react-spring/web"]))})(this,function(G,R,E,be){"use strict";const le="RSC::Event";function Be(){const r=E.useRef(null);function e(n){E.useEffect(()=>{r.current||(r.current=document.createElement("div"));function i(c){n(c.detail)}if(r.current)return r.current.addEventListener(le,i,!1),()=>{var c;(c=r.current)==null||c.removeEventListener(le,i,!1)}},[n])}function t(n){if(r.current){const i=new CustomEvent(le,{detail:n});r.current.dispatchEvent(i)}}return{useListenToCustomEvent:e,emitEvent:t}}function Ue(r,e,t){return Math.max(e,Math.min(r,t))}const S={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function ye(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function _e(r,e,t,n=.15){return n===0?Ue(r,e,t):r<e?-ye(e-r,t-e,n)+e:r>t?+ye(r-t,t-e,n)+t:r}function Ge(r,[e,t],[n,i]){const[[c,o],[d,m]]=r;return[_e(e,c,o,n),_e(t,d,m,i)]}function Ke(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Fe(r){var e=Ke(r,"string");return typeof e=="symbol"?e:String(e)}function C(r,e,t){return e=Fe(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function we(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function b(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?we(Object(t),!0).forEach(function(n){C(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):we(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const xe={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function Ie(r){return r?r[0].toUpperCase()+r.slice(1):""}const We=["enter","leave"];function He(r=!1,e){return r&&!We.includes(e)}function ze(r,e="",t=!1){const n=xe[r],i=n&&n[e]||e;return"on"+Ie(r)+Ie(i)+(He(t,i)?"Capture":"")}const Ye=["gotpointercapture","lostpointercapture"];function Xe(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ye.includes(e)?"capturecapture":"capture",i=!!~e.indexOf(n);return i&&(e=e.replace("capture","")),{device:e,capture:i,passive:t}}function qe(r,e=""){const t=xe[r],n=t&&t[e]||e;return r+n}function ie(r){return"touches"in r}function Ee(r){return ie(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Je(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Qe(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function Se(r){return ie(r)?Qe(r)[0]:r}function Ze(r){return Je(r).map(e=>e.identifier)}function fe(r){const e=Se(r);return ie(r)?e.identifier:e.pointerId}function Te(r){const e=Se(r);return[e.clientX,e.clientY]}function et(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:c}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:c})}return e}function se(r,...e){return typeof r=="function"?r(...e):r}function tt(){}function rt(...r){return r.length===0?tt:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function De(r,e){return Object.assign({},e,r||{})}const nt=32;class it{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:i}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?se(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:i}=this;t.args=this.args;let c=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,et(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,c=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const j=t._delta.map(Math.abs);S.addTo(t._distance,j)}this.axisIntent&&this.axisIntent(e);const[o,d]=t._movement,[m,I]=n.threshold,{_step:l,values:$}=t;if(n.hasCustomTransform?(l[0]===!1&&(l[0]=Math.abs(o)>=m&&$[0]),l[1]===!1&&(l[1]=Math.abs(d)>=I&&$[1])):(l[0]===!1&&(l[0]=Math.abs(o)>=m&&Math.sign(o)*m),l[1]===!1&&(l[1]=Math.abs(d)>=I&&Math.sign(d)*I)),t.intentional=l[0]!==!1||l[1]!==!1,!t.intentional)return;const k=[0,0];if(n.hasCustomTransform){const[j,D]=$;k[0]=l[0]!==!1?j-l[0]:0,k[1]=l[1]!==!1?D-l[1]:0}else k[0]=l[0]!==!1?o-l[0]:0,k[1]=l[1]!==!1?d-l[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(k);const P=t.offset,L=t._active&&!t._blocked||t.active;L&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=se(n.bounds,t)),this.setup&&this.setup()),t.movement=k,this.computeOffset()));const[z,x]=t.offset,[[T,V],[ee,te]]=t._bounds;t.overflow=[z<T?-1:z>V?1:0,x<ee?-1:x>te?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const y=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=Ge(t._bounds,t.offset,y),t.delta=S.sub(t.offset,P),this.computeMovement(),L&&(!t.last||c>nt)){t.delta=S.sub(t.offset,P);const j=t.delta.map(Math.abs);S.addTo(t.distance,j),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&c>0&&(t.velocity=[j[0]/c,j[1]/c],t.timeDelta=c)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const i=this.handler(b(b(b({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function st([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class ot extends it{constructor(...e){super(...e),C(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=S.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=S.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[Ee(e)]:n.axisThreshold;t.axis=st(t._movement,i)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const ke=r=>r,Ce=.15,de={enabled(r=!0){return r},eventOptions(r,e,t){return b(b({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[Ce,Ce];case!1:return[0,0];default:return S.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return S.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const i=n||ke;return c=>{const o=i(c);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}}return n||ke},threshold(r){return S.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(de,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const ct=0,Q=b(b({},de),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=ct){return r},bounds(r={}){if(typeof r=="function")return c=>Q.bounds(r(c));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:i=1/0}=r;return[[e,t],[n,i]]}}),Oe={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class at extends ot{constructor(...e){super(...e),C(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),i={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=Q.bounds(i)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const i=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=fe(e),n._pointerActive=!0,this.computeValues(Te(e)),this.computeInitial(),t.preventScrollAxis&&Ee(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const i=fe(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;const c=Te(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=S.sub(c,t._values),this.computeValues(c)),S.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{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.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const i=fe(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[c,o]=t._distance;if(t.tap=c<=n.tapsThreshold&&o<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[d,m]=t._delta,[I,l]=t._movement,[$,k]=n.swipe.velocity,[P,L]=n.swipe.distance,z=n.swipe.duration;if(t.elapsedTime<z){const x=Math.abs(d/t.timeDelta),T=Math.abs(m/t.timeDelta);x>$&&Math.abs(I)>P&&(t.swipe[0]=Math.sign(d)),T>k&&Math.abs(l)>L&&(t.swipe[1]=Math.sign(m))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const i="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(i).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.",i)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.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)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,ut(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=Oe[e.key];if(t){const n=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,i),n._keyboardActive=!0,S.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in Oe&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function ut(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const Z=typeof window<"u"&&window.document&&window.document.createElement;function Pe(){return Z&&"ontouchstart"in window}function lt(){return Pe()||Z&&window.navigator.maxTouchPoints>1}function ft(){return Z&&"onpointerdown"in window}function dt(){return Z&&"exitPointerLock"in window.document}function ht(){try{return"constructor"in GestureEvent}catch{return!1}}const M={isBrowser:Z,gesture:ht(),touch:Pe(),touchscreen:lt(),pointer:ft(),pointerLock:dt()},pt=250,gt=180,mt=.5,vt=50,bt=250,yt=10,Ae={mouse:0,touch:0,pen:8},Ne=b(b({},Q),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&M.pointerLock,M.touch&&t?"touch":this.pointerLock?"mouse":M.pointer&&!i?"pointer":M.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?pt:void 0,!(!M.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const c=S.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,c},swipe({velocity:r=mt,distance:e=vt,duration:t=bt}={}){return{velocity:this.transform(S.toVector(r)),distance:this.transform(S.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return gt;case!1:return 0;default:return r}},axisThreshold(r){return r?b(b({},Ae),r):Ae},keyboardDisplacement(r=yt){return r}});process.env.NODE_ENV==="development"&&Object.assign(Ne,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),b(b({},de),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!M.touch&&M.gesture)return"gesture";if(M.touch&&n)return"touch";if(M.touchscreen){if(M.pointer)return"pointer";if(M.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=o=>{const d=De(se(t,o),{min:-1/0,max:1/0});return[d.min,d.max]},c=o=>{const d=De(se(n,o),{min:-1/0,max:1/0});return[d.min,d.max]};return typeof t!="function"&&typeof n!="function"?[i(),c()]:o=>[i(o),c(o)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",S.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),b(b({},Q),{},{mouseOnly:(r=!0)=>r}),b(b({},Q),{},{mouseOnly:(r=!0)=>r});const Me=new Map,he=new Map;function _t(r){Me.set(r.key,r.engine),he.set(r.key,r.resolver)}const wt={key:"drag",engine:at,resolver:Ne};function xt(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,c;for(c=0;c<n.length;c++)i=n[c],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function It(r,e){if(r==null)return{};var t=xt(r,e),n,i;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(i=0;i<c.length;i++)n=c[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const Et={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=M.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},St=["target","eventOptions","window","enabled","transform"];function oe(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":if(process.env.NODE_ENV==="development"){const c=i.call(t,r[n],n,r);Number.isNaN(c)||(t[n]=c)}else t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=oe(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function Tt(r,e,t={}){const n=r,{target:i,eventOptions:c,window:o,enabled:d,transform:m}=n,I=It(n,St);if(t.shared=oe({target:i,eventOptions:c,window:o,enabled:d,transform:m},Et),e){const l=he.get(e);t[e]=oe(b({shared:t.shared},I),l)}else for(const l in I){const $=he.get(l);if($)t[l]=oe(b({shared:t.shared},I[l]),$);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(l)){if(l==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${l}\` was used. Please read the documentation for further information.`)}}return t}class $e{constructor(e,t){C(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,c){const o=this._listeners,d=qe(t,n),m=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},I=b(b({},m),c);e.addEventListener(d,i,I);const l=()=>{e.removeEventListener(d,i,I),o.delete(l)};return o.add(l),l}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Dt{constructor(){C(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class kt{constructor(e){C(this,"gestures",new Set),C(this,"_targetEventStore",new $e(this)),C(this,"gestureEventStores",{}),C(this,"gestureTimeoutStores",{}),C(this,"handlers",{}),C(this,"config",{}),C(this,"pointerIds",new Set),C(this,"touchIds",new Set),C(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Ct(this,e)}setEventIds(e){if(ie(e))return this.touchIds=new Set(Ze(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=Tt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const o of this.gestures){const d=this.config[o],m=Le(n,d.eventOptions,!!i);if(d.enabled){const I=Me.get(o);new I(this,e,o).bind(m)}}const c=Le(n,t.eventOptions,!!i);for(const o in this.nativeHandlers)c(o,"",d=>this.nativeHandlers[o](b(b({},this.state.shared),{},{event:d,args:e})),void 0,!0)}for(const c in n)n[c]=rt(...n[c]);if(!i)return n;for(const c in n){const{device:o,capture:d,passive:m}=Xe(c);this._targetEventStore.add(i,o,"",n[c],{capture:d,passive:m})}}}}function J(r,e){r.gestures.add(e),r.gestureEventStores[e]=new $e(r,e),r.gestureTimeoutStores[e]=new Dt}function Ct(r,e){e.drag&&J(r,"drag"),e.wheel&&J(r,"wheel"),e.scroll&&J(r,"scroll"),e.move&&J(r,"move"),e.pinch&&J(r,"pinch"),e.hover&&J(r,"hover")}const Le=(r,e,t)=>(n,i,c,o={},d=!1)=>{var m,I;const l=(m=o.capture)!==null&&m!==void 0?m:e.capture,$=(I=o.passive)!==null&&I!==void 0?I:e.passive;let k=d?n:ze(n,i,l);t&&$&&(k+="Passive"),r[k]=r[k]||[],r[k].push(c)};function Ot(r,e={},t,n){const i=E.useMemo(()=>new kt(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),E.useEffect(i.effect.bind(i)),E.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function Pt(r,e){return _t(wt),Ot({drag:r},e||{},"drag")}function At(r){const{left:e,right:t,top:n,bottom:i}=r.getBoundingClientRect(),{innerWidth:c,innerHeight:o}=window;return e<0||n<0?{isOut:!0,direction:"start"}:Math.floor(t)>Math.floor(c)||Math.floor(i)>Math.floor(o)?{isOut:!0,direction:"end"}:{isOut:!1,direction:null}}function H(r){return parseFloat(r.toFixed(2))}function pe(r){process.env.NODE_ENV!=="production"&&console.warn(r)}function Nt({init:r=!0,items:e,slideType:t="fixed",scrollAmount:n,withLoop:i=!1,enableGestures:c=!0,carouselAxis:o="x",slideWhenDragThresholdIsReached:d=!0,itemsPerSlide:m,scrollAmountType:I,gutter:l=0,startEndGutter:$=0,fadeIn:k=!1}){const P=E.useRef(!1),L=E.useRef([]),z=E.useRef(!1),x=m??1,T=I??"slide",V=i?[...e.map(s=>({...s,id:`prev-repeated-item-${s.id}`})),...e,...e.map(s=>({...s,id:`next-repeated-item-${s.id}`}))]:e,ee=E.useRef(n),te=E.useRef(0),y=E.useId().replace(/:/g,""),j=E.useRef(null),D=E.useRef(null),Re=E.useRef(0),p=E.useRef(!0),h=E.useRef(!1),a=E.useRef(0),[B,ce]=be.useSpring(()=>({value:0,onChange({value:s}){(t==="fixed"||t==="fluid")&&(o==="x"?D.current.style.transform=`translate3d(${s.value}px, 0px, 0px)`:D.current.style.transform=`translate3d(${s.value}px, 0px, 0px)`),t==="freeScroll"&&(D.current[o==="x"?"scrollLeft":"scrollTop"]=Math.abs(s.value))}})),{useListenToCustomEvent:Mt,emitEvent:Y}=Be();function g(){return H(ee.current??0)}function F(){return D.current[o==="x"?"scrollWidth":"scrollHeight"]-j.current.getBoundingClientRect()[o==="x"?"width":"height"]}function re(){pe("The carousel can't be initialized. List of errors:"),console.table(L.current)}function $t(){return t==="freeScroll"?{onWheel(){B.value.stop()},onScroll(s){const f=s.currentTarget,v=o==="x"?f.scrollLeft:f.scrollTop,u=o==="x"?f.scrollWidth-f.clientWidth:f.scrollHeight-f.clientHeight;v===0?p.current=!0:v===u?h.current=!0:(p.current=!1,h.current=!1)}}:{}}function Lt(){let s=0,f=0;const v=getComputedStyle(document.documentElement).getPropertyValue(`--${y}-react-spring-carousel-item-gutter`),u=getComputedStyle(document.documentElement).getPropertyValue(`--${y}-react-spring-carousel-item-gutter`);return u.includes("px")&&(s=Number(u.replace("px",""))),v.includes("px")&&(f=Number(v.replace("px",""))),{totalGutterCssVar:s,totalStartEndGutterCssVar:f}}function Rt(){return x>1?`calc(100% / ${x} - var(--${y}-react-spring-carousel-item-gutter) / ${x} * ${x-1}) !important`:"100% !important"}function ae({type:s,actionType:f,newActiveItem:v}){var U,W,X,ne,ue,Ve,je;let u=0,_=B.value.get();if(p.current=!1,h.current=!1,t==="fixed"){const O=a.current;if(s==="prev"&&(a.current=v??a.current-1),s==="next"&&(a.current=v??a.current+1),i&&T==="group"&&x>1&&s==="next"){const w=e.length/x,K=Math.ceil(w)-1===a.current,q=Math.ceil(w)===a.current;K&&(h.current=!0),u=-(a.current*g()),q&&(a.current=0,_=B.value.get()+g()*w,u=0,h.current=!1,p.current=!0)}if(i&&T==="group"&&x>1&&s==="prev"){const w=e.length/x,K=a.current===0,q=a.current===-1;u=-(a.current*g()),K&&(p.current=!0),q&&(p.current=!1,h.current=!0,a.current=w-1,_=B.value.get()-g()*w,u=-g()*w+g())}if(!i&&T==="group"&&x>1){const w=e.length/x,K=2%w!==0,q=Math.ceil(w-1)===a.current,ve=a.current===0;u=-(a.current*g()),ve&&(p.current=!0),q&&(h.current=!0,K&&(u=-F()))}if(i&&s==="next"&&(T==="slide"||T==="group"&&x===1)){const w=((U=e[a.current])==null?void 0:U.id)===e[e.length-1].id,K=V[e.length+a.current].id.includes("repeated-item");w&&(h.current=!0),K&&(a.current=0,_=B.value.get()+g()*e.length,h.current=!1,p.current=!0),u=-(a.current*g())}if(i&&s==="prev"&&(T==="slide"||T==="group"&&x===1)){const w=V.findIndex(ve=>ve.id===e[O].id),K=((W=e[a.current])==null?void 0:W.id)===e[0].id,q=V[w-1].id.includes("repeated-item");K&&(p.current=!0),q&&(p.current=!1,h.current=!0,a.current=e.length-1,_=B.value.get()-g()*e.length),u=-(a.current*g())}!i&&T==="slide"&&(((X=e[a.current+1])==null?void 0:X.id)===e[e.length-1].id?h.current=!0:a.current===0?p.current=!0:(p.current=!1,h.current=!1),u=-(a.current*g()),s==="next"&&Math.abs(u)>F()&&(h.current=!0,u=-F())),Y({eventName:"onSlideStartChange",sliceActionType:f,slideDirection:s,nextItem:{index:a.current,id:e[a.current].id,startReached:p.current,endReached:h.current}})}if(t==="fluid"){if(s==="prev"&&(a.current=v??a.current-1),s==="next"&&(a.current=v??a.current+1),u=-(a.current*g()),s==="next"&&i){const O=((ne=e[a.current])==null?void 0:ne.id)===e[e.length-1].id,w=V[e.length+a.current].id.includes("repeated-item");O&&(h.current=!0),w&&(a.current=0,_=B.value.get()+g()*e.length,u=0,h.current=!1,p.current=!0)}if(s==="next"&&!i){const O=Math.abs(u)>F();O||O?(h.current=!0,u=-F()):(p.current=!1,h.current=!1)}if(s==="prev"&&!i&&((ue=e[a.current])==null?void 0:ue.id)===e[0].id&&(p.current=!0),s==="prev"&&i){const O=((Ve=e[a.current])==null?void 0:Ve.id)===e[0].id,w=(je=V[e.length+a.current])==null?void 0:je.id.includes("repeated-item");O&&(p.current=!0),w&&(a.current=e.length-1,_=B.value.get()-g()*e.length,u=-(g()*e.length-g()),p.current=!1,h.current=!0)}Y({eventName:"onSlideStartChange",sliceActionType:f,slideDirection:s,nextItem:{startReached:p.current,endReached:h.current,index:0,id:""}})}if(t==="freeScroll"){const O=D.current[o==="x"?"scrollLeft":"scrollTop"],w=o==="x"?D.current.scrollWidth-D.current.clientWidth:D.current.scrollHeight-D.current.clientHeight;_=O,s==="prev"&&(u=_-g(),u<0&&(u=0),_-g()<=0&&(p.current=!0),Y({eventName:"onSlideStartChange",sliceActionType:f,slideDirection:s,nextItem:{index:0,id:"",startReached:p.current,endReached:!1}})),s==="next"&&(u=_+g(),u>w&&(u=w),_+g()>=w&&(h.current=!0),Y({eventName:"onSlideStartChange",sliceActionType:f,slideDirection:s,nextItem:{index:0,id:"",startReached:!1,endReached:h.current}}))}const A=H(_),N=H(u);Re.current=N,ce.start({from:{value:A},to:{value:N},onRest({finished:O}){O&&t==="fixed"&&Y({eventName:"onSlideChangeComplete",sliceActionType:f,slideDirection:s,currentItem:{index:a.current,id:e[a.current].id,startReached:p.current,endReached:h.current}}),O&&t==="fluid"&&Y({eventName:"onSlideChangeComplete",sliceActionType:f,slideDirection:s,currentItem:{index:0,id:"",startReached:p.current,endReached:h.current}})}})}function ge(s,f){if(!P.current){re();return}if(s==="drag"||t==="fixed"&&i||t==="fixed"&&!i&&!h.current){const v=f??a.current+1;ae({type:"next",actionType:s,newActiveItem:v})}(t==="fluid"&&i||t==="fluid"&&!i&&!h.current||t==="freeScroll"&&!h.current)&&ae({type:"next",actionType:s})}function me(s,f){if(!P.current){re();return}if(s==="drag"||t==="fixed"&&i||t==="fixed"&&!i&&!p.current){const v=f??a.current-1;ae({type:"prev",actionType:s,newActiveItem:v})}(t==="fluid"&&i||t==="fluid"&&!i&&!p.current||t==="freeScroll"&&!p.current)&&ae({type:"prev",actionType:s})}function Vt(s){let f=0;typeof s=="string"?f=e.findIndex(v=>v.id===s):f=s,f>a.current&&ge("click",f),f<a.current&&me("click",f)}function jt({getContainer:s,activeItem:f,updateTotalValue:v}){const u=s();if(!(u instanceof HTMLElement)){console.warn(`Container is not a valid html element: container is ${u}`);return}const _=u.children[f];if(_){const A=u[o==="x"?"scrollWidth":"scrollHeight"]-u.getBoundingClientRect()[o==="x"?"width":"height"],U=_.offsetLeft+_.offsetWidth/2-u.clientWidth/2,W=At(_);if(W.isOut){const X=W.direction==="start"?U<0?0:U:U>A?A:U,ne=u[o==="x"?"scrollLeft":"scrollTop"];new be.Controller({from:{value:ne},to:{value:v?v({from:ne,to:X,itemOutOfViewport:W}):X},onChange({value:ue}){u[o==="x"?"scrollLeft":"scrollTop"]=ue.value}})}}}const Bt=Pt(s=>{if(!P.current){re();return}const f=s.dragging,v=s.offset[o==="x"?0:1],u=s.movement[o==="x"?0:1],_=u>te.current,A=u<-te.current,N=s.velocity;f&&(Y({...s,eventName:"onDrag",slideActionType:"drag"}),ce.start({value:v,immediate:!0,config:{velocity:N}}),d&&(_||A)&&(console.log("cancel",{slideWhenDragThresholdIsReached:d,prevItemTresholdReached:_,nextItemTresholdReached:A}),s.cancel())),s.last&&(console.log("last"),_?me("drag"):A?ge("drag"):ce.start({value:Re.current,config:{velocity:N}}))},{enabled:c&&t!=="freeScroll",axis:o,rubberband:!i,...i?{}:{bounds:()=>({right:0,left:-F(),top:-F(),bottom:0})},from:()=>[B.value.get(),B.value.get()]});return E.useEffect(()=>{function s(){document.hidden?(z.current=!0,P.current=!1):(z.current=!1,P.current=!0)}function f(){if(!(t==="fixed"&&!i||t==="freeScroll"))if(t==="fixed"&&T==="group"&&x>1){const A=e.length*3/x;D.current.style[o==="x"?"left":"top"]=`-${H(g()*A/3)}px`}else D.current.style[o==="x"?"left":"top"]=`-${H(g()*V.length/3)}px`}function v(){u(),f(),ce.start({immediate:!0,value:-(a.current*g())})}function u(){const A=D.current.children[0];let N=0;const U=t==="fixed"&&T==="group"&&x>1;U?N=H(D.current.getBoundingClientRect()[o==="x"?"width":"height"]):N=H(A.getBoundingClientRect()[o==="x"?"width":"height"]);let{totalGutterCssVar:W,totalStartEndGutterCssVar:X}=Lt();return N+=W,U&&(N-=X),ee.current=N,N}function _(){if(L.current=[],V.length===0&&pe("Init is true but no items are available; carousel will not be initialized"),t==="fixed"&&T==="group"&&x===1&&pe("Using scrollAmountType='group' and itemsPerSlide={1} makes no difference; itemsPerSlide must be greater than 1."),t==="fixed"&&T==="group"&&e.length%x!==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"&&I!==void 0&&L.current.push('scrollAmountType="group" is not available for slideType="fluid"; please change one of them.'),t==="fluid"&&m!==void 0&&L.current.push(`itemsPerSlide=${m} is not available for slideType="fluid"; please change one of them.`),L.current.length>0){re();return}u(),i&&f(),te.current=g()/4,P.current=!0}if(r)return _(),window.addEventListener("resize",v),document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("resize",v)};P.current=!1},[ee,r,t,i,o]),{carouselFragment:R.jsxs(R.Fragment,{children:[R.jsx("style",{id:`carousel-container-${y}`,dangerouslySetInnerHTML:{__html:`
|
|
2
2
|
:root {
|
|
3
3
|
--${y}-react-spring-carousel-item-gutter: ${l}px;
|
|
4
|
-
--${y}-react-spring-carousel-start-end-gutter: ${
|
|
4
|
+
--${y}-react-spring-carousel-start-end-gutter: ${$}px;
|
|
5
5
|
}
|
|
6
6
|
.carousel-${y} {
|
|
7
7
|
display: flex;
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
display: flex;
|
|
15
15
|
width: calc(100% - var(--${y}-react-spring-carousel-start-end-gutter) * 2);
|
|
16
16
|
padding-left: var(--${y}-react-spring-carousel-start-end-gutter);
|
|
17
|
-
touch-action: ${c?
|
|
18
|
-
flex-direction: ${
|
|
19
|
-
overflow-x: ${t==="freeScroll"&&
|
|
20
|
-
overflow-y: ${t==="freeScroll"&&
|
|
17
|
+
touch-action: ${c?o==="x"?"pan-y":"pan-x":"auto"};
|
|
18
|
+
flex-direction: ${o==="x"?"row":"column"};
|
|
19
|
+
overflow-x: ${t==="freeScroll"&&o==="x"?"auto":"initial"};
|
|
20
|
+
overflow-y: ${t==="freeScroll"&&o==="y"?"auto":"initial"};
|
|
21
21
|
}
|
|
22
22
|
.carousel-${y} .use-spring-carousel-track::after {
|
|
23
23
|
content: "";
|
|
@@ -48,4 +48,4 @@
|
|
|
48
48
|
.carousel-${y} .use-spring-carousel-item:first-child {
|
|
49
49
|
opacity: 1;
|
|
50
50
|
}`.trim():""};
|
|
51
|
-
`.trim()}}),R.jsx("div",{className:`use-spring-carousel-container carousel-${y}`,ref:j,"data-carousel-direction":
|
|
51
|
+
`.trim()}}),R.jsx("div",{className:`use-spring-carousel-container carousel-${y}`,ref:j,"data-carousel-direction":o,children:R.jsx("div",{className:"use-spring-carousel-track",...Bt(),ref:D,...$t(),children:V.map((s,f)=>R.jsx("div",{className:"use-spring-carousel-item",id:s.id,children:s.renderItem},`${s.id}-${f}`))})})]}),useListenToCustomEvent:Mt,slideToNextItem:()=>ge("click"),slideToPrevItem:()=>me("click"),slideToIem:s=>{if(!P.current){re();return}Vt(s)},handleThumbsContainerScroll:jt,carouselId:y}}G.useSpringCarousel=Nt,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-spring-carousel",
|
|
3
|
-
"version": "3.0.0-beta-1.0.
|
|
3
|
+
"version": "3.0.0-beta-1.0.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.umd.js",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"react-dom": "^18.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@chromatic-com/storybook": "^
|
|
38
|
+
"@chromatic-com/storybook": "^3.2.2",
|
|
39
39
|
"@eslint/js": "^9.9.0",
|
|
40
|
-
"@storybook/addon-essentials": "^8.
|
|
41
|
-
"@storybook/addon-interactions": "^8.
|
|
42
|
-
"@storybook/addon-links": "^8.
|
|
43
|
-
"@storybook/addon-onboarding": "^8.
|
|
44
|
-
"@storybook/blocks": "^8.
|
|
45
|
-
"@storybook/react": "^8.
|
|
46
|
-
"@storybook/react-vite": "^8.
|
|
47
|
-
"@storybook/test": "^8.
|
|
40
|
+
"@storybook/addon-essentials": "^8.4.5",
|
|
41
|
+
"@storybook/addon-interactions": "^8.4.5",
|
|
42
|
+
"@storybook/addon-links": "^8.4.5",
|
|
43
|
+
"@storybook/addon-onboarding": "^8.4.5",
|
|
44
|
+
"@storybook/blocks": "^8.4.5",
|
|
45
|
+
"@storybook/react": "^8.4.5",
|
|
46
|
+
"@storybook/react-vite": "^8.4.5",
|
|
47
|
+
"@storybook/test": "^8.4.5",
|
|
48
48
|
"@types/node": "^22.7.9",
|
|
49
49
|
"@types/react": "^18.3.3",
|
|
50
50
|
"@types/react-dom": "^18.3.0",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"eslint": "^9.9.0",
|
|
53
53
|
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
|
|
54
54
|
"eslint-plugin-react-refresh": "^0.4.9",
|
|
55
|
-
"eslint-plugin-storybook": "^0.
|
|
55
|
+
"eslint-plugin-storybook": "^0.11.1",
|
|
56
56
|
"globals": "^15.9.0",
|
|
57
|
-
"storybook": "^8.
|
|
57
|
+
"storybook": "^8.4.5",
|
|
58
58
|
"typescript": "^5.5.3",
|
|
59
59
|
"typescript-eslint": "^8.0.1",
|
|
60
60
|
"vite": "^5.4.1",
|