react-spring-carousel 3.0.0-beta090.3 → 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,65 +1,66 @@
|
|
|
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
|
-
onFullScreenChange:
|
|
10
|
-
handleResize:
|
|
9
|
+
onFullScreenChange: v,
|
|
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
|
|
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
|
-
enterFullscreen:
|
|
35
|
+
enterFullscreen: T,
|
|
36
36
|
exitFullscreen: u,
|
|
37
37
|
getIsFullscreen: I
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function tt({
|
|
41
41
|
items: n,
|
|
42
|
-
init:
|
|
43
|
-
withThumbs:
|
|
42
|
+
init: v = !0,
|
|
43
|
+
withThumbs: N,
|
|
44
44
|
thumbsSlideAxis: U = "x",
|
|
45
|
-
itemsPerSlide:
|
|
45
|
+
itemsPerSlide: O = 1,
|
|
46
46
|
slideType: I = "fixed",
|
|
47
|
-
gutter:
|
|
47
|
+
gutter: T = 0,
|
|
48
48
|
withLoop: u = !1,
|
|
49
|
-
startEndGutter:
|
|
49
|
+
startEndGutter: m = 0,
|
|
50
50
|
carouselSlideAxis: o = "x",
|
|
51
|
-
disableGestures:
|
|
52
|
-
draggingSlideTreshold:
|
|
53
|
-
slideWhenThresholdIsReached:
|
|
51
|
+
disableGestures: he = !1,
|
|
52
|
+
draggingSlideTreshold: re,
|
|
53
|
+
slideWhenThresholdIsReached: me = !1,
|
|
54
54
|
freeScroll: c,
|
|
55
|
-
enableFreeScrollDrag:
|
|
55
|
+
enableFreeScrollDrag: ne,
|
|
56
56
|
initialStartingPosition: Z,
|
|
57
|
-
prepareThumbsData:
|
|
58
|
-
initialActiveItem:
|
|
59
|
-
animateWhenActiveItemChange:
|
|
60
|
-
getControllerRef:
|
|
57
|
+
prepareThumbsData: Ie,
|
|
58
|
+
initialActiveItem: C = 0,
|
|
59
|
+
animateWhenActiveItemChange: be = !0,
|
|
60
|
+
getControllerRef: ce,
|
|
61
|
+
slideGroupOfItems: _ = !1
|
|
61
62
|
}) {
|
|
62
|
-
const
|
|
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,58 +70,58 @@ function et({
|
|
|
69
70
|
...e,
|
|
70
71
|
id: `next-repeated-item-${e.id}`
|
|
71
72
|
}))
|
|
72
|
-
] : [...n], [n, u])(), [
|
|
73
|
+
] : [...n], [n, u])(), [W, y] = He(
|
|
73
74
|
() => ({
|
|
74
75
|
val: 0,
|
|
75
|
-
pause: !
|
|
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
|
-
withThumbs: !!
|
|
82
|
+
), { emitEvent: A, useListenToCustomEvent: S } = qe(), { thumbsFragment: Ce, handleScroll: ke } = Be({
|
|
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
|
-
marginRight: `${e ? 0 :
|
|
105
|
-
flex: `1 0 calc(100% / ${
|
|
105
|
+
marginRight: `${e ? 0 : T}px`,
|
|
106
|
+
flex: `1 0 calc(100% / ${w} - ${T * (w - 1) / w}px)`
|
|
106
107
|
} : {
|
|
107
|
-
marginRight: `${e ? 0 :
|
|
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
|
-
return e.getBoundingClientRect()[o === "x" ? "width" : "height"] +
|
|
116
|
-
}, [o,
|
|
117
|
-
function j({ from: e, to: r, nextActiveItem: t, immediate: i = !1, slideMode:
|
|
118
|
-
|
|
116
|
+
return e.getBoundingClientRect()[o === "x" ? "width" : "height"] + T;
|
|
117
|
+
}, [o, T, _]);
|
|
118
|
+
function j({ from: e, to: r, nextActiveItem: t, immediate: i = !1, slideMode: M }) {
|
|
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
|
|
@@ -135,54 +136,54 @@ function et({
|
|
|
135
136
|
},
|
|
136
137
|
config: {
|
|
137
138
|
...Q.default,
|
|
138
|
-
velocity:
|
|
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
|
-
}),
|
|
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
|
-
return e.getBoundingClientRect()[o === "x" ? "width" : "height"] +
|
|
176
|
-
}, [o,
|
|
176
|
+
return e.getBoundingClientRect()[o === "x" ? "width" : "height"] + T;
|
|
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
|
-
Z === "center" ? Y() * n.length - s() * Math.round((
|
|
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
|
|
186
187
|
), I === "fluid") {
|
|
187
188
|
if (J(Y() * n.length), l.current && g() !== Math.abs(d.current) && !u) {
|
|
188
189
|
const r = -g();
|
|
@@ -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
|
|
@@ -229,15 +230,15 @@ function et({
|
|
|
229
230
|
g,
|
|
230
231
|
Z,
|
|
231
232
|
n.length,
|
|
232
|
-
|
|
233
|
+
w,
|
|
233
234
|
J,
|
|
234
235
|
y,
|
|
235
236
|
I,
|
|
236
237
|
u
|
|
237
238
|
]
|
|
238
239
|
);
|
|
239
|
-
function
|
|
240
|
-
return c &&
|
|
240
|
+
function F() {
|
|
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,18 +252,18 @@ 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 (!
|
|
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
|
-
const
|
|
260
|
-
if (
|
|
259
|
+
if (c && te(), !u) {
|
|
260
|
+
const M = c ? K("prev", r) - s() / 3 < 0 : K("prev", r) + s() / 3 > 0;
|
|
261
|
+
if (a.current)
|
|
261
262
|
return;
|
|
262
|
-
if (
|
|
263
|
-
|
|
263
|
+
if (M) {
|
|
264
|
+
a.current = !0, l.current = !1, j({
|
|
264
265
|
slideMode: e,
|
|
265
|
-
from:
|
|
266
|
+
from: F(),
|
|
266
267
|
to: 0,
|
|
267
268
|
nextActiveItem: 0,
|
|
268
269
|
immediate: t
|
|
@@ -270,37 +271,37 @@ 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
|
-
from:
|
|
277
|
+
from: F() - s() * n.length,
|
|
277
278
|
to: -(s() * n.length) + s(),
|
|
278
279
|
nextActiveItem: n.length - 1,
|
|
279
280
|
immediate: t
|
|
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
|
-
from:
|
|
286
|
+
from: F(),
|
|
286
287
|
to: K("prev", r),
|
|
287
288
|
nextActiveItem: i,
|
|
288
289
|
immediate: t
|
|
289
290
|
});
|
|
290
291
|
}
|
|
291
292
|
function D({ type: e, index: r, immediate: t }) {
|
|
292
|
-
if (!
|
|
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
|
-
const
|
|
297
|
+
if (c && te(), !u) {
|
|
298
|
+
const M = Math.abs(K("next", r)) > g() - s() / 3;
|
|
298
299
|
if (l.current)
|
|
299
300
|
return;
|
|
300
|
-
if (
|
|
301
|
-
|
|
301
|
+
if (M) {
|
|
302
|
+
a.current = !1, l.current = !0, j({
|
|
302
303
|
slideMode: e,
|
|
303
|
-
from:
|
|
304
|
+
from: F(),
|
|
304
305
|
to: c ? g() : -g(),
|
|
305
306
|
nextActiveItem: i,
|
|
306
307
|
immediate: t
|
|
@@ -309,34 +310,34 @@ 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
|
-
from:
|
|
315
|
+
from: F() + s() * n.length,
|
|
315
316
|
to: 0,
|
|
316
317
|
nextActiveItem: 0,
|
|
317
318
|
immediate: t
|
|
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
|
-
from:
|
|
324
|
+
from: F(),
|
|
324
325
|
to: K("next", r),
|
|
325
326
|
nextActiveItem: i,
|
|
326
327
|
immediate: t
|
|
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
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],
|
|
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 (
|
|
340
|
+
if (M > 0 ? k.current = "prev" : k.current = "next", A({
|
|
340
341
|
...e,
|
|
341
342
|
eventName: "onDrag",
|
|
342
343
|
slideActionType: k.current
|
|
@@ -344,7 +345,7 @@ function et({
|
|
|
344
345
|
if (t > 0) {
|
|
345
346
|
y.start({
|
|
346
347
|
from: {
|
|
347
|
-
val:
|
|
348
|
+
val: F()
|
|
348
349
|
},
|
|
349
350
|
to: {
|
|
350
351
|
val: 0
|
|
@@ -359,7 +360,7 @@ function et({
|
|
|
359
360
|
}
|
|
360
361
|
y.start({
|
|
361
362
|
from: {
|
|
362
|
-
val:
|
|
363
|
+
val: F()
|
|
363
364
|
},
|
|
364
365
|
to: {
|
|
365
366
|
val: -t
|
|
@@ -379,13 +380,13 @@ function et({
|
|
|
379
380
|
friction: 50,
|
|
380
381
|
tension: 1e3
|
|
381
382
|
}
|
|
382
|
-
}),
|
|
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) {
|
|
386
387
|
y.start({
|
|
387
388
|
from: {
|
|
388
|
-
val:
|
|
389
|
+
val: F()
|
|
389
390
|
},
|
|
390
391
|
to: {
|
|
391
392
|
val: 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,12 +426,12 @@ function et({
|
|
|
425
426
|
});
|
|
426
427
|
},
|
|
427
428
|
{
|
|
428
|
-
enabled:
|
|
429
|
+
enabled: v && !he && !c || !!c && !!ne,
|
|
429
430
|
axis: o,
|
|
430
|
-
from: () => c &&
|
|
431
|
-
-
|
|
432
|
-
-
|
|
433
|
-
] : o === "x" ? [
|
|
431
|
+
from: () => c && f.current ? [
|
|
432
|
+
-f.current.scrollLeft,
|
|
433
|
+
-f.current.scrollTop
|
|
434
|
+
] : o === "x" ? [W.val.get(), W.val.get()] : [W.val.get(), W.val.get()]
|
|
434
435
|
}
|
|
435
436
|
);
|
|
436
437
|
function We() {
|
|
@@ -440,13 +441,13 @@ function et({
|
|
|
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
|
-
|
|
450
|
+
W.val.stop(), te();
|
|
450
451
|
}
|
|
451
452
|
} : {};
|
|
452
453
|
}
|
|
@@ -459,17 +460,17 @@ function et({
|
|
|
459
460
|
}
|
|
460
461
|
return t;
|
|
461
462
|
}
|
|
462
|
-
function
|
|
463
|
-
if (!
|
|
463
|
+
function se({ id: e, immediate: r, shouldReset: t, type: i }) {
|
|
464
|
+
if (!v || R.current)
|
|
464
465
|
return;
|
|
465
|
-
|
|
466
|
-
const
|
|
466
|
+
a.current = !1, l.current = !1;
|
|
467
|
+
const M = q(
|
|
467
468
|
e,
|
|
468
469
|
"The item you want to slide to doesn't exist; check the provided id."
|
|
469
470
|
);
|
|
470
|
-
if (
|
|
471
|
+
if (M === p.current && !t)
|
|
471
472
|
return;
|
|
472
|
-
const B = q(n[p.current].id), H = q(n[
|
|
473
|
+
const B = q(n[p.current].id), H = q(n[M].id);
|
|
473
474
|
H > B ? D({
|
|
474
475
|
type: i || t ? "initial" : "click",
|
|
475
476
|
index: H,
|
|
@@ -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
|
-
const
|
|
498
|
-
useListenToCustomEvent:
|
|
499
|
-
enterFullscreen:
|
|
500
|
-
exitFullscreen:
|
|
501
|
-
getIsFullscreen:
|
|
498
|
+
const b = c ? {
|
|
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,35 +530,58 @@ 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 &&
|
|
540
|
-
}, [
|
|
541
|
-
p.current !==
|
|
542
|
-
id:
|
|
543
|
-
immediate: !
|
|
539
|
+
ze(() => {
|
|
540
|
+
x.current && v && (X.current = !0, ye());
|
|
541
|
+
}, [v]), $(() => {
|
|
542
|
+
p.current !== C && (X.current = !0, se({
|
|
543
|
+
id: C,
|
|
544
|
+
immediate: !be
|
|
544
545
|
}));
|
|
545
|
-
}, [
|
|
546
|
-
if (
|
|
547
|
-
if (
|
|
546
|
+
}, [C]), $(() => {
|
|
547
|
+
if (v) {
|
|
548
|
+
if (C > n.length - 1)
|
|
548
549
|
throw new Error(
|
|
549
|
-
`initialActiveItem (${
|
|
550
|
+
`initialActiveItem (${C}) is greater than the total quantity available items (${n.length}).`
|
|
550
551
|
);
|
|
551
|
-
|
|
552
|
-
`itemsPerSlide (${
|
|
552
|
+
w > n.length && console.warn(
|
|
553
|
+
`itemsPerSlide (${w}) is greater than the total quantity available items (${n.length}). Fallback to ${n.length})`
|
|
553
554
|
);
|
|
554
555
|
}
|
|
555
|
-
}, [
|
|
556
|
-
|
|
557
|
-
}, []),
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
556
|
+
}, [C, n.length, w, v]), $(() => {
|
|
557
|
+
le.current = window.innerWidth;
|
|
558
|
+
}, []), $(() => {
|
|
559
|
+
if (v) {
|
|
560
|
+
if (u && c)
|
|
561
|
+
throw new Error("`withLoop` and `freeScroll` can't be used together.");
|
|
562
|
+
if (c && I === "fixed")
|
|
563
|
+
throw new Error("`freeScroll` can't be used when `scrollType=fixed`.");
|
|
564
|
+
if (ne && (I !== "fluid" || !c))
|
|
565
|
+
throw new Error(
|
|
566
|
+
"`enableFreeScrollDrag` must be used with `slideType=fluid` and `freeScroll=true`"
|
|
567
|
+
);
|
|
568
|
+
if (_ && c)
|
|
569
|
+
throw new Error("`slideGroupOfItems` and `freeScroll` can't be used together.");
|
|
570
|
+
X.current = !0, ye();
|
|
571
|
+
}
|
|
572
|
+
}, [
|
|
573
|
+
Z,
|
|
574
|
+
w,
|
|
575
|
+
m,
|
|
576
|
+
T,
|
|
577
|
+
v,
|
|
578
|
+
u,
|
|
579
|
+
I,
|
|
580
|
+
c,
|
|
581
|
+
ne,
|
|
582
|
+
_
|
|
583
|
+
]), $(() => {
|
|
584
|
+
if (!v)
|
|
561
585
|
return;
|
|
562
586
|
function e() {
|
|
563
587
|
document.hidden ? R.current = !0 : R.current = !1;
|
|
@@ -565,35 +589,35 @@ function et({
|
|
|
565
589
|
return document.addEventListener("visibilitychange", e), () => {
|
|
566
590
|
document.removeEventListener("visibilitychange", e);
|
|
567
591
|
};
|
|
568
|
-
}, [
|
|
569
|
-
if (
|
|
592
|
+
}, [v]), $(() => {
|
|
593
|
+
if (f.current) {
|
|
570
594
|
let e;
|
|
571
|
-
const r = new
|
|
595
|
+
const r = new Je(() => {
|
|
572
596
|
if (!R.current && !X.current) {
|
|
573
|
-
|
|
574
|
-
const t =
|
|
597
|
+
le.current = window.innerWidth;
|
|
598
|
+
const t = ee();
|
|
575
599
|
window.clearTimeout(e), e = setTimeout(() => {
|
|
576
|
-
|
|
600
|
+
ie.current = g(), typeof t == "function" && t();
|
|
577
601
|
}, 100);
|
|
578
602
|
}
|
|
579
603
|
});
|
|
580
|
-
return r.observe(
|
|
604
|
+
return r.observe(f.current), () => {
|
|
581
605
|
r.disconnect();
|
|
582
606
|
};
|
|
583
607
|
}
|
|
584
|
-
}, [
|
|
585
|
-
|
|
586
|
-
slideToNextItem:
|
|
587
|
-
slideToPrevItem:
|
|
588
|
-
slideToItem:
|
|
608
|
+
}, [ee, g]), $(() => {
|
|
609
|
+
ce && ce({
|
|
610
|
+
slideToNextItem: b.slideToNextItem,
|
|
611
|
+
slideToPrevItem: b.slideToPrevItem,
|
|
612
|
+
slideToItem: b == null ? void 0 : b.slideToItem
|
|
589
613
|
});
|
|
590
|
-
}, [
|
|
591
|
-
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(
|
|
592
616
|
"div",
|
|
593
617
|
{
|
|
594
618
|
className: "use-spring-carousel-main-wrapper",
|
|
595
|
-
ref:
|
|
596
|
-
...
|
|
619
|
+
ref: f,
|
|
620
|
+
...Pe(),
|
|
597
621
|
style: {
|
|
598
622
|
display: "flex",
|
|
599
623
|
position: "relative",
|
|
@@ -611,20 +635,20 @@ function et({
|
|
|
611
635
|
position: "relative",
|
|
612
636
|
display: "flex",
|
|
613
637
|
flexDirection: o === "x" ? "row" : "column",
|
|
614
|
-
touchAction:
|
|
615
|
-
...
|
|
638
|
+
touchAction: Re(),
|
|
639
|
+
...Ee()
|
|
616
640
|
},
|
|
617
641
|
children: [
|
|
618
|
-
(c || !u) &&
|
|
642
|
+
(c || !u) && m ? /* @__PURE__ */ P.jsx(
|
|
619
643
|
"div",
|
|
620
644
|
{
|
|
621
645
|
style: {
|
|
622
646
|
flexShrink: 0,
|
|
623
|
-
width:
|
|
647
|
+
width: m
|
|
624
648
|
}
|
|
625
649
|
}
|
|
626
650
|
) : null,
|
|
627
|
-
|
|
651
|
+
L.map((e, r) => /* @__PURE__ */ P.jsx(
|
|
628
652
|
"div",
|
|
629
653
|
{
|
|
630
654
|
className: "use-spring-carousel-item",
|
|
@@ -633,27 +657,27 @@ function et({
|
|
|
633
657
|
display: "flex",
|
|
634
658
|
position: "relative",
|
|
635
659
|
flex: "1",
|
|
636
|
-
...
|
|
637
|
-
r ===
|
|
638
|
-
(t) => t.id ===
|
|
660
|
+
...Fe(
|
|
661
|
+
r === L.findIndex(
|
|
662
|
+
(t) => t.id === L[L.length - 1].id
|
|
639
663
|
)
|
|
640
664
|
)
|
|
641
665
|
},
|
|
642
666
|
children: typeof e.renderItem == "function" ? e.renderItem({
|
|
643
|
-
getIsActiveItem:
|
|
644
|
-
getIsNextItem:
|
|
645
|
-
getIsPrevItem:
|
|
646
|
-
useListenToCustomEvent:
|
|
667
|
+
getIsActiveItem: de,
|
|
668
|
+
getIsNextItem: fe,
|
|
669
|
+
getIsPrevItem: ae,
|
|
670
|
+
useListenToCustomEvent: S
|
|
647
671
|
}) : e.renderItem
|
|
648
672
|
},
|
|
649
673
|
`${e.id}-${r}`
|
|
650
674
|
)),
|
|
651
|
-
(c || !u) &&
|
|
675
|
+
(c || !u) && m ? /* @__PURE__ */ P.jsx(
|
|
652
676
|
"div",
|
|
653
677
|
{
|
|
654
678
|
style: {
|
|
655
679
|
flexShrink: 0,
|
|
656
|
-
width:
|
|
680
|
+
width: m
|
|
657
681
|
}
|
|
658
682
|
}
|
|
659
683
|
) : null
|
|
@@ -662,17 +686,17 @@ function et({
|
|
|
662
686
|
)
|
|
663
687
|
}
|
|
664
688
|
) });
|
|
665
|
-
return { ...
|
|
689
|
+
return { ...b, carouselFragment: Ve, thumbsFragment: je };
|
|
666
690
|
}
|
|
667
|
-
const
|
|
668
|
-
function
|
|
669
|
-
const n =
|
|
691
|
+
const ge = Xe(void 0);
|
|
692
|
+
function rt() {
|
|
693
|
+
const n = Ye(ge);
|
|
670
694
|
if (!n)
|
|
671
695
|
throw new Error("useSpringCarouselContext must be used within the carousel.");
|
|
672
696
|
return n;
|
|
673
697
|
}
|
|
674
698
|
export {
|
|
675
|
-
|
|
676
|
-
|
|
699
|
+
tt as useSpringCarousel,
|
|
700
|
+
rt as useSpringCarouselContext
|
|
677
701
|
};
|
|
678
702
|
//# sourceMappingURL=index.es2.js.map
|