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

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