react-spring-carousel 3.0.0-beta090.6 → 3.0.0-beta090.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs2.js +1 -1
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.es2.js +127 -124
- package/dist/index.es2.js.map +1 -1
- package/dist/types/types/useSpringCarousel.types.d.ts +2 -0
- package/package.json +14 -11
package/dist/index.es2.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import { useDrag as
|
|
4
|
-
import { useRef as m, useEffect as E, createContext as
|
|
5
|
-
import
|
|
1
|
+
import { u as He, a as ze, j as R } from "./useThumbsModule-4e4b7969.js";
|
|
2
|
+
import { useSpring as Xe, config as _, useIsomorphicLayoutEffect as Ye } from "@react-spring/web";
|
|
3
|
+
import { useDrag as Je } from "@use-gesture/react";
|
|
4
|
+
import { useRef as m, useEffect as E, createContext as Ke, useCallback as Y, useContext as Qe } from "react";
|
|
5
|
+
import Ue from "resize-observer-polyfill";
|
|
6
6
|
import N from "screenfull";
|
|
7
|
-
function
|
|
7
|
+
function Ze({
|
|
8
8
|
mainCarouselWrapperRef: n,
|
|
9
9
|
onFullScreenChange: v,
|
|
10
10
|
handleResize: W
|
|
@@ -22,7 +22,7 @@ function Ue({
|
|
|
22
22
|
function J(a) {
|
|
23
23
|
O.current = a;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function p() {
|
|
26
26
|
return O.current;
|
|
27
27
|
}
|
|
28
28
|
function b(a) {
|
|
@@ -34,33 +34,34 @@ function Ue({
|
|
|
34
34
|
return {
|
|
35
35
|
enterFullscreen: b,
|
|
36
36
|
exitFullscreen: u,
|
|
37
|
-
getIsFullscreen:
|
|
37
|
+
getIsFullscreen: p
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function nr({
|
|
41
41
|
items: n,
|
|
42
42
|
init: v = !0,
|
|
43
43
|
withThumbs: W,
|
|
44
44
|
thumbsSlideAxis: O = "x",
|
|
45
45
|
itemsPerSlide: J = 1,
|
|
46
|
-
slideType:
|
|
46
|
+
slideType: p = "fixed",
|
|
47
47
|
gutter: b = 0,
|
|
48
48
|
withLoop: u = !1,
|
|
49
49
|
startEndGutter: a = 0,
|
|
50
50
|
carouselSlideAxis: o = "x",
|
|
51
|
-
disableGestures:
|
|
51
|
+
disableGestures: ve = !1,
|
|
52
52
|
draggingSlideTreshold: ne,
|
|
53
|
-
slideWhenThresholdIsReached:
|
|
53
|
+
slideWhenThresholdIsReached: pe = !1,
|
|
54
54
|
freeScroll: c,
|
|
55
55
|
enableFreeScrollDrag: ce,
|
|
56
56
|
initialStartingPosition: L,
|
|
57
|
-
prepareThumbsData:
|
|
57
|
+
prepareThumbsData: Te,
|
|
58
58
|
initialActiveItem: C = 0,
|
|
59
|
-
animateWhenActiveItemChange:
|
|
59
|
+
animateWhenActiveItemChange: we = !0,
|
|
60
60
|
getControllerRef: ue,
|
|
61
|
-
slideGroupOfItems: j = !1
|
|
61
|
+
slideGroupOfItems: j = !1,
|
|
62
|
+
customSlideValue: oe
|
|
62
63
|
}) {
|
|
63
|
-
const w = J > n.length ? n.length : J, K = m(!1), G = m(ne ?? 0), k = m("initial"),
|
|
64
|
+
const w = J > n.length ? n.length : J, K = m(!1), G = m(ne ?? 0), k = m("initial"), ie = m("initial"), se = m("initial"), x = m(C), d = m(C === 0), s = m(p === "fixed" && C === n.length - 1), f = m(null), I = m(null), le = m(0), fe = m(0), g = m(0), Me = m(u), Ce = m(p), ke = m(c), V = m(!1), A = Y(() => u ? [
|
|
64
65
|
...n.map((e) => ({
|
|
65
66
|
...e,
|
|
66
67
|
id: `prev-repeated-item-${e.id}`
|
|
@@ -70,27 +71,27 @@ function tr({
|
|
|
70
71
|
...e,
|
|
71
72
|
id: `next-repeated-item-${e.id}`
|
|
72
73
|
}))
|
|
73
|
-
] : [...n], [n, u])(), [P,
|
|
74
|
+
] : [...n], [n, u])(), [P, y] = Xe(
|
|
74
75
|
() => ({
|
|
75
76
|
val: 0,
|
|
76
77
|
pause: !v,
|
|
77
78
|
onChange: ({ value: e }) => {
|
|
78
|
-
c && f.current ? (o === "x" ? f.current.scrollLeft = Math.abs(e.val) : f.current.scrollTop = Math.abs(e.val), te()) :
|
|
79
|
+
c && f.current ? (o === "x" ? f.current.scrollLeft = Math.abs(e.val) : f.current.scrollTop = Math.abs(e.val), te()) : I.current && (o === "x" ? I.current.style.transform = `translate3d(${e.val}px, 0px,0px)` : I.current.style.transform = `translate3d(0px,${e.val}px,0px)`);
|
|
79
80
|
}
|
|
80
81
|
}),
|
|
81
82
|
[c]
|
|
82
|
-
), { emitEvent: S, useListenToCustomEvent: ee } =
|
|
83
|
+
), { emitEvent: S, useListenToCustomEvent: ee } = He(), { thumbsFragment: Fe, handleScroll: $e } = ze({
|
|
83
84
|
withThumbs: !!W,
|
|
84
85
|
thumbsSlideAxis: O,
|
|
85
|
-
prepareThumbsData:
|
|
86
|
+
prepareThumbsData: Te,
|
|
86
87
|
items: n,
|
|
87
88
|
renderThumbFnProps: {
|
|
88
|
-
getIsActiveItem:
|
|
89
|
-
getIsPrevItem:
|
|
89
|
+
getIsActiveItem: he,
|
|
90
|
+
getIsPrevItem: ge,
|
|
90
91
|
useListenToCustomEvent: ee,
|
|
91
|
-
getIsNextItem:
|
|
92
|
+
getIsNextItem: de
|
|
92
93
|
}
|
|
93
|
-
}), { enterFullscreen:
|
|
94
|
+
}), { enterFullscreen: xe, exitFullscreen: Ie, getIsFullscreen: ye } = Ze({
|
|
94
95
|
mainCarouselWrapperRef: f,
|
|
95
96
|
handleResize: () => re(),
|
|
96
97
|
onFullScreenChange: (e) => {
|
|
@@ -100,8 +101,8 @@ function tr({
|
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
|
-
function
|
|
104
|
-
return
|
|
104
|
+
function Ne(e) {
|
|
105
|
+
return p === "fixed" && !c ? {
|
|
105
106
|
marginRight: `${e ? 0 : b}px`,
|
|
106
107
|
flex: `1 0 calc(100% / ${w} - ${b * (w - 1) / w}px)`
|
|
107
108
|
} : {
|
|
@@ -110,24 +111,26 @@ function tr({
|
|
|
110
111
|
}
|
|
111
112
|
const l = Y(() => {
|
|
112
113
|
var r;
|
|
114
|
+
if (p === "fluid" && typeof oe == "number")
|
|
115
|
+
return oe;
|
|
113
116
|
const e = j ? f.current : (r = f.current) == null ? void 0 : r.querySelector(".use-spring-carousel-item");
|
|
114
117
|
if (!e)
|
|
115
118
|
throw Error("No carousel items available!");
|
|
116
119
|
let t = e.getBoundingClientRect()[o === "x" ? "width" : "height"];
|
|
117
120
|
return j || (t += b), j && (t += b - a * 2), t;
|
|
118
|
-
}, [o, b, j, a]);
|
|
121
|
+
}, [o, b, j, a, oe, p]);
|
|
119
122
|
function D({ from: e, to: t, nextActiveItem: r, immediate: i = !1, slideMode: M }) {
|
|
120
|
-
|
|
123
|
+
ie.current = M, typeof r == "number" && (c || (x.current = r), S({
|
|
121
124
|
eventName: "onSlideStartChange",
|
|
122
125
|
slideActionType: k.current,
|
|
123
|
-
slideMode:
|
|
126
|
+
slideMode: ie.current,
|
|
124
127
|
nextItem: {
|
|
125
128
|
startReached: d.current,
|
|
126
129
|
endReached: s.current,
|
|
127
|
-
index: c ? -1 :
|
|
128
|
-
id: c ? "" : n[
|
|
130
|
+
index: c ? -1 : x.current,
|
|
131
|
+
id: c ? "" : n[x.current].id
|
|
129
132
|
}
|
|
130
|
-
})), g.current = t,
|
|
133
|
+
})), g.current = t, y.start({
|
|
131
134
|
immediate: i,
|
|
132
135
|
from: {
|
|
133
136
|
val: e
|
|
@@ -143,26 +146,26 @@ function tr({
|
|
|
143
146
|
!i && z.finished && S({
|
|
144
147
|
eventName: "onSlideChange",
|
|
145
148
|
slideActionType: k.current,
|
|
146
|
-
slideMode:
|
|
149
|
+
slideMode: ie.current,
|
|
147
150
|
currentItem: {
|
|
148
151
|
startReached: d.current,
|
|
149
152
|
endReached: s.current,
|
|
150
|
-
index: c ? -1 :
|
|
151
|
-
id: c ? "" : n[
|
|
153
|
+
index: c ? -1 : x.current,
|
|
154
|
+
id: c ? "" : n[x.current].id
|
|
152
155
|
}
|
|
153
156
|
});
|
|
154
157
|
}
|
|
155
|
-
}), W && !i &&
|
|
158
|
+
}), W && !i && $e(x.current);
|
|
156
159
|
}
|
|
157
160
|
const h = Y(() => {
|
|
158
161
|
var e;
|
|
159
|
-
return
|
|
162
|
+
return I.current ? u ? l() * n.length : Math.round(
|
|
160
163
|
Number(
|
|
161
|
-
(e =
|
|
162
|
-
) -
|
|
164
|
+
(e = I.current) == null ? void 0 : e[o === "x" ? "scrollWidth" : "scrollHeight"]
|
|
165
|
+
) - I.current.getBoundingClientRect()[o === "x" ? "width" : "height"] - a * 2
|
|
163
166
|
) : 0;
|
|
164
167
|
}, [o, l, n.length, a, u]);
|
|
165
|
-
function
|
|
168
|
+
function Ee() {
|
|
166
169
|
const e = `calc(100% - ${a * 2}px)`;
|
|
167
170
|
return {
|
|
168
171
|
width: o === "x" ? e : "100%",
|
|
@@ -171,32 +174,32 @@ function tr({
|
|
|
171
174
|
}
|
|
172
175
|
const Q = Y(() => {
|
|
173
176
|
var t;
|
|
174
|
-
const e = (t =
|
|
177
|
+
const e = (t = I.current) == null ? void 0 : t.querySelector(".use-spring-carousel-item");
|
|
175
178
|
if (!e)
|
|
176
179
|
throw Error("No carousel items available!");
|
|
177
180
|
return e.getBoundingClientRect()[o === "x" ? "width" : "height"] + b;
|
|
178
181
|
}, [o, b]), U = Y(
|
|
179
182
|
(e) => {
|
|
180
|
-
const t = o === "x" ? "left" : "top", r =
|
|
183
|
+
const t = o === "x" ? "left" : "top", r = I.current;
|
|
181
184
|
r && (u ? (r.style.top = "0px", r.style.left = "0px", r.style[t] = `-${e - a}px`, d.current = !1, s.current = !1) : (r.style.left = "0px", r.style.top = "0px"));
|
|
182
185
|
},
|
|
183
186
|
[o, a, u]
|
|
184
187
|
), re = Y(
|
|
185
188
|
(e = !1) => {
|
|
186
|
-
if (
|
|
189
|
+
if (I.current && e && (I.current.style.transform = "translate3d(0px, 0px,0px)", I.current.style.left = "0", I.current.style.top = "0"), p === "fixed" && U(
|
|
187
190
|
L === "center" ? Q() * n.length - l() * Math.round((w - 1) / 2) : L === "end" ? Q() * n.length - l() * Math.round(w - 1) : Q() * n.length
|
|
188
|
-
),
|
|
191
|
+
), p === "fluid") {
|
|
189
192
|
if (U(Q() * n.length), s.current && h() !== Math.abs(g.current) && !u) {
|
|
190
193
|
const t = -h();
|
|
191
|
-
g.current = t,
|
|
194
|
+
g.current = t, y.start({
|
|
192
195
|
immediate: !0,
|
|
193
196
|
val: g.current
|
|
194
197
|
});
|
|
195
198
|
return;
|
|
196
199
|
}
|
|
197
|
-
if (Math.abs(g.current) > 0 && h() !== Math.abs(g.current) && !u && !c &&
|
|
198
|
-
const t =
|
|
199
|
-
return
|
|
200
|
+
if (Math.abs(g.current) > 0 && h() !== Math.abs(g.current) && !u && !c && se.current === "backward") {
|
|
201
|
+
const t = le.current - h(), r = g.current + t;
|
|
202
|
+
return y.start({
|
|
200
203
|
immediate: !0,
|
|
201
204
|
val: r
|
|
202
205
|
}), () => {
|
|
@@ -206,16 +209,16 @@ function tr({
|
|
|
206
209
|
console.log("here");
|
|
207
210
|
return;
|
|
208
211
|
}
|
|
209
|
-
if (!c &&
|
|
210
|
-
const t = -(l() *
|
|
212
|
+
if (!c && p === "fixed") {
|
|
213
|
+
const t = -(l() * x.current);
|
|
211
214
|
if (Math.abs(t) > h() && !u) {
|
|
212
215
|
const r = -h();
|
|
213
|
-
s.current = !0, g.current = r,
|
|
216
|
+
s.current = !0, g.current = r, y.start({
|
|
214
217
|
immediate: !0,
|
|
215
218
|
val: g.current
|
|
216
219
|
});
|
|
217
220
|
} else
|
|
218
|
-
g.current = t,
|
|
221
|
+
g.current = t, y.start({
|
|
219
222
|
immediate: !0,
|
|
220
223
|
val: t
|
|
221
224
|
});
|
|
@@ -233,8 +236,8 @@ function tr({
|
|
|
233
236
|
n.length,
|
|
234
237
|
w,
|
|
235
238
|
U,
|
|
236
|
-
I,
|
|
237
239
|
y,
|
|
240
|
+
p,
|
|
238
241
|
u
|
|
239
242
|
]
|
|
240
243
|
);
|
|
@@ -255,8 +258,8 @@ function tr({
|
|
|
255
258
|
function q({ type: e, index: t, immediate: r }) {
|
|
256
259
|
if (!v || V.current || d.current && !u)
|
|
257
260
|
return;
|
|
258
|
-
s.current && (
|
|
259
|
-
const i = typeof t == "number" ? t :
|
|
261
|
+
s.current && (se.current = "backward"), k.current = "prev", s.current = !1;
|
|
262
|
+
const i = typeof t == "number" ? t : x.current - 1;
|
|
260
263
|
if (c && te(), !u) {
|
|
261
264
|
const M = c ? Z("prev", t) - l() / 3 < 0 : Z("prev", t) + l() / 3 > 0;
|
|
262
265
|
if (d.current)
|
|
@@ -293,8 +296,8 @@ function tr({
|
|
|
293
296
|
function B({ type: e, index: t, immediate: r }) {
|
|
294
297
|
if (!v || V.current || s.current && !u)
|
|
295
298
|
return;
|
|
296
|
-
d.current && (
|
|
297
|
-
const i = t ||
|
|
299
|
+
d.current && (se.current = "forward"), k.current = "next", d.current = !1;
|
|
300
|
+
const i = t || x.current + 1;
|
|
298
301
|
if (c && te(), !u) {
|
|
299
302
|
const M = Math.abs(Z("next", t)) > h() - l() / 3;
|
|
300
303
|
if (s.current)
|
|
@@ -328,15 +331,15 @@ function tr({
|
|
|
328
331
|
immediate: r
|
|
329
332
|
});
|
|
330
333
|
}
|
|
331
|
-
function
|
|
334
|
+
function We() {
|
|
332
335
|
ne ? G.current = ne : G.current = Math.floor(l() / 2 / 2);
|
|
333
336
|
}
|
|
334
|
-
function
|
|
335
|
-
|
|
337
|
+
function be() {
|
|
338
|
+
I.current && (le.current = h(), Me.current = u, Ce.current = p, ke.current = c, fe.current = window.innerWidth, g.current = 0, ae({ id: 0, immediate: !0, shouldReset: !0 }), We(), re());
|
|
336
339
|
}
|
|
337
|
-
const
|
|
340
|
+
const Pe = Je(
|
|
338
341
|
(e) => {
|
|
339
|
-
const t = e.dragging, r = e.offset[o === "x" ? 0 : 1], i = e.movement[o === "x" ? 0 : 1], M = e.direction[o === "x" ? 0 : 1], z = i > G.current, X = i < -G.current,
|
|
342
|
+
const t = e.dragging, r = e.offset[o === "x" ? 0 : 1], i = e.movement[o === "x" ? 0 : 1], M = e.direction[o === "x" ? 0 : 1], z = i > G.current, X = i < -G.current, Be = h(), $ = e.velocity;
|
|
340
343
|
if (t) {
|
|
341
344
|
if (M > 0 ? k.current = "prev" : k.current = "next", S({
|
|
342
345
|
...e,
|
|
@@ -344,7 +347,7 @@ function tr({
|
|
|
344
347
|
slideActionType: k.current
|
|
345
348
|
}), c) {
|
|
346
349
|
if (r > 0) {
|
|
347
|
-
|
|
350
|
+
y.start({
|
|
348
351
|
from: {
|
|
349
352
|
val: F()
|
|
350
353
|
},
|
|
@@ -359,7 +362,7 @@ function tr({
|
|
|
359
362
|
}), e.cancel();
|
|
360
363
|
return;
|
|
361
364
|
}
|
|
362
|
-
|
|
365
|
+
y.start({
|
|
363
366
|
from: {
|
|
364
367
|
val: F()
|
|
365
368
|
},
|
|
@@ -374,18 +377,18 @@ function tr({
|
|
|
374
377
|
});
|
|
375
378
|
return;
|
|
376
379
|
}
|
|
377
|
-
|
|
380
|
+
y.start({
|
|
378
381
|
val: r,
|
|
379
382
|
config: {
|
|
380
383
|
velocity: $,
|
|
381
384
|
friction: 50,
|
|
382
385
|
tension: 1e3
|
|
383
386
|
}
|
|
384
|
-
}),
|
|
387
|
+
}), pe && X ? (B({ type: "drag" }), e.cancel()) : pe && z && (q({ type: "drag" }), e.cancel()), Be - Math.abs(r) < -(l() * 2) && e.cancel();
|
|
385
388
|
return;
|
|
386
389
|
}
|
|
387
390
|
if (e.last && c && r > 0) {
|
|
388
|
-
|
|
391
|
+
y.start({
|
|
389
392
|
from: {
|
|
390
393
|
val: F()
|
|
391
394
|
},
|
|
@@ -400,25 +403,25 @@ function tr({
|
|
|
400
403
|
});
|
|
401
404
|
return;
|
|
402
405
|
}
|
|
403
|
-
e.last && !e.canceled && c && (k.current === "prev" && q({ type: "drag" }), k.current === "next" && B({ type: "drag" })), e.last && !e.canceled && !c && (X ? !u && s.current ?
|
|
406
|
+
e.last && !e.canceled && c && (k.current === "prev" && q({ type: "drag" }), k.current === "next" && B({ type: "drag" })), e.last && !e.canceled && !c && (X ? !u && s.current ? y.start({
|
|
404
407
|
val: -h(),
|
|
405
408
|
config: {
|
|
406
409
|
..._.default,
|
|
407
410
|
velocity: $
|
|
408
411
|
}
|
|
409
|
-
}) : B({ type: "drag" }) : z ? !u && d.current ?
|
|
412
|
+
}) : B({ type: "drag" }) : z ? !u && d.current ? y.start({
|
|
410
413
|
val: 0,
|
|
411
414
|
config: {
|
|
412
415
|
..._.default,
|
|
413
416
|
velocity: $
|
|
414
417
|
}
|
|
415
|
-
}) : q({ type: "drag" }) :
|
|
418
|
+
}) : q({ type: "drag" }) : y.start({
|
|
416
419
|
val: g.current,
|
|
417
420
|
config: {
|
|
418
421
|
..._.default,
|
|
419
422
|
velocity: $
|
|
420
423
|
}
|
|
421
|
-
})), e.last && e.canceled &&
|
|
424
|
+
})), e.last && e.canceled && y.start({
|
|
422
425
|
val: g.current,
|
|
423
426
|
config: {
|
|
424
427
|
..._.default,
|
|
@@ -427,7 +430,7 @@ function tr({
|
|
|
427
430
|
});
|
|
428
431
|
},
|
|
429
432
|
{
|
|
430
|
-
enabled: v && !
|
|
433
|
+
enabled: v && !ve && !c || !!c && !!ce,
|
|
431
434
|
axis: o,
|
|
432
435
|
from: () => c && f.current ? [
|
|
433
436
|
-f.current.scrollLeft,
|
|
@@ -435,7 +438,7 @@ function tr({
|
|
|
435
438
|
] : o === "x" ? [P.val.get(), P.val.get()] : [P.val.get(), P.val.get()]
|
|
436
439
|
}
|
|
437
440
|
);
|
|
438
|
-
function
|
|
441
|
+
function Re() {
|
|
439
442
|
return c ? o === "x" ? {
|
|
440
443
|
overflowX: "auto"
|
|
441
444
|
} : {
|
|
@@ -445,7 +448,7 @@ function tr({
|
|
|
445
448
|
function te() {
|
|
446
449
|
f.current && (g.current = f.current[o === "x" ? "scrollLeft" : "scrollTop"], f.current[o === "x" ? "scrollLeft" : "scrollTop"] === 0 && (d.current = !0, s.current = !1), f.current[o === "x" ? "scrollLeft" : "scrollTop"] > 0 && f.current[o === "x" ? "scrollLeft" : "scrollTop"] < h() && (d.current = !1, s.current = !1), f.current[o === "x" ? "scrollLeft" : "scrollTop"] === h() && (d.current = !1, s.current = !0));
|
|
447
450
|
}
|
|
448
|
-
function
|
|
451
|
+
function je() {
|
|
449
452
|
return c ? {
|
|
450
453
|
onWheel() {
|
|
451
454
|
P.val.stop(), te();
|
|
@@ -461,7 +464,7 @@ function tr({
|
|
|
461
464
|
}
|
|
462
465
|
return r;
|
|
463
466
|
}
|
|
464
|
-
function
|
|
467
|
+
function ae({ id: e, immediate: t, shouldReset: r, type: i }) {
|
|
465
468
|
if (!v || V.current)
|
|
466
469
|
return;
|
|
467
470
|
d.current = !1, s.current = !1;
|
|
@@ -469,9 +472,9 @@ function tr({
|
|
|
469
472
|
e,
|
|
470
473
|
"The item you want to slide to doesn't exist; check the provided id."
|
|
471
474
|
);
|
|
472
|
-
if (M ===
|
|
475
|
+
if (M === x.current && !r)
|
|
473
476
|
return;
|
|
474
|
-
const z = H(n[
|
|
477
|
+
const z = H(n[x.current].id), X = H(n[M].id);
|
|
475
478
|
X > z ? B({
|
|
476
479
|
type: i || r ? "initial" : "click",
|
|
477
480
|
index: X,
|
|
@@ -482,25 +485,25 @@ function tr({
|
|
|
482
485
|
immediate: t
|
|
483
486
|
});
|
|
484
487
|
}
|
|
485
|
-
function
|
|
486
|
-
const t = H(e, "The item doesn't exist; check the provided id."), r =
|
|
488
|
+
function de(e) {
|
|
489
|
+
const t = H(e, "The item doesn't exist; check the provided id."), r = x.current;
|
|
487
490
|
return u && r === n.length - 1 ? t === 0 : t === r + 1;
|
|
488
491
|
}
|
|
489
|
-
function
|
|
490
|
-
const t = H(e, "The item doesn't exist; check the provided id."), r =
|
|
492
|
+
function ge(e) {
|
|
493
|
+
const t = H(e, "The item doesn't exist; check the provided id."), r = x.current;
|
|
491
494
|
return u && r === 0 ? t === n.length - 1 : t === r - 1;
|
|
492
495
|
}
|
|
493
|
-
function
|
|
494
|
-
return H(e, "The item you want to check doesn't exist; check the provided id.") ===
|
|
496
|
+
function he(e) {
|
|
497
|
+
return H(e, "The item you want to check doesn't exist; check the provided id.") === x.current;
|
|
495
498
|
}
|
|
496
|
-
function
|
|
497
|
-
return
|
|
499
|
+
function Ve() {
|
|
500
|
+
return ve ? "unset" : o === "x" ? "pan-y" : "pan-x";
|
|
498
501
|
}
|
|
499
502
|
const T = c ? {
|
|
500
503
|
useListenToCustomEvent: ee,
|
|
501
|
-
enterFullscreen:
|
|
502
|
-
exitFullscreen:
|
|
503
|
-
getIsFullscreen:
|
|
504
|
+
enterFullscreen: xe,
|
|
505
|
+
exitFullscreen: Ie,
|
|
506
|
+
getIsFullscreen: ye,
|
|
504
507
|
slideToPrevItem: (e = !0) => {
|
|
505
508
|
q({
|
|
506
509
|
type: "click",
|
|
@@ -515,9 +518,9 @@ function tr({
|
|
|
515
518
|
}
|
|
516
519
|
} : {
|
|
517
520
|
useListenToCustomEvent: ee,
|
|
518
|
-
enterFullscreen:
|
|
519
|
-
exitFullscreen:
|
|
520
|
-
getIsFullscreen:
|
|
521
|
+
enterFullscreen: xe,
|
|
522
|
+
exitFullscreen: Ie,
|
|
523
|
+
getIsFullscreen: ye,
|
|
521
524
|
slideToPrevItem: (e = !0) => {
|
|
522
525
|
q({
|
|
523
526
|
type: "click",
|
|
@@ -531,18 +534,18 @@ function tr({
|
|
|
531
534
|
});
|
|
532
535
|
},
|
|
533
536
|
slideToItem: (e, t = !0) => {
|
|
534
|
-
|
|
537
|
+
ae({ id: e, immediate: !t });
|
|
535
538
|
},
|
|
536
|
-
getIsNextItem:
|
|
537
|
-
getIsPrevItem:
|
|
538
|
-
getIsActiveItem:
|
|
539
|
+
getIsNextItem: de,
|
|
540
|
+
getIsPrevItem: ge,
|
|
541
|
+
getIsActiveItem: he
|
|
539
542
|
};
|
|
540
|
-
|
|
541
|
-
|
|
543
|
+
Ye(() => {
|
|
544
|
+
I.current && v && (K.current = !0, be());
|
|
542
545
|
}, [v]), E(() => {
|
|
543
|
-
|
|
546
|
+
x.current !== C && (K.current = !0, ae({
|
|
544
547
|
id: C,
|
|
545
|
-
immediate: !
|
|
548
|
+
immediate: !we
|
|
546
549
|
}));
|
|
547
550
|
}, [C]), E(() => {
|
|
548
551
|
if (v) {
|
|
@@ -555,20 +558,20 @@ function tr({
|
|
|
555
558
|
);
|
|
556
559
|
}
|
|
557
560
|
}, [C, n.length, w, v]), E(() => {
|
|
558
|
-
|
|
561
|
+
fe.current = window.innerWidth;
|
|
559
562
|
}, []), E(() => {
|
|
560
563
|
if (v) {
|
|
561
564
|
if (u && c)
|
|
562
565
|
throw new Error("`withLoop` and `freeScroll` can't be used together.");
|
|
563
|
-
if (c &&
|
|
566
|
+
if (c && p === "fixed")
|
|
564
567
|
throw new Error("`freeScroll` can't be used when `scrollType=fixed`.");
|
|
565
|
-
if (ce && (
|
|
568
|
+
if (ce && (p !== "fluid" || !c))
|
|
566
569
|
throw new Error(
|
|
567
570
|
"`enableFreeScrollDrag` must be used with `slideType=fluid` and `freeScroll=true`"
|
|
568
571
|
);
|
|
569
572
|
if (j && c)
|
|
570
573
|
throw new Error("`slideGroupOfItems` and `freeScroll` can't be used together.");
|
|
571
|
-
K.current = !0,
|
|
574
|
+
K.current = !0, be();
|
|
572
575
|
}
|
|
573
576
|
}, [
|
|
574
577
|
L,
|
|
@@ -577,7 +580,7 @@ function tr({
|
|
|
577
580
|
b,
|
|
578
581
|
v,
|
|
579
582
|
u,
|
|
580
|
-
|
|
583
|
+
p,
|
|
581
584
|
c,
|
|
582
585
|
ce,
|
|
583
586
|
j
|
|
@@ -593,12 +596,12 @@ function tr({
|
|
|
593
596
|
}, [v]), E(() => {
|
|
594
597
|
if (f.current) {
|
|
595
598
|
let e;
|
|
596
|
-
const t = new
|
|
599
|
+
const t = new Ue(() => {
|
|
597
600
|
if (!V.current && !K.current) {
|
|
598
|
-
|
|
601
|
+
fe.current = window.innerWidth;
|
|
599
602
|
const r = re();
|
|
600
603
|
window.clearTimeout(e), e = setTimeout(() => {
|
|
601
|
-
|
|
604
|
+
le.current = h(), typeof r == "function" && r();
|
|
602
605
|
}, 100);
|
|
603
606
|
}
|
|
604
607
|
});
|
|
@@ -613,31 +616,31 @@ function tr({
|
|
|
613
616
|
slideToItem: T == null ? void 0 : T.slideToItem
|
|
614
617
|
});
|
|
615
618
|
}, [ue, T.slideToItem, T.slideToNextItem, T.slideToPrevItem]);
|
|
616
|
-
const
|
|
619
|
+
const De = /* @__PURE__ */ R.jsx(me.Provider, { value: T, children: Fe }), qe = /* @__PURE__ */ R.jsx(me.Provider, { value: T, children: /* @__PURE__ */ R.jsx(
|
|
617
620
|
"div",
|
|
618
621
|
{
|
|
619
622
|
className: "use-spring-carousel-main-wrapper",
|
|
620
623
|
ref: f,
|
|
621
|
-
...
|
|
624
|
+
...je(),
|
|
622
625
|
style: {
|
|
623
626
|
display: "flex",
|
|
624
627
|
position: "relative",
|
|
625
628
|
width: "100%",
|
|
626
629
|
height: "100%",
|
|
627
|
-
...
|
|
630
|
+
...Re()
|
|
628
631
|
},
|
|
629
632
|
children: /* @__PURE__ */ R.jsxs(
|
|
630
633
|
"div",
|
|
631
634
|
{
|
|
632
635
|
className: "use-spring-carousel-track-wrapper",
|
|
633
|
-
ref:
|
|
634
|
-
...
|
|
636
|
+
ref: I,
|
|
637
|
+
...Pe(),
|
|
635
638
|
style: {
|
|
636
639
|
position: "relative",
|
|
637
640
|
display: "flex",
|
|
638
641
|
flexDirection: o === "x" ? "row" : "column",
|
|
639
|
-
touchAction:
|
|
640
|
-
...
|
|
642
|
+
touchAction: Ve(),
|
|
643
|
+
...Ee()
|
|
641
644
|
},
|
|
642
645
|
children: [
|
|
643
646
|
(c || !u) && a ? /* @__PURE__ */ R.jsx(
|
|
@@ -658,16 +661,16 @@ function tr({
|
|
|
658
661
|
display: "flex",
|
|
659
662
|
position: "relative",
|
|
660
663
|
flex: "1",
|
|
661
|
-
|
|
664
|
+
...Ne(
|
|
662
665
|
t === A.findIndex(
|
|
663
666
|
(r) => r.id === A[A.length - 1].id
|
|
664
667
|
)
|
|
665
668
|
)
|
|
666
669
|
},
|
|
667
670
|
children: typeof e.renderItem == "function" ? e.renderItem({
|
|
668
|
-
getIsActiveItem:
|
|
669
|
-
getIsNextItem:
|
|
670
|
-
getIsPrevItem:
|
|
671
|
+
getIsActiveItem: he,
|
|
672
|
+
getIsNextItem: de,
|
|
673
|
+
getIsPrevItem: ge,
|
|
671
674
|
useListenToCustomEvent: ee
|
|
672
675
|
}) : e.renderItem
|
|
673
676
|
},
|
|
@@ -687,17 +690,17 @@ function tr({
|
|
|
687
690
|
)
|
|
688
691
|
}
|
|
689
692
|
) });
|
|
690
|
-
return { ...T, carouselFragment:
|
|
693
|
+
return { ...T, carouselFragment: qe, thumbsFragment: De };
|
|
691
694
|
}
|
|
692
|
-
const
|
|
693
|
-
function
|
|
694
|
-
const n =
|
|
695
|
+
const me = Ke(void 0);
|
|
696
|
+
function cr() {
|
|
697
|
+
const n = Qe(me);
|
|
695
698
|
if (!n)
|
|
696
699
|
throw new Error("useSpringCarouselContext must be used within the carousel.");
|
|
697
700
|
return n;
|
|
698
701
|
}
|
|
699
702
|
export {
|
|
700
|
-
|
|
701
|
-
|
|
703
|
+
nr as useSpringCarousel,
|
|
704
|
+
cr as useSpringCarouselContext
|
|
702
705
|
};
|
|
703
706
|
//# sourceMappingURL=index.es2.js.map
|