react-spring-carousel 3.0.0-beta003 → 3.0.0-beta006

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/umd/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('@react-spring/web'), require('react'), require('@use-gesture/react'), require('screenfull')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', '@react-spring/web', 'react', '@use-gesture/react', 'screenfull'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactSpringCarousel = {}, global.ReactJSXRuntime, global.web, global.React, global.UseGestureReact, global.Screenfull));
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactSpringCarousel = {}, global.ReactJSXRuntime, global.ReactSpring, global.React, global.UseGestureReact, global.Screenfull));
5
5
  })(this, (function (exports, jsxRuntime, web, react, react$1, screenfull) { 'use strict';
6
6
 
7
- const eventLabel = "RSC::Event";
7
+ const eventLabel = 'RSC::Event';
8
8
  function useEventsModule() {
9
9
  const targetEvent = react.useRef(null);
10
10
  react.useEffect(() => {
11
- targetEvent.current = document.createElement("div");
11
+ targetEvent.current = document.createElement('div');
12
12
  }, []);
13
13
  function useListenToCustomEvent(eventHandler) {
14
14
  react.useEffect(() => {
@@ -47,7 +47,7 @@
47
47
  if (document.fullscreenElement) {
48
48
  setIsFullscreen(true);
49
49
  emitEvent({
50
- eventName: "onFullscreenChange",
50
+ eventName: 'onFullscreenChange',
51
51
  isFullscreen: true,
52
52
  });
53
53
  handleResize && handleResize();
@@ -55,17 +55,17 @@
55
55
  if (!document.fullscreenElement) {
56
56
  setIsFullscreen(false);
57
57
  emitEvent({
58
- eventName: "onFullscreenChange",
58
+ eventName: 'onFullscreenChange',
59
59
  isFullscreen: false,
60
60
  });
61
61
  handleResize && handleResize();
62
62
  }
63
63
  }
64
64
  if (screenfull.isEnabled) {
65
- screenfull.on("change", handleFullscreenChange);
65
+ screenfull.on('change', handleFullscreenChange);
66
66
  return () => {
67
67
  if (screenfull.isEnabled) {
68
- screenfull.off("change", handleFullscreenChange);
68
+ screenfull.off('change', handleFullscreenChange);
69
69
  }
70
70
  };
71
71
  }
@@ -95,19 +95,18 @@
95
95
  const rect = el.getBoundingClientRect();
96
96
  return (rect.top >= 0 &&
97
97
  rect.left >= 0 &&
98
- rect.bottom <=
99
- (window.innerHeight || document.documentElement.clientHeight) &&
98
+ rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
100
99
  rect.right <= (window.innerWidth || document.documentElement.clientWidth));
101
100
  }
102
- function useThumbsModule({ thumbsSlideAxis = "x", withThumbs = false, prepareThumbsData, items, }) {
101
+ function useThumbsModule({ thumbsSlideAxis = 'x', withThumbs = false, prepareThumbsData, items, }) {
103
102
  const wrapperRef = react.useRef(null);
104
103
  const [spring, setSpring] = web.useSpring(() => ({
105
104
  val: 0,
106
105
  }));
107
106
  function getTotalScrollValue() {
108
107
  var _a;
109
- return Math.round(Number((_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a[thumbsSlideAxis === "x" ? "scrollWidth" : "scrollHeight"]) -
110
- wrapperRef.current.getBoundingClientRect()[thumbsSlideAxis === "x" ? "width" : "height"]);
108
+ return Math.round(Number((_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a[thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight']) -
109
+ wrapperRef.current.getBoundingClientRect()[thumbsSlideAxis === 'x' ? 'width' : 'height']);
111
110
  }
112
111
  function handleScroll(activeItem) {
113
112
  var _a, _b;
@@ -124,14 +123,15 @@
124
123
  const val = offset > getTotalScrollValue() ? getTotalScrollValue() : offset;
125
124
  setSpring.start({
126
125
  from: {
127
- val: (_b = (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a[thumbsSlideAxis === "x" ? "scrollLeft" : "scrollTop"]) !== null && _b !== void 0 ? _b : 0,
126
+ val: (_b = (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a[thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop']) !== null && _b !== void 0 ? _b : 0,
128
127
  },
129
128
  to: {
130
129
  val,
131
130
  },
132
131
  onChange: ({ value }) => {
133
132
  if (wrapperRef.current) {
134
- wrapperRef.current[thumbsSlideAxis === "x" ? "scrollLeft" : "scrollTop"] = Math.abs(value.val);
133
+ wrapperRef.current[thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'] =
134
+ Math.abs(value.val);
135
135
  }
136
136
  },
137
137
  });
@@ -140,7 +140,7 @@
140
140
  }
141
141
  function handlePrepareThumbsData() {
142
142
  function getPreparedItems(_items) {
143
- return _items.map((i) => ({
143
+ return _items.map(i => ({
144
144
  id: i.id,
145
145
  renderThumb: i.renderThumb,
146
146
  }));
@@ -150,11 +150,11 @@
150
150
  }
151
151
  return getPreparedItems(items);
152
152
  }
153
- const thumbsFragment = withThumbs ? (jsxRuntime.jsx("div", Object.assign({ className: "use-spring-carousel-thumbs-wrapper", ref: wrapperRef, onWheel: () => spring.val.stop(), style: Object.assign({ display: "flex", flex: "1", position: "relative", width: "100%", height: "100%", flexDirection: thumbsSlideAxis === "x" ? "row" : "column" }, (thumbsSlideAxis === "x"
154
- ? { overflowX: "auto" }
153
+ const thumbsFragment = withThumbs ? (jsxRuntime.jsx("div", Object.assign({ className: "use-spring-carousel-thumbs-wrapper", ref: wrapperRef, onWheel: () => spring.val.stop(), style: Object.assign({ display: 'flex', flex: '1', position: 'relative', width: '100%', height: '100%', flexDirection: thumbsSlideAxis === 'x' ? 'row' : 'column' }, (thumbsSlideAxis === 'x'
154
+ ? { overflowX: 'auto' }
155
155
  : {
156
- overflowY: "auto",
157
- maxHeight: "100%",
156
+ overflowY: 'auto',
157
+ maxHeight: '100%',
158
158
  })) }, { children: handlePrepareThumbsData().map(({ id, renderThumb }) => {
159
159
  const thumbId = `thumb-item-${id}`;
160
160
  return (jsxRuntime.jsx("div", Object.assign({ id: thumbId, className: "thumb-item" }, { children: renderThumb }), thumbId));
@@ -165,11 +165,11 @@
165
165
  };
166
166
  }
167
167
 
168
- function useSpringCarousel({ items, init = true, withThumbs, thumbsSlideAxis = "x", itemsPerSlide = 1, slideType = "fixed", gutter = 0, withLoop = false, startEndGutter = 0, carouselSlideAxis = "x", disableGestures = false, draggingSlideTreshold: _draggingSlideTreshold, slideWhenThresholdIsReached = false, freeScroll, enableFreeScrollDrag, initialStartingPosition, prepareThumbsData, initialActiveItem = 0, }) {
168
+ function useSpringCarousel({ items, init = true, withThumbs, thumbsSlideAxis = 'x', itemsPerSlide = 1, slideType = 'fixed', gutter = 0, withLoop = false, startEndGutter = 0, carouselSlideAxis = 'x', disableGestures = false, draggingSlideTreshold: _draggingSlideTreshold, slideWhenThresholdIsReached = false, freeScroll, enableFreeScrollDrag, initialStartingPosition, prepareThumbsData, initialActiveItem = 0, }) {
169
169
  const prevWindowWidth = react.useRef(0);
170
170
  const draggingSlideTreshold = react.useRef(_draggingSlideTreshold !== null && _draggingSlideTreshold !== void 0 ? _draggingSlideTreshold : 0);
171
- const slideActionType = react.useRef("initial");
172
- const slideModeType = react.useRef("initial");
171
+ const slideActionType = react.useRef('initial');
172
+ const slideModeType = react.useRef('initial');
173
173
  const prevSlidedValue = react.useRef(0);
174
174
  const [spring, setSpring] = web.useSpring(() => ({
175
175
  val: 0,
@@ -177,7 +177,7 @@
177
177
  onChange({ value }) {
178
178
  if (freeScroll && mainCarouselWrapperRef.current) {
179
179
  setStartEndItemReachedOnFreeScroll();
180
- if (carouselSlideAxis === "x") {
180
+ if (carouselSlideAxis === 'x') {
181
181
  mainCarouselWrapperRef.current.scrollLeft = Math.abs(value.val);
182
182
  }
183
183
  else {
@@ -185,7 +185,7 @@
185
185
  }
186
186
  }
187
187
  else if (carouselTrackWrapperRef.current) {
188
- if (carouselSlideAxis === "x") {
188
+ if (carouselSlideAxis === 'x') {
189
189
  carouselTrackWrapperRef.current.style.transform = `translate3d(${value.val}px, 0px,0px)`;
190
190
  }
191
191
  else {
@@ -202,9 +202,9 @@
202
202
  const getItems = react.useCallback(() => {
203
203
  if (withLoop) {
204
204
  return [
205
- ...items.map((i) => (Object.assign(Object.assign({}, i), { id: `prev-repeated-item-${i.id}` }))),
205
+ ...items.map(i => (Object.assign(Object.assign({}, i), { id: `prev-repeated-item-${i.id}` }))),
206
206
  ...items,
207
- ...items.map((i) => (Object.assign(Object.assign({}, i), { id: `next-repeated-item-${i.id}` }))),
207
+ ...items.map(i => (Object.assign(Object.assign({}, i), { id: `next-repeated-item-${i.id}` }))),
208
208
  ];
209
209
  }
210
210
  return [...items];
@@ -223,7 +223,7 @@
223
223
  handleResize: () => adjustCarouselWrapperPosition(),
224
224
  });
225
225
  function getItemStyles() {
226
- if (slideType === "fixed" && !freeScroll) {
226
+ if (slideType === 'fixed' && !freeScroll) {
227
227
  return {
228
228
  marginRight: `${gutter}px`,
229
229
  flex: `1 0 calc(100% / ${itemsPerSlide} - ${(gutter * (itemsPerSlide - 1)) / itemsPerSlide}px)`,
@@ -233,27 +233,27 @@
233
233
  }
234
234
  function getSlideValue() {
235
235
  var _a;
236
- const carouselItem = (_a = mainCarouselWrapperRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".use-spring-carousel-item");
236
+ const carouselItem = (_a = mainCarouselWrapperRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.use-spring-carousel-item');
237
237
  if (!carouselItem) {
238
- throw Error("No carousel items available!");
238
+ throw Error('No carousel items available!');
239
239
  }
240
- return (carouselItem.getBoundingClientRect()[carouselSlideAxis === "x" ? "width" : "height"] + gutter);
240
+ return (carouselItem.getBoundingClientRect()[carouselSlideAxis === 'x' ? 'width' : 'height'] + gutter);
241
241
  }
242
242
  function slideToItem({ from, to, nextActiveItem, immediate = false, slideMode, }) {
243
243
  slideModeType.current = slideMode;
244
- if (typeof nextActiveItem === "number") {
244
+ if (typeof nextActiveItem === 'number') {
245
245
  if (!freeScroll) {
246
246
  activeItem.current = nextActiveItem;
247
247
  }
248
248
  emitEvent({
249
- eventName: "onSlideStartChange",
249
+ eventName: 'onSlideStartChange',
250
250
  slideActionType: slideActionType.current,
251
251
  slideMode: slideModeType.current,
252
252
  nextItem: {
253
253
  startReached: firstItemReached.current,
254
254
  endReached: lastItemReached.current,
255
255
  index: freeScroll ? -1 : activeItem.current,
256
- id: freeScroll ? "" : items[activeItem.current].id,
256
+ id: freeScroll ? '' : items[activeItem.current].id,
257
257
  },
258
258
  });
259
259
  }
@@ -270,14 +270,14 @@
270
270
  onRest(value) {
271
271
  if (!immediate && value.finished) {
272
272
  emitEvent({
273
- eventName: "onSlideChange",
273
+ eventName: 'onSlideChange',
274
274
  slideActionType: slideActionType.current,
275
275
  slideMode: slideModeType.current,
276
276
  currentItem: {
277
277
  startReached: firstItemReached.current,
278
278
  endReached: lastItemReached.current,
279
279
  index: freeScroll ? -1 : activeItem.current,
280
- id: freeScroll ? "" : items[activeItem.current].id,
280
+ id: freeScroll ? '' : items[activeItem.current].id,
281
281
  },
282
282
  });
283
283
  }
@@ -292,38 +292,38 @@
292
292
  if (withLoop) {
293
293
  return getSlideValue() * items.length;
294
294
  }
295
- return Math.round(Number((_a = carouselTrackWrapperRef.current) === null || _a === void 0 ? void 0 : _a[carouselSlideAxis === "x" ? "scrollWidth" : "scrollHeight"]) -
296
- carouselTrackWrapperRef.current.getBoundingClientRect()[carouselSlideAxis === "x" ? "width" : "height"]);
295
+ return Math.round(Number((_a = carouselTrackWrapperRef.current) === null || _a === void 0 ? void 0 : _a[carouselSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight']) -
296
+ carouselTrackWrapperRef.current.getBoundingClientRect()[carouselSlideAxis === 'x' ? 'width' : 'height']);
297
297
  }
298
298
  function getAnimatedWrapperStyles() {
299
299
  const percentValue = `calc(100% - ${startEndGutter * 2}px)`;
300
300
  return {
301
- width: carouselSlideAxis === "x" ? percentValue : "100%",
302
- height: carouselSlideAxis === "y" ? percentValue : "100%",
301
+ width: carouselSlideAxis === 'x' ? percentValue : '100%',
302
+ height: carouselSlideAxis === 'y' ? percentValue : '100%',
303
303
  };
304
304
  }
305
305
  function getCarouselItemWidth() {
306
306
  var _a;
307
- const carouselItem = (_a = carouselTrackWrapperRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".use-spring-carousel-item");
307
+ const carouselItem = (_a = carouselTrackWrapperRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.use-spring-carousel-item');
308
308
  if (!carouselItem) {
309
- throw Error("No carousel items available!");
309
+ throw Error('No carousel items available!');
310
310
  }
311
- return (carouselItem.getBoundingClientRect()[carouselSlideAxis === "x" ? "width" : "height"] + gutter);
311
+ return (carouselItem.getBoundingClientRect()[carouselSlideAxis === 'x' ? 'width' : 'height'] + gutter);
312
312
  }
313
313
  function adjustCarouselWrapperPosition() {
314
- const positionProperty = carouselSlideAxis === "x" ? "left" : "top";
314
+ const positionProperty = carouselSlideAxis === 'x' ? 'left' : 'top';
315
315
  function setPosition(v) {
316
316
  const ref = carouselTrackWrapperRef.current;
317
317
  if (!ref)
318
318
  return;
319
319
  if (withLoop) {
320
- ref.style.top = "0px";
321
- ref.style.left = "0px";
320
+ ref.style.top = '0px';
321
+ ref.style.left = '0px';
322
322
  ref.style[positionProperty] = `-${v - startEndGutter}px`;
323
323
  }
324
324
  else {
325
- ref.style.left = "0px";
326
- ref.style.top = "0px";
325
+ ref.style.left = '0px';
326
+ ref.style.top = '0px';
327
327
  }
328
328
  }
329
329
  const currentFromValue = Math.abs(getFromValue());
@@ -340,18 +340,18 @@
340
340
  });
341
341
  return;
342
342
  }
343
- if (initialStartingPosition === "center") {
343
+ if (initialStartingPosition === 'center') {
344
344
  setPosition(getCarouselItemWidth() * items.length -
345
345
  getSlideValue() * Math.round((itemsPerSlide - 1) / 2));
346
346
  }
347
- else if (initialStartingPosition === "end") {
347
+ else if (initialStartingPosition === 'end') {
348
348
  setPosition(getCarouselItemWidth() * items.length -
349
349
  getSlideValue() * Math.round(itemsPerSlide - 1));
350
350
  }
351
351
  else {
352
352
  setPosition(getCarouselItemWidth() * items.length);
353
353
  }
354
- if (!freeScroll && slideType === "fixed") {
354
+ if (!freeScroll && slideType === 'fixed') {
355
355
  const val = -(getSlideValue() * activeItem.current);
356
356
  prevSlidedValue.current = val;
357
357
  setSpring.start({
@@ -362,26 +362,26 @@
362
362
  }
363
363
  function getFromValue() {
364
364
  if (freeScroll && mainCarouselWrapperRef.current) {
365
- return mainCarouselWrapperRef.current[carouselSlideAxis === "x" ? "scrollLeft" : "scrollTop"];
365
+ return mainCarouselWrapperRef.current[carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'];
366
366
  }
367
367
  return spring.val.get();
368
368
  }
369
369
  function getToValue(type, index) {
370
- if (freeScroll && type === "next") {
370
+ if (freeScroll && type === 'next') {
371
371
  const next = prevSlidedValue.current + getSlideValue();
372
372
  if (next > getTotalScrollValue()) {
373
373
  return getTotalScrollValue();
374
374
  }
375
375
  return next;
376
376
  }
377
- if (freeScroll && type === "prev") {
377
+ if (freeScroll && type === 'prev') {
378
378
  const next = prevSlidedValue.current - getSlideValue();
379
379
  if (next < 0) {
380
380
  return 0;
381
381
  }
382
382
  return next;
383
383
  }
384
- if (type === "next") {
384
+ if (type === 'next') {
385
385
  if (index) {
386
386
  return -(index * getSlideValue());
387
387
  }
@@ -392,14 +392,14 @@
392
392
  }
393
393
  return prevSlidedValue.current + getSlideValue();
394
394
  }
395
- function slideToPrevItem(type = "click", index) {
395
+ function slideToPrevItem(type = 'click', index) {
396
396
  if (!init || (firstItemReached.current && !withLoop))
397
397
  return;
398
- slideActionType.current = "prev";
398
+ slideActionType.current = 'prev';
399
399
  lastItemReached.current = false;
400
400
  const nextItem = index || activeItem.current - 1;
401
401
  if (!withLoop) {
402
- const nextItemWillExceed = getToValue("prev", index) + getSlideValue() / 3 > 0;
402
+ const nextItemWillExceed = getToValue('prev', index) + getSlideValue() / 3 > 0;
403
403
  if (firstItemReached.current)
404
404
  return;
405
405
  if (nextItemWillExceed) {
@@ -434,19 +434,18 @@
434
434
  slideToItem({
435
435
  slideMode: type,
436
436
  from: getFromValue(),
437
- to: getToValue("prev", index),
437
+ to: getToValue('prev', index),
438
438
  nextActiveItem: nextItem,
439
439
  });
440
440
  }
441
- function slideToNextItem(type = "click", index) {
441
+ function slideToNextItem(type = 'click', index) {
442
442
  if (!init || (lastItemReached.current && !withLoop))
443
443
  return;
444
- slideActionType.current = "next";
444
+ slideActionType.current = 'next';
445
445
  firstItemReached.current = false;
446
446
  const nextItem = index || activeItem.current + 1;
447
447
  if (!withLoop) {
448
- const nextItemWillExceed = Math.abs(getToValue("next", index)) >
449
- getTotalScrollValue() - getSlideValue() / 3;
448
+ const nextItemWillExceed = Math.abs(getToValue('next', index)) > getTotalScrollValue() - getSlideValue() / 3;
450
449
  if (lastItemReached.current)
451
450
  return;
452
451
  if (nextItemWillExceed) {
@@ -481,7 +480,7 @@
481
480
  slideToItem({
482
481
  slideMode: type,
483
482
  from: getFromValue(),
484
- to: getToValue("next", index),
483
+ to: getToValue('next', index),
485
484
  nextActiveItem: nextItem,
486
485
  });
487
486
  }
@@ -523,28 +522,28 @@
523
522
  prevWindowWidth.current = window.innerWidth;
524
523
  adjustCarouselWrapperPosition();
525
524
  }
526
- window.addEventListener("resize", handleResize);
525
+ window.addEventListener('resize', handleResize);
527
526
  return () => {
528
- window.removeEventListener("resize", handleResize);
527
+ window.removeEventListener('resize', handleResize);
529
528
  };
530
529
  }, []);
531
- const bindDrag = react$1.useDrag((state) => {
530
+ const bindDrag = react$1.useDrag(state => {
532
531
  const isDragging = state.dragging;
533
- const movement = state.offset[carouselSlideAxis === "x" ? 0 : 1];
534
- const currentMovement = state.movement[carouselSlideAxis === "x" ? 0 : 1];
535
- const direction = state.direction[carouselSlideAxis === "x" ? 0 : 1];
532
+ const movement = state.offset[carouselSlideAxis === 'x' ? 0 : 1];
533
+ const currentMovement = state.movement[carouselSlideAxis === 'x' ? 0 : 1];
534
+ const direction = state.direction[carouselSlideAxis === 'x' ? 0 : 1];
536
535
  const prevItemTreshold = currentMovement > draggingSlideTreshold.current;
537
536
  const nextItemTreshold = currentMovement < -draggingSlideTreshold.current;
538
537
  if (isDragging) {
539
538
  if (direction > 0) {
540
- slideActionType.current = "prev";
539
+ slideActionType.current = 'prev';
541
540
  }
542
541
  else {
543
- slideActionType.current = "next";
542
+ slideActionType.current = 'next';
544
543
  }
545
- emitEvent(Object.assign(Object.assign({}, state), { eventName: "onDrag", slideActionType: slideActionType.current }));
544
+ emitEvent(Object.assign(Object.assign({}, state), { eventName: 'onDrag', slideActionType: slideActionType.current }));
546
545
  if (freeScroll) {
547
- if (slideActionType.current === "prev" && movement > 0) {
546
+ if (slideActionType.current === 'prev' && movement > 0) {
548
547
  state.cancel();
549
548
  setSpring.start({
550
549
  from: {
@@ -585,21 +584,21 @@
585
584
  },
586
585
  });
587
586
  if (slideWhenThresholdIsReached && nextItemTreshold) {
588
- slideToNextItem("drag");
587
+ slideToNextItem('drag');
589
588
  state.cancel();
590
589
  }
591
590
  else if (slideWhenThresholdIsReached && prevItemTreshold) {
592
- slideToPrevItem("drag");
591
+ slideToPrevItem('drag');
593
592
  state.cancel();
594
593
  }
595
594
  return;
596
595
  }
597
596
  if (state.last && !state.canceled && freeScroll) {
598
- if (slideActionType.current === "prev") {
599
- slideToPrevItem("drag");
597
+ if (slideActionType.current === 'prev') {
598
+ slideToPrevItem('drag');
600
599
  }
601
- if (slideActionType.current === "next") {
602
- slideToNextItem("drag");
600
+ if (slideActionType.current === 'next') {
601
+ slideToNextItem('drag');
603
602
  }
604
603
  }
605
604
  if (state.last && !state.canceled && !freeScroll) {
@@ -611,7 +610,7 @@
611
610
  });
612
611
  }
613
612
  else {
614
- slideToNextItem("drag");
613
+ slideToNextItem('drag');
615
614
  }
616
615
  }
617
616
  else if (prevItemTreshold) {
@@ -622,7 +621,7 @@
622
621
  });
623
622
  }
624
623
  else {
625
- slideToPrevItem("drag");
624
+ slideToPrevItem('drag');
626
625
  }
627
626
  }
628
627
  else {
@@ -643,7 +642,7 @@
643
642
  -mainCarouselWrapperRef.current.scrollTop,
644
643
  ];
645
644
  }
646
- if (carouselSlideAxis === "x") {
645
+ if (carouselSlideAxis === 'x') {
647
646
  return [spring.val.get(), spring.val.get()];
648
647
  }
649
648
  return [spring.val.get(), spring.val.get()];
@@ -651,13 +650,13 @@
651
650
  });
652
651
  function getWrapperOverflowStyles() {
653
652
  if (freeScroll) {
654
- if (carouselSlideAxis === "x") {
653
+ if (carouselSlideAxis === 'x') {
655
654
  return {
656
- overflowX: "auto",
655
+ overflowX: 'auto',
657
656
  };
658
657
  }
659
658
  return {
660
- overflowY: "auto",
659
+ overflowY: 'auto',
661
660
  };
662
661
  }
663
662
  return {};
@@ -665,17 +664,17 @@
665
664
  function setStartEndItemReachedOnFreeScroll() {
666
665
  if (mainCarouselWrapperRef.current) {
667
666
  prevSlidedValue.current =
668
- mainCarouselWrapperRef.current[carouselSlideAxis === "x" ? "scrollLeft" : "scrollTop"];
669
- if (mainCarouselWrapperRef.current[carouselSlideAxis === "x" ? "scrollLeft" : "scrollTop"] === 0) {
667
+ mainCarouselWrapperRef.current[carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'];
668
+ if (mainCarouselWrapperRef.current[carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'] === 0) {
670
669
  firstItemReached.current = true;
671
670
  lastItemReached.current = false;
672
671
  }
673
- if (mainCarouselWrapperRef.current[carouselSlideAxis === "x" ? "scrollLeft" : "scrollTop"] > 0 &&
674
- mainCarouselWrapperRef.current[carouselSlideAxis === "x" ? "scrollLeft" : "scrollTop"] < getTotalScrollValue()) {
672
+ if (mainCarouselWrapperRef.current[carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'] > 0 &&
673
+ mainCarouselWrapperRef.current[carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'] < getTotalScrollValue()) {
675
674
  firstItemReached.current = false;
676
675
  lastItemReached.current = false;
677
676
  }
678
- if (mainCarouselWrapperRef.current[carouselSlideAxis === "x" ? "scrollLeft" : "scrollTop"] === getTotalScrollValue()) {
677
+ if (mainCarouselWrapperRef.current[carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'] === getTotalScrollValue()) {
679
678
  firstItemReached.current = false;
680
679
  lastItemReached.current = true;
681
680
  }
@@ -693,12 +692,12 @@
693
692
  return {};
694
693
  }
695
694
  function findItemIndex(id) {
696
- return items.findIndex((item) => item.id === id);
695
+ return items.findIndex(item => item.id === id);
697
696
  }
698
697
  function findItemIndexById(id, error) {
699
698
  let itemIndex = 0;
700
- if (typeof id === "string") {
701
- itemIndex = items.findIndex((_item) => _item.id === id);
699
+ if (typeof id === 'string') {
700
+ itemIndex = items.findIndex(_item => _item.id === id);
702
701
  }
703
702
  else {
704
703
  itemIndex = id;
@@ -720,10 +719,10 @@
720
719
  const currentItem = findItemIndex(items[activeItem.current].id);
721
720
  const newActiveItem = findItemIndex(items[itemIndex].id);
722
721
  if (newActiveItem > currentItem) {
723
- slideToNextItem("click", newActiveItem);
722
+ slideToNextItem('click', newActiveItem);
724
723
  }
725
724
  else {
726
- slideToPrevItem("click", newActiveItem);
725
+ slideToPrevItem('click', newActiveItem);
727
726
  }
728
727
  }
729
728
  function getIsNextItem(id) {
@@ -742,8 +741,8 @@
742
741
  }
743
742
  return itemIndex === _activeItem - 1;
744
743
  }
745
- const carouselFragment = (jsxRuntime.jsx("div", Object.assign({ ref: mainCarouselWrapperRef }, getScrollHandlers(), { style: Object.assign({ display: "flex", position: "relative", width: "100%", height: "100%" }, getWrapperOverflowStyles()) }, { children: jsxRuntime.jsx("div", Object.assign({ ref: carouselTrackWrapperRef }, bindDrag(), { style: Object.assign({ position: "relative", display: "flex", flexDirection: carouselSlideAxis === "x" ? "row" : "column", touchAction: "none" }, getAnimatedWrapperStyles()) }, { children: internalItems.map((item, index) => {
746
- return (jsxRuntime.jsx("div", Object.assign({ className: "use-spring-carousel-item", "data-testid": "use-spring-carousel-item-wrapper", style: Object.assign({ display: "flex", position: "relative", flex: "1" }, getItemStyles()) }, { children: item.renderItem }), `${item.id}-${index}`));
744
+ const carouselFragment = (jsxRuntime.jsx("div", Object.assign({ ref: mainCarouselWrapperRef }, getScrollHandlers(), { style: Object.assign({ display: 'flex', position: 'relative', width: '100%', height: '100%' }, getWrapperOverflowStyles()) }, { children: jsxRuntime.jsx("div", Object.assign({ ref: carouselTrackWrapperRef }, bindDrag(), { style: Object.assign({ position: 'relative', display: 'flex', flexDirection: carouselSlideAxis === 'x' ? 'row' : 'column', touchAction: 'none' }, getAnimatedWrapperStyles()) }, { children: internalItems.map((item, index) => {
745
+ return (jsxRuntime.jsx("div", Object.assign({ className: "use-spring-carousel-item", "data-testid": "use-spring-carousel-item-wrapper", style: Object.assign({ display: 'flex', position: 'relative', flex: '1' }, getItemStyles()) }, { children: item.renderItem }), `${item.id}-${index}`));
747
746
  }) })) })));
748
747
  return {
749
748
  useListenToCustomEvent,
@@ -767,7 +766,7 @@
767
766
  function useSpringCarouselContext() {
768
767
  const context = react.useContext(Context);
769
768
  if (!context) {
770
- throw new Error("useSpringCarouselContext must be used within the carousel.");
769
+ throw new Error('useSpringCarouselContext must be used within the carousel.');
771
770
  }
772
771
  return context;
773
772
  }