react-spring-carousel 3.0.0-beta090.1 → 3.0.0-beta090.3

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