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