react-spring-carousel 3.0.0-beta090.4 → 3.0.0-beta090.5
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.es2.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { useSpring as
|
|
1
|
+
import { u as qe, a as Be, j as P } from "./useThumbsModule-4e4b7969.js";
|
|
2
|
+
import { useSpring as He, config as Q, useIsomorphicLayoutEffect as ze } from "@react-spring/web";
|
|
3
3
|
import { useDrag as Oe } from "@use-gesture/react";
|
|
4
|
-
import { useRef as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function
|
|
4
|
+
import { useRef as h, useEffect as $, createContext as Xe, useCallback as z, useContext as Ye } from "react";
|
|
5
|
+
import Je from "resize-observer-polyfill";
|
|
6
|
+
import E from "screenfull";
|
|
7
|
+
function Ke({
|
|
8
8
|
mainCarouselWrapperRef: n,
|
|
9
9
|
onFullScreenChange: v,
|
|
10
10
|
handleResize: N
|
|
11
11
|
}) {
|
|
12
|
-
const U =
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
document.fullscreenElement && (
|
|
12
|
+
const U = h(!1);
|
|
13
|
+
$(() => {
|
|
14
|
+
function m() {
|
|
15
|
+
document.fullscreenElement && (O(!0), v(!0), N && N()), document.fullscreenElement || (O(!1), v(!1), N && N());
|
|
16
16
|
}
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
19
|
-
|
|
17
|
+
if (E.isEnabled)
|
|
18
|
+
return E.on("change", m), () => {
|
|
19
|
+
E.isEnabled && E.off("change", m);
|
|
20
20
|
};
|
|
21
21
|
}, []);
|
|
22
|
-
function
|
|
23
|
-
U.current =
|
|
22
|
+
function O(m) {
|
|
23
|
+
U.current = m;
|
|
24
24
|
}
|
|
25
25
|
function I() {
|
|
26
26
|
return U.current;
|
|
27
27
|
}
|
|
28
|
-
function T(
|
|
29
|
-
|
|
28
|
+
function T(m) {
|
|
29
|
+
E.isEnabled && E.request(m || n.current);
|
|
30
30
|
}
|
|
31
31
|
function u() {
|
|
32
|
-
|
|
32
|
+
E.isEnabled && E.exit();
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
35
|
enterFullscreen: T,
|
|
@@ -37,29 +37,30 @@ function Je({
|
|
|
37
37
|
getIsFullscreen: I
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function tt({
|
|
41
41
|
items: n,
|
|
42
42
|
init: v = !0,
|
|
43
43
|
withThumbs: N,
|
|
44
44
|
thumbsSlideAxis: U = "x",
|
|
45
|
-
itemsPerSlide:
|
|
45
|
+
itemsPerSlide: O = 1,
|
|
46
46
|
slideType: I = "fixed",
|
|
47
47
|
gutter: T = 0,
|
|
48
48
|
withLoop: u = !1,
|
|
49
|
-
startEndGutter:
|
|
49
|
+
startEndGutter: m = 0,
|
|
50
50
|
carouselSlideAxis: o = "x",
|
|
51
|
-
disableGestures:
|
|
52
|
-
draggingSlideTreshold:
|
|
51
|
+
disableGestures: he = !1,
|
|
52
|
+
draggingSlideTreshold: re,
|
|
53
53
|
slideWhenThresholdIsReached: me = !1,
|
|
54
54
|
freeScroll: c,
|
|
55
|
-
enableFreeScrollDrag:
|
|
55
|
+
enableFreeScrollDrag: ne,
|
|
56
56
|
initialStartingPosition: Z,
|
|
57
|
-
prepareThumbsData:
|
|
57
|
+
prepareThumbsData: Ie,
|
|
58
58
|
initialActiveItem: C = 0,
|
|
59
|
-
animateWhenActiveItemChange:
|
|
60
|
-
getControllerRef:
|
|
59
|
+
animateWhenActiveItemChange: be = !0,
|
|
60
|
+
getControllerRef: ce,
|
|
61
|
+
slideGroupOfItems: _ = !1
|
|
61
62
|
}) {
|
|
62
|
-
const w =
|
|
63
|
+
const w = O > n.length ? n.length : O, X = h(!1), G = h(re ?? 0), k = h("initial"), ue = h("initial"), oe = h("initial"), p = h(C), a = h(C === 0), l = h(I === "fixed" && C === n.length - 1), f = h(null), x = h(null), ie = h(0), le = h(0), d = h(0), Te = h(u), we = h(I), Me = h(c), R = h(!1), L = z(() => u ? [
|
|
63
64
|
...n.map((e) => ({
|
|
64
65
|
...e,
|
|
65
66
|
id: `prev-repeated-item-${e.id}`
|
|
@@ -69,37 +70,37 @@ function et({
|
|
|
69
70
|
...e,
|
|
70
71
|
id: `next-repeated-item-${e.id}`
|
|
71
72
|
}))
|
|
72
|
-
] : [...n], [n, u])(), [W, y] =
|
|
73
|
+
] : [...n], [n, u])(), [W, y] = He(
|
|
73
74
|
() => ({
|
|
74
75
|
val: 0,
|
|
75
76
|
pause: !v,
|
|
76
77
|
onChange: ({ value: e }) => {
|
|
77
|
-
c &&
|
|
78
|
+
c && f.current ? (o === "x" ? f.current.scrollLeft = Math.abs(e.val) : f.current.scrollTop = Math.abs(e.val), te()) : x.current && (o === "x" ? x.current.style.transform = `translate3d(${e.val}px, 0px,0px)` : x.current.style.transform = `translate3d(0px,${e.val}px,0px)`);
|
|
78
79
|
}
|
|
79
80
|
}),
|
|
80
81
|
[c]
|
|
81
|
-
), { emitEvent:
|
|
82
|
+
), { emitEvent: A, useListenToCustomEvent: S } = qe(), { thumbsFragment: Ce, handleScroll: ke } = Be({
|
|
82
83
|
withThumbs: !!N,
|
|
83
84
|
thumbsSlideAxis: U,
|
|
84
|
-
prepareThumbsData:
|
|
85
|
+
prepareThumbsData: Ie,
|
|
85
86
|
items: n,
|
|
86
87
|
renderThumbFnProps: {
|
|
87
|
-
getIsActiveItem:
|
|
88
|
-
getIsPrevItem:
|
|
89
|
-
useListenToCustomEvent:
|
|
90
|
-
getIsNextItem:
|
|
88
|
+
getIsActiveItem: de,
|
|
89
|
+
getIsPrevItem: ae,
|
|
90
|
+
useListenToCustomEvent: S,
|
|
91
|
+
getIsNextItem: fe
|
|
91
92
|
}
|
|
92
|
-
}), { enterFullscreen:
|
|
93
|
-
mainCarouselWrapperRef:
|
|
94
|
-
handleResize: () =>
|
|
93
|
+
}), { enterFullscreen: ve, exitFullscreen: pe, getIsFullscreen: xe } = Ke({
|
|
94
|
+
mainCarouselWrapperRef: f,
|
|
95
|
+
handleResize: () => ee(),
|
|
95
96
|
onFullScreenChange: (e) => {
|
|
96
|
-
|
|
97
|
+
A({
|
|
97
98
|
eventName: "onFullscreenChange",
|
|
98
99
|
isFullscreen: e
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
});
|
|
102
|
-
function
|
|
103
|
+
function Fe(e) {
|
|
103
104
|
return I === "fixed" && !c ? {
|
|
104
105
|
marginRight: `${e ? 0 : T}px`,
|
|
105
106
|
flex: `1 0 calc(100% / ${w} - ${T * (w - 1) / w}px)`
|
|
@@ -107,20 +108,20 @@ function et({
|
|
|
107
108
|
marginRight: `${e ? 0 : T}px`
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
|
-
const s =
|
|
111
|
+
const s = z(() => {
|
|
111
112
|
var r;
|
|
112
|
-
const e = (r =
|
|
113
|
+
const e = _ ? f.current : (r = f.current) == null ? void 0 : r.querySelector(".use-spring-carousel-item");
|
|
113
114
|
if (!e)
|
|
114
115
|
throw Error("No carousel items available!");
|
|
115
116
|
return e.getBoundingClientRect()[o === "x" ? "width" : "height"] + T;
|
|
116
|
-
}, [o, T]);
|
|
117
|
+
}, [o, T, _]);
|
|
117
118
|
function j({ from: e, to: r, nextActiveItem: t, immediate: i = !1, slideMode: M }) {
|
|
118
|
-
|
|
119
|
+
ue.current = M, typeof t == "number" && (c || (p.current = t), A({
|
|
119
120
|
eventName: "onSlideStartChange",
|
|
120
121
|
slideActionType: k.current,
|
|
121
|
-
slideMode:
|
|
122
|
+
slideMode: ue.current,
|
|
122
123
|
nextItem: {
|
|
123
|
-
startReached:
|
|
124
|
+
startReached: a.current,
|
|
124
125
|
endReached: l.current,
|
|
125
126
|
index: c ? -1 : p.current,
|
|
126
127
|
id: c ? "" : n[p.current].id
|
|
@@ -138,48 +139,48 @@ function et({
|
|
|
138
139
|
velocity: W.val.velocity
|
|
139
140
|
},
|
|
140
141
|
onRest(B) {
|
|
141
|
-
!i && B.finished &&
|
|
142
|
+
!i && B.finished && A({
|
|
142
143
|
eventName: "onSlideChange",
|
|
143
144
|
slideActionType: k.current,
|
|
144
|
-
slideMode:
|
|
145
|
+
slideMode: ue.current,
|
|
145
146
|
currentItem: {
|
|
146
|
-
startReached:
|
|
147
|
+
startReached: a.current,
|
|
147
148
|
endReached: l.current,
|
|
148
149
|
index: c ? -1 : p.current,
|
|
149
150
|
id: c ? "" : n[p.current].id
|
|
150
151
|
}
|
|
151
152
|
});
|
|
152
153
|
}
|
|
153
|
-
}), N && !i &&
|
|
154
|
+
}), N && !i && ke(p.current);
|
|
154
155
|
}
|
|
155
|
-
const g =
|
|
156
|
+
const g = z(() => {
|
|
156
157
|
var e;
|
|
157
158
|
return x.current ? u ? s() * n.length : Math.round(
|
|
158
159
|
Number(
|
|
159
160
|
(e = x.current) == null ? void 0 : e[o === "x" ? "scrollWidth" : "scrollHeight"]
|
|
160
|
-
) - x.current.getBoundingClientRect()[o === "x" ? "width" : "height"] -
|
|
161
|
+
) - x.current.getBoundingClientRect()[o === "x" ? "width" : "height"] - m * 2
|
|
161
162
|
) : 0;
|
|
162
|
-
}, [o, s, n.length,
|
|
163
|
-
function
|
|
164
|
-
const e = `calc(100% - ${
|
|
163
|
+
}, [o, s, n.length, m, u]);
|
|
164
|
+
function Ee() {
|
|
165
|
+
const e = `calc(100% - ${m * 2}px)`;
|
|
165
166
|
return {
|
|
166
167
|
width: o === "x" ? e : "100%",
|
|
167
168
|
height: o === "y" ? e : "100%"
|
|
168
169
|
};
|
|
169
170
|
}
|
|
170
|
-
const Y =
|
|
171
|
+
const Y = z(() => {
|
|
171
172
|
var r;
|
|
172
173
|
const e = (r = x.current) == null ? void 0 : r.querySelector(".use-spring-carousel-item");
|
|
173
174
|
if (!e)
|
|
174
175
|
throw Error("No carousel items available!");
|
|
175
176
|
return e.getBoundingClientRect()[o === "x" ? "width" : "height"] + T;
|
|
176
|
-
}, [o, T]), J =
|
|
177
|
+
}, [o, T]), J = z(
|
|
177
178
|
(e) => {
|
|
178
179
|
const r = o === "x" ? "left" : "top", t = x.current;
|
|
179
|
-
t && (u ? (t.style.top = "0px", t.style.left = "0px", t.style[r] = `-${e -
|
|
180
|
+
t && (u ? (t.style.top = "0px", t.style.left = "0px", t.style[r] = `-${e - m}px`, a.current = !1, l.current = !1) : (t.style.left = "0px", t.style.top = "0px"));
|
|
180
181
|
},
|
|
181
|
-
[o,
|
|
182
|
-
),
|
|
182
|
+
[o, m, u]
|
|
183
|
+
), ee = z(
|
|
183
184
|
(e = !1) => {
|
|
184
185
|
if (x.current && e && (x.current.style.transform = "translate3d(0px, 0px,0px)", x.current.style.left = "0", x.current.style.top = "0"), I === "fixed" && J(
|
|
185
186
|
Z === "center" ? Y() * n.length - s() * Math.round((w - 1) / 2) : Z === "end" ? Y() * n.length - s() * Math.round(w - 1) : Y() * n.length
|
|
@@ -192,8 +193,8 @@ function et({
|
|
|
192
193
|
});
|
|
193
194
|
return;
|
|
194
195
|
}
|
|
195
|
-
if (Math.abs(d.current) > 0 && g() !== Math.abs(d.current) && !u && !c &&
|
|
196
|
-
const r =
|
|
196
|
+
if (Math.abs(d.current) > 0 && g() !== Math.abs(d.current) && !u && !c && oe.current === "backward") {
|
|
197
|
+
const r = ie.current - g(), t = d.current + r;
|
|
197
198
|
return y.start({
|
|
198
199
|
immediate: !0,
|
|
199
200
|
val: t
|
|
@@ -237,7 +238,7 @@ function et({
|
|
|
237
238
|
]
|
|
238
239
|
);
|
|
239
240
|
function F() {
|
|
240
|
-
return c &&
|
|
241
|
+
return c && f.current ? f.current[o === "x" ? "scrollLeft" : "scrollTop"] : W.val.get();
|
|
241
242
|
}
|
|
242
243
|
function K(e, r) {
|
|
243
244
|
if (c && e === "next") {
|
|
@@ -251,16 +252,16 @@ function et({
|
|
|
251
252
|
return e === "next" ? typeof r == "number" ? -(r * s()) : d.current - s() : typeof r == "number" ? -(r * s()) : d.current + s();
|
|
252
253
|
}
|
|
253
254
|
function V({ type: e, index: r, immediate: t }) {
|
|
254
|
-
if (!v || R.current ||
|
|
255
|
+
if (!v || R.current || a.current && !u)
|
|
255
256
|
return;
|
|
256
|
-
l.current && (
|
|
257
|
+
l.current && (oe.current = "backward"), k.current = "prev", l.current = !1;
|
|
257
258
|
const i = typeof r == "number" ? r : p.current - 1;
|
|
258
|
-
if (c &&
|
|
259
|
+
if (c && te(), !u) {
|
|
259
260
|
const M = c ? K("prev", r) - s() / 3 < 0 : K("prev", r) + s() / 3 > 0;
|
|
260
|
-
if (
|
|
261
|
+
if (a.current)
|
|
261
262
|
return;
|
|
262
263
|
if (M) {
|
|
263
|
-
|
|
264
|
+
a.current = !0, l.current = !1, j({
|
|
264
265
|
slideMode: e,
|
|
265
266
|
from: F(),
|
|
266
267
|
to: 0,
|
|
@@ -270,8 +271,8 @@ function et({
|
|
|
270
271
|
return;
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
|
-
if (u && (
|
|
274
|
-
|
|
274
|
+
if (u && (a.current || i < 0)) {
|
|
275
|
+
a.current = !1, l.current = !0, j({
|
|
275
276
|
slideMode: e,
|
|
276
277
|
from: F() - s() * n.length,
|
|
277
278
|
to: -(s() * n.length) + s(),
|
|
@@ -280,7 +281,7 @@ function et({
|
|
|
280
281
|
});
|
|
281
282
|
return;
|
|
282
283
|
}
|
|
283
|
-
i === 0 && (
|
|
284
|
+
i === 0 && (a.current = !0), (i === n.length - 1 || i === -1) && (l.current = !0), j({
|
|
284
285
|
slideMode: e,
|
|
285
286
|
from: F(),
|
|
286
287
|
to: K("prev", r),
|
|
@@ -291,14 +292,14 @@ function et({
|
|
|
291
292
|
function D({ type: e, index: r, immediate: t }) {
|
|
292
293
|
if (!v || R.current || l.current && !u)
|
|
293
294
|
return;
|
|
294
|
-
|
|
295
|
+
a.current && (oe.current = "forward"), k.current = "next", a.current = !1;
|
|
295
296
|
const i = r || p.current + 1;
|
|
296
|
-
if (c &&
|
|
297
|
+
if (c && te(), !u) {
|
|
297
298
|
const M = Math.abs(K("next", r)) > g() - s() / 3;
|
|
298
299
|
if (l.current)
|
|
299
300
|
return;
|
|
300
301
|
if (M) {
|
|
301
|
-
|
|
302
|
+
a.current = !1, l.current = !0, j({
|
|
302
303
|
slideMode: e,
|
|
303
304
|
from: F(),
|
|
304
305
|
to: c ? g() : -g(),
|
|
@@ -309,7 +310,7 @@ function et({
|
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
312
|
if (u && (l.current || i > n.length - 1)) {
|
|
312
|
-
l.current = !1,
|
|
313
|
+
l.current = !1, a.current = !0, j({
|
|
313
314
|
slideMode: e,
|
|
314
315
|
from: F() + s() * n.length,
|
|
315
316
|
to: 0,
|
|
@@ -318,7 +319,7 @@ function et({
|
|
|
318
319
|
});
|
|
319
320
|
return;
|
|
320
321
|
}
|
|
321
|
-
i === 0 && (
|
|
322
|
+
i === 0 && (a.current = !0), i === n.length - 1 && (l.current = !0), j({
|
|
322
323
|
slideMode: e,
|
|
323
324
|
from: F(),
|
|
324
325
|
to: K("next", r),
|
|
@@ -327,16 +328,16 @@ function et({
|
|
|
327
328
|
});
|
|
328
329
|
}
|
|
329
330
|
function $e() {
|
|
330
|
-
|
|
331
|
+
re ? G.current = re : G.current = Math.floor(s() / 2 / 2);
|
|
331
332
|
}
|
|
332
|
-
function
|
|
333
|
-
x.current && (
|
|
333
|
+
function ye() {
|
|
334
|
+
x.current && (ie.current = g(), Te.current = u, we.current = I, Me.current = c, le.current = window.innerWidth, d.current = 0, se({ id: 0, immediate: !0, shouldReset: !0 }), $e(), ee());
|
|
334
335
|
}
|
|
335
|
-
const
|
|
336
|
+
const Ne = Oe(
|
|
336
337
|
(e) => {
|
|
337
|
-
const r = e.dragging, t = e.offset[o === "x" ? 0 : 1], i = e.movement[o === "x" ? 0 : 1], M = e.direction[o === "x" ? 0 : 1], B = i >
|
|
338
|
+
const r = e.dragging, t = e.offset[o === "x" ? 0 : 1], i = e.movement[o === "x" ? 0 : 1], M = e.direction[o === "x" ? 0 : 1], B = i > G.current, H = i < -G.current, De = g();
|
|
338
339
|
if (r) {
|
|
339
|
-
if (M > 0 ? k.current = "prev" : k.current = "next",
|
|
340
|
+
if (M > 0 ? k.current = "prev" : k.current = "next", A({
|
|
340
341
|
...e,
|
|
341
342
|
eventName: "onDrag",
|
|
342
343
|
slideActionType: k.current
|
|
@@ -379,7 +380,7 @@ function et({
|
|
|
379
380
|
friction: 50,
|
|
380
381
|
tension: 1e3
|
|
381
382
|
}
|
|
382
|
-
}), me && H ? (D({ type: "drag" }), e.cancel()) : me && B && (V({ type: "drag" }), e.cancel()),
|
|
383
|
+
}), me && H ? (D({ type: "drag" }), e.cancel()) : me && B && (V({ type: "drag" }), e.cancel()), De - Math.abs(t) < -(s() * 2) && e.cancel();
|
|
383
384
|
return;
|
|
384
385
|
}
|
|
385
386
|
if (e.last && c && t > 0) {
|
|
@@ -404,7 +405,7 @@ function et({
|
|
|
404
405
|
...Q.default,
|
|
405
406
|
velocity: e.velocity
|
|
406
407
|
}
|
|
407
|
-
}) : D({ type: "drag" }) : B ? !u &&
|
|
408
|
+
}) : D({ type: "drag" }) : B ? !u && a.current ? y.start({
|
|
408
409
|
val: 0,
|
|
409
410
|
config: {
|
|
410
411
|
...Q.default,
|
|
@@ -425,28 +426,28 @@ function et({
|
|
|
425
426
|
});
|
|
426
427
|
},
|
|
427
428
|
{
|
|
428
|
-
enabled: v && !
|
|
429
|
+
enabled: v && !he && !c || !!c && !!ne,
|
|
429
430
|
axis: o,
|
|
430
|
-
from: () => c &&
|
|
431
|
-
-
|
|
432
|
-
-
|
|
431
|
+
from: () => c && f.current ? [
|
|
432
|
+
-f.current.scrollLeft,
|
|
433
|
+
-f.current.scrollTop
|
|
433
434
|
] : o === "x" ? [W.val.get(), W.val.get()] : [W.val.get(), W.val.get()]
|
|
434
435
|
}
|
|
435
436
|
);
|
|
436
|
-
function
|
|
437
|
+
function We() {
|
|
437
438
|
return c ? o === "x" ? {
|
|
438
439
|
overflowX: "auto"
|
|
439
440
|
} : {
|
|
440
441
|
overflowY: "auto"
|
|
441
442
|
} : {};
|
|
442
443
|
}
|
|
443
|
-
function
|
|
444
|
-
|
|
444
|
+
function te() {
|
|
445
|
+
f.current && (d.current = f.current[o === "x" ? "scrollLeft" : "scrollTop"], f.current[o === "x" ? "scrollLeft" : "scrollTop"] === 0 && (a.current = !0, l.current = !1), f.current[o === "x" ? "scrollLeft" : "scrollTop"] > 0 && f.current[o === "x" ? "scrollLeft" : "scrollTop"] < g() && (a.current = !1, l.current = !1), f.current[o === "x" ? "scrollLeft" : "scrollTop"] === g() && (a.current = !1, l.current = !0));
|
|
445
446
|
}
|
|
446
|
-
function
|
|
447
|
+
function Pe() {
|
|
447
448
|
return c ? {
|
|
448
449
|
onWheel() {
|
|
449
|
-
W.val.stop(),
|
|
450
|
+
W.val.stop(), te();
|
|
450
451
|
}
|
|
451
452
|
} : {};
|
|
452
453
|
}
|
|
@@ -459,10 +460,10 @@ function et({
|
|
|
459
460
|
}
|
|
460
461
|
return t;
|
|
461
462
|
}
|
|
462
|
-
function
|
|
463
|
+
function se({ id: e, immediate: r, shouldReset: t, type: i }) {
|
|
463
464
|
if (!v || R.current)
|
|
464
465
|
return;
|
|
465
|
-
|
|
466
|
+
a.current = !1, l.current = !1;
|
|
466
467
|
const M = q(
|
|
467
468
|
e,
|
|
468
469
|
"The item you want to slide to doesn't exist; check the provided id."
|
|
@@ -480,25 +481,25 @@ function et({
|
|
|
480
481
|
immediate: r
|
|
481
482
|
});
|
|
482
483
|
}
|
|
483
|
-
function
|
|
484
|
+
function fe(e) {
|
|
484
485
|
const r = q(e, "The item doesn't exist; check the provided id."), t = p.current;
|
|
485
486
|
return u && t === n.length - 1 ? r === 0 : r === t + 1;
|
|
486
487
|
}
|
|
487
|
-
function
|
|
488
|
+
function ae(e) {
|
|
488
489
|
const r = q(e, "The item doesn't exist; check the provided id."), t = p.current;
|
|
489
490
|
return u && t === 0 ? r === n.length - 1 : r === t - 1;
|
|
490
491
|
}
|
|
491
|
-
function
|
|
492
|
+
function de(e) {
|
|
492
493
|
return q(e, "The item you want to check doesn't exist; check the provided id.") === p.current;
|
|
493
494
|
}
|
|
494
|
-
function
|
|
495
|
-
return
|
|
495
|
+
function Re() {
|
|
496
|
+
return he ? "unset" : o === "x" ? "pan-y" : "pan-x";
|
|
496
497
|
}
|
|
497
498
|
const b = c ? {
|
|
498
|
-
useListenToCustomEvent:
|
|
499
|
-
enterFullscreen:
|
|
500
|
-
exitFullscreen:
|
|
501
|
-
getIsFullscreen:
|
|
499
|
+
useListenToCustomEvent: S,
|
|
500
|
+
enterFullscreen: ve,
|
|
501
|
+
exitFullscreen: pe,
|
|
502
|
+
getIsFullscreen: xe,
|
|
502
503
|
slideToPrevItem: (e = !0) => {
|
|
503
504
|
V({
|
|
504
505
|
type: "click",
|
|
@@ -512,10 +513,10 @@ function et({
|
|
|
512
513
|
});
|
|
513
514
|
}
|
|
514
515
|
} : {
|
|
515
|
-
useListenToCustomEvent:
|
|
516
|
-
enterFullscreen:
|
|
517
|
-
exitFullscreen:
|
|
518
|
-
getIsFullscreen:
|
|
516
|
+
useListenToCustomEvent: S,
|
|
517
|
+
enterFullscreen: ve,
|
|
518
|
+
exitFullscreen: pe,
|
|
519
|
+
getIsFullscreen: xe,
|
|
519
520
|
slideToPrevItem: (e = !0) => {
|
|
520
521
|
V({
|
|
521
522
|
type: "click",
|
|
@@ -529,20 +530,20 @@ function et({
|
|
|
529
530
|
});
|
|
530
531
|
},
|
|
531
532
|
slideToItem: (e, r = !0) => {
|
|
532
|
-
|
|
533
|
+
se({ id: e, immediate: !r });
|
|
533
534
|
},
|
|
534
|
-
getIsNextItem:
|
|
535
|
-
getIsPrevItem:
|
|
536
|
-
getIsActiveItem:
|
|
535
|
+
getIsNextItem: fe,
|
|
536
|
+
getIsPrevItem: ae,
|
|
537
|
+
getIsActiveItem: de
|
|
537
538
|
};
|
|
538
|
-
|
|
539
|
-
x.current && v && (X.current = !0,
|
|
540
|
-
}, [v]),
|
|
541
|
-
p.current !== C && (X.current = !0,
|
|
539
|
+
ze(() => {
|
|
540
|
+
x.current && v && (X.current = !0, ye());
|
|
541
|
+
}, [v]), $(() => {
|
|
542
|
+
p.current !== C && (X.current = !0, se({
|
|
542
543
|
id: C,
|
|
543
|
-
immediate: !
|
|
544
|
+
immediate: !be
|
|
544
545
|
}));
|
|
545
|
-
}, [C]),
|
|
546
|
+
}, [C]), $(() => {
|
|
546
547
|
if (v) {
|
|
547
548
|
if (C > n.length - 1)
|
|
548
549
|
throw new Error(
|
|
@@ -552,31 +553,34 @@ function et({
|
|
|
552
553
|
`itemsPerSlide (${w}) is greater than the total quantity available items (${n.length}). Fallback to ${n.length})`
|
|
553
554
|
);
|
|
554
555
|
}
|
|
555
|
-
}, [C, n.length, w, v]),
|
|
556
|
-
|
|
557
|
-
}, []),
|
|
556
|
+
}, [C, n.length, w, v]), $(() => {
|
|
557
|
+
le.current = window.innerWidth;
|
|
558
|
+
}, []), $(() => {
|
|
558
559
|
if (v) {
|
|
559
560
|
if (u && c)
|
|
560
561
|
throw new Error("`withLoop` and `freeScroll` can't be used together.");
|
|
561
562
|
if (c && I === "fixed")
|
|
562
563
|
throw new Error("`freeScroll` can't be used when `scrollType=fixed`.");
|
|
563
|
-
if (
|
|
564
|
+
if (ne && (I !== "fluid" || !c))
|
|
564
565
|
throw new Error(
|
|
565
566
|
"`enableFreeScrollDrag` must be used with `slideType=fluid` and `freeScroll=true`"
|
|
566
567
|
);
|
|
567
|
-
|
|
568
|
+
if (_ && c)
|
|
569
|
+
throw new Error("`slideGroupOfItems` and `freeScroll` can't be used together.");
|
|
570
|
+
X.current = !0, ye();
|
|
568
571
|
}
|
|
569
572
|
}, [
|
|
570
573
|
Z,
|
|
571
574
|
w,
|
|
572
|
-
|
|
575
|
+
m,
|
|
573
576
|
T,
|
|
574
577
|
v,
|
|
575
578
|
u,
|
|
576
579
|
I,
|
|
577
580
|
c,
|
|
578
|
-
|
|
579
|
-
|
|
581
|
+
ne,
|
|
582
|
+
_
|
|
583
|
+
]), $(() => {
|
|
580
584
|
if (!v)
|
|
581
585
|
return;
|
|
582
586
|
function e() {
|
|
@@ -585,66 +589,66 @@ function et({
|
|
|
585
589
|
return document.addEventListener("visibilitychange", e), () => {
|
|
586
590
|
document.removeEventListener("visibilitychange", e);
|
|
587
591
|
};
|
|
588
|
-
}, [v]),
|
|
589
|
-
if (
|
|
592
|
+
}, [v]), $(() => {
|
|
593
|
+
if (f.current) {
|
|
590
594
|
let e;
|
|
591
|
-
const r = new
|
|
595
|
+
const r = new Je(() => {
|
|
592
596
|
if (!R.current && !X.current) {
|
|
593
|
-
|
|
594
|
-
const t =
|
|
597
|
+
le.current = window.innerWidth;
|
|
598
|
+
const t = ee();
|
|
595
599
|
window.clearTimeout(e), e = setTimeout(() => {
|
|
596
|
-
|
|
600
|
+
ie.current = g(), typeof t == "function" && t();
|
|
597
601
|
}, 100);
|
|
598
602
|
}
|
|
599
603
|
});
|
|
600
|
-
return r.observe(
|
|
604
|
+
return r.observe(f.current), () => {
|
|
601
605
|
r.disconnect();
|
|
602
606
|
};
|
|
603
607
|
}
|
|
604
|
-
}, [
|
|
605
|
-
|
|
608
|
+
}, [ee, g]), $(() => {
|
|
609
|
+
ce && ce({
|
|
606
610
|
slideToNextItem: b.slideToNextItem,
|
|
607
611
|
slideToPrevItem: b.slideToPrevItem,
|
|
608
612
|
slideToItem: b == null ? void 0 : b.slideToItem
|
|
609
613
|
});
|
|
610
|
-
}, [
|
|
611
|
-
const
|
|
614
|
+
}, [ce, b.slideToItem, b.slideToNextItem, b.slideToPrevItem]);
|
|
615
|
+
const je = /* @__PURE__ */ P.jsx(ge.Provider, { value: b, children: Ce }), Ve = /* @__PURE__ */ P.jsx(ge.Provider, { value: b, children: /* @__PURE__ */ P.jsx(
|
|
612
616
|
"div",
|
|
613
617
|
{
|
|
614
618
|
className: "use-spring-carousel-main-wrapper",
|
|
615
|
-
ref:
|
|
616
|
-
...
|
|
619
|
+
ref: f,
|
|
620
|
+
...Pe(),
|
|
617
621
|
style: {
|
|
618
622
|
display: "flex",
|
|
619
623
|
position: "relative",
|
|
620
624
|
width: "100%",
|
|
621
625
|
height: "100%",
|
|
622
|
-
...
|
|
626
|
+
...We()
|
|
623
627
|
},
|
|
624
628
|
children: /* @__PURE__ */ P.jsxs(
|
|
625
629
|
"div",
|
|
626
630
|
{
|
|
627
631
|
className: "use-spring-carousel-track-wrapper",
|
|
628
632
|
ref: x,
|
|
629
|
-
...
|
|
633
|
+
...Ne(),
|
|
630
634
|
style: {
|
|
631
635
|
position: "relative",
|
|
632
636
|
display: "flex",
|
|
633
637
|
flexDirection: o === "x" ? "row" : "column",
|
|
634
|
-
touchAction:
|
|
635
|
-
...
|
|
638
|
+
touchAction: Re(),
|
|
639
|
+
...Ee()
|
|
636
640
|
},
|
|
637
641
|
children: [
|
|
638
|
-
(c || !u) &&
|
|
642
|
+
(c || !u) && m ? /* @__PURE__ */ P.jsx(
|
|
639
643
|
"div",
|
|
640
644
|
{
|
|
641
645
|
style: {
|
|
642
646
|
flexShrink: 0,
|
|
643
|
-
width:
|
|
647
|
+
width: m
|
|
644
648
|
}
|
|
645
649
|
}
|
|
646
650
|
) : null,
|
|
647
|
-
|
|
651
|
+
L.map((e, r) => /* @__PURE__ */ P.jsx(
|
|
648
652
|
"div",
|
|
649
653
|
{
|
|
650
654
|
className: "use-spring-carousel-item",
|
|
@@ -653,27 +657,27 @@ function et({
|
|
|
653
657
|
display: "flex",
|
|
654
658
|
position: "relative",
|
|
655
659
|
flex: "1",
|
|
656
|
-
...
|
|
657
|
-
r ===
|
|
658
|
-
(t) => t.id ===
|
|
660
|
+
...Fe(
|
|
661
|
+
r === L.findIndex(
|
|
662
|
+
(t) => t.id === L[L.length - 1].id
|
|
659
663
|
)
|
|
660
664
|
)
|
|
661
665
|
},
|
|
662
666
|
children: typeof e.renderItem == "function" ? e.renderItem({
|
|
663
|
-
getIsActiveItem:
|
|
664
|
-
getIsNextItem:
|
|
665
|
-
getIsPrevItem:
|
|
666
|
-
useListenToCustomEvent:
|
|
667
|
+
getIsActiveItem: de,
|
|
668
|
+
getIsNextItem: fe,
|
|
669
|
+
getIsPrevItem: ae,
|
|
670
|
+
useListenToCustomEvent: S
|
|
667
671
|
}) : e.renderItem
|
|
668
672
|
},
|
|
669
673
|
`${e.id}-${r}`
|
|
670
674
|
)),
|
|
671
|
-
(c || !u) &&
|
|
675
|
+
(c || !u) && m ? /* @__PURE__ */ P.jsx(
|
|
672
676
|
"div",
|
|
673
677
|
{
|
|
674
678
|
style: {
|
|
675
679
|
flexShrink: 0,
|
|
676
|
-
width:
|
|
680
|
+
width: m
|
|
677
681
|
}
|
|
678
682
|
}
|
|
679
683
|
) : null
|
|
@@ -682,17 +686,17 @@ function et({
|
|
|
682
686
|
)
|
|
683
687
|
}
|
|
684
688
|
) });
|
|
685
|
-
return { ...b, carouselFragment:
|
|
689
|
+
return { ...b, carouselFragment: Ve, thumbsFragment: je };
|
|
686
690
|
}
|
|
687
|
-
const
|
|
688
|
-
function
|
|
689
|
-
const n =
|
|
691
|
+
const ge = Xe(void 0);
|
|
692
|
+
function rt() {
|
|
693
|
+
const n = Ye(ge);
|
|
690
694
|
if (!n)
|
|
691
695
|
throw new Error("useSpringCarouselContext must be used within the carousel.");
|
|
692
696
|
return n;
|
|
693
697
|
}
|
|
694
698
|
export {
|
|
695
|
-
|
|
696
|
-
|
|
699
|
+
tt as useSpringCarousel,
|
|
700
|
+
rt as useSpringCarouselContext
|
|
697
701
|
};
|
|
698
702
|
//# sourceMappingURL=index.es2.js.map
|