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

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