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