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