react-spring-carousel 1.9.29-beta39 → 1.9.29-beta42

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.
@@ -1,2 +1,2 @@
1
1
  !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("react-spring"),require("@use-gesture/react"),require("rxjs"),require("screenfull")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","react-spring","@use-gesture/react","rxjs","screenfull"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactSpringCarousel={},e.jsxRuntime,e.React,e.reactSpring,e.reactUseGesture,e.rxjs,e.screenfull)}(this,(function(e,t,n,r,i,o,s){"use strict";function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(s);function c(){const e=n.useRef(new o.Subject);return{useListenToCustomEvent:function(t){n.useEffect((()=>{const n=e.current.subscribe(t);return()=>n.unsubscribe()}),[t])},emitObservable:t=>{e.current.next(t)}}}function a({mainCarouselWrapperRef:e,emitObservable:t,handleResize:r}){const i=n.useRef(!1);function o(e){i.current=e}return n.useEffect((()=>{function e(){document.fullscreenElement&&(o(!0),t({eventName:"onFullscreenChange",isFullscreen:!0}),r&&r()),document.fullscreenElement||(o(!1),t({eventName:"onFullscreenChange",isFullscreen:!1}),r&&r())}if(l.default.isEnabled)return l.default.on("change",e),()=>{l.default.isEnabled&&l.default.off("change",e)}})),{enterFullscreen:function(t){l.default.isEnabled&&l.default.request(t||e.current)},exitFullscreen:function(){l.default.isEnabled&&l.default.exit()},getIsFullscreen:function(){return i.current}}}function d(e){const t=n.useRef(!1);n.useEffect((()=>{if(!t.current){const n=e();return t.current=!0,()=>{n&&n()}}}),[])}const f=n.forwardRef((({children:e,...n},i)=>t.jsx(r.animated.div,Object.assign({},n,{ref:i},{children:e}),void 0)));function m({items:e,withThumbs:i,thumbsSlideAxis:o="x",springConfig:s,prepareThumbsData:u,itemsPerSlide:l,getFluidWrapperScrollValue:c=(()=>0),getSlideValue:a=(()=>0),CustomThumbsWrapperComponent:m}){const h=n.useRef(null),[p,g]=r.useSpring((()=>({x:0,y:0,config:s,onChange:({value:e})=>{h.current&&(h.current["x"===o?"scrollLeft":"scrollTop"]=Math.abs(e[o]))}})));function x(){return h.current["x"===o?"scrollLeft":"scrollTop"]}function b(){return Math.round(Number(h.current?.["x"===o?"scrollWidth":"scrollHeight"])-h.current.getBoundingClientRect()["x"===o?"width":"height"])}function v(){const e=Math.round(c()/a());return b()/e}d((()=>{if(i&&!h.current)throw new Error("The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.")}));const w=m?r.animated(m):f;return{thumbsFragment:i?t.jsx(w,Object.assign({ref:h,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{p[o].stop()},style:{display:"flex",flex:1,position:"relative",flexDirection:"x"===o?"row":"column",..."x"===o?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"}}},{children:function(){function t(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return u?u(t(e)):t(e)}().map((({id:e,renderThumb:n})=>{const r=`thumb-${e}`;return t.jsx("div",Object.assign({id:r},{children:n}),r)}))}),void 0):null,handleThumbsScroll:function(t,n){if("fluid"===l){const e=b();if("next"===n){const t=x()+v();g.start({from:{[o]:x()},to:{[o]:t>e?e:t}})}if("prev"===n){const e=x()-v();g.start({from:{[o]:x()},to:{[o]:e<0?0:e}})}}else{const n=h.current.querySelector(`#thumb-${e[t].id}`);if(n){const r=h.current,i="x"===o?"offsetWidth":"offsetHeight",s="x"===o?"scrollLeft":"scrollTop",u=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:n,offsetDimension:i,offsetDirection:"x"===o?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:r,offsetDimension:i});g.start({from:{[o]:function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:r,scrollDirection:s})},to:{[o]:function({thumbWrapper:n,thumbOffsetPosition:r,thumbScrollDimension:i,offsetDimension:s}){const u="x"===o?"scrollWidth":"scrollHeight";return t===e.length-1||r-i>n[u]-n[s]?n[u]-n[s]:0===t?0:r-i}({thumbWrapper:r,thumbOffsetPosition:u,thumbScrollDimension:l,offsetDimension:i})},onChange:e=>{"x"===o?h.current.scrollLeft=e.x:h.current.scrollTop=e.y}})}}}}}const h=n.createContext(void 0);const p=n.createContext(void 0);e.useSpringCarousel=function({itemsPerSlide:e=1,items:o,withLoop:s=!1,draggingSlideTreshold:u=140,springConfig:l=r.config.default,shouldResizeOnWindowResize:f=!0,withThumbs:p=!1,enableThumbsWrapperScroll:g=!0,carouselSlideAxis:x="x",thumbsSlideAxis:b="x",prepareThumbsData:v,initialActiveItem:w=0,initialStartingPosition:T="start",disableGestures:y=!1,gutter:C=0,startEndGutter:S=0,touchAction:I,slideAmount:R,freeScroll:j=!1,CustomThumbsWrapperComponent:E}){const A=n.useRef("initial"),W=s?o.length===e?[...o,...o,...o,...o,...o]:[...o,...o,...o]:o,N=n.useRef(w),F=n.useRef(null),D=n.useRef(null),L=n.useRef(!1),O=n.useRef(!1),P=n.useRef(!1),k=n.useRef(0),M=n.useRef(0),$=n.useRef(!1),q=n.useRef(0),[z,B]=r.useSpring((()=>({y:0,x:0,config:l,onChange:({value:e})=>{F.current&&j&&(F.current["x"===x?"scrollLeft":"scrollTop"]=Math.abs(e[x]))}}))),H=n.useCallback((()=>{if(!F.current)throw new Error("mainCarouselWrapperRef is not available");return F.current.getBoundingClientRect()["x"===x?"width":"height"]}),[x]),G=n.useCallback((()=>{const e=D.current?.querySelector(".use-spring-carousel-item");if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===x?"width":"height"]+C}),[x,C]),V=n.useCallback((()=>z[x].get()),[x,z]),Y=n.useCallback((()=>G()*o.length<H()),[G,H,o.length]),X=n.useCallback((()=>Math.round(Number(D.current?.["x"===x?"scrollWidth":"scrollHeight"])-D.current.getBoundingClientRect()["x"===x?"width":"height"])),[x]),_=n.useCallback((()=>0===ae()),[]),U=n.useCallback((()=>{if(!D.current)return 0;const t=G();if("fluid"===e&&"number"==typeof R){if(R<t)throw new Error("slideAmount must be greater than the width of a single item.");return R}return t}),[G,e,R]),J=n.useCallback((t=>{const n="x"===x?"left":"top";function r(){return G()*o.length}function i(e){t.style.top="0px",t.style.left="0px",s&&(t.style[n]=`-${e-S}px`)}function u(){i(r())}if("fluid"!==e&&"number"==typeof e){if(e>1)switch(T){default:case"start":u();break;case"center":i(r()-U()*Math.round((e-1)/2));break;case"end":i(r()-U()*Math.round(e-1))}else u()}else u()}),[x,e,G,o.length,S,U,T,s]),K=n.useCallback((()=>{if(window.innerWidth!==k.current&&!j){if(k.current=window.innerWidth,"fluid"===e){if(Y())return void B.start({immediate:!0,[x]:0});M.current=X();const e=k.current-q.current;if($.current){const e=-M.current;B.start({immediate:!0,[x]:e})}else{const t=V()+e;B.start({immediate:!0,[x]:t})}q.current=window.innerWidth}else B.start({immediate:!0,x:0,y:0}),B.start({immediate:!0,[x]:-U()*ae()});J(D.current)}}),[e,Y,X,j,B,x,V,U,J]),{useListenToCustomEvent:Q,emitObservable:Z}=c(),{enterFullscreen:ee,exitFullscreen:te,getIsFullscreen:ne}=a({mainCarouselWrapperRef:F,emitObservable:Z,handleResize:K}),{thumbsFragment:re,handleThumbsScroll:ie}=m({withThumbs:p,items:o,thumbsSlideAxis:b,springConfig:l,prepareThumbsData:v,itemsPerSlide:e,getFluidWrapperScrollValue:X,getSlideValue:U,CustomThumbsWrapperComponent:E});function oe(){if(!F.current)throw new Error("Missing mainCarouselWrapperRef.current");return F.current["x"===x?"scrollLeft":"scrollTop"]}const se=i.useDrag((t=>{const n=t.dragging,r=t.offset["x"===x?0:1],i=t.movement["x"===x?0:1];function l(){t.cancel()}function c(){"fluid"===e?Y()||_()&&"prev"===le()?B.start({[x]:0}):$.current?B.start({[x]:-M.current}):B.start({[x]:V()}):B.start({[x]:-ae()*U()})}if(n){fe(!0),Z({eventName:"onDrag",slideActionType:le(),...t});const n=t.direction["x"===x?0:1];ue(n>0?"prev":"next"),j?0===oe()&&n>0?l():B.start({from:{[x]:oe()},to:{[x]:n>0?oe()-Math.abs(r):oe()+Math.abs(r)}}):B.start({[x]:r});const a=i>u,d=i<-u;if(F.current.getBoundingClientRect().width>=o.length*U()&&"fluid"===e&&($.current=!0),(a||d)&&Y()&&"fluid"===e)return l(),void c();$.current&&r<0?d&&(l(),B.start({[x]:-M.current})):d?(l(),!s&&xe()?c():ve()):a&&(l(),!s&&_()?c():be())}!t.last||t.pressed||j||(c(),Z({eventName:"onDrag",slideActionType:le(),...t}))}),{enabled:!y,from:()=>[z.x.get(),z.y.get()]});function ue(e){A.current=e}function le(){return A.current}function ce(e){N.current=e}function ae(){return N.current}function de(e){O.current=e}function fe(e){L.current=e}function me(){const e=ae();return 0===e?o.length-1:e-1}function he(){const e=ae();return e===o.length-1?0:e+1}function pe(e){return o.findIndex((t=>t.id===e))}function ge({from:t,to:n=-1,customTo:r,immediate:i=!1,onRest:s=(()=>{})}){i||(ce(n),de(!0),Z({eventName:"onSlideStartChange",slideActionType:le(),nextItem:{index:"fluid"===e?-1:n,id:"fluid"===e?"":o[n].id}})),B.start({..."number"==typeof t?{from:{[x]:t}}:{},to:"number"==typeof r?{[x]:r}:{[x]:-U()*n},immediate:i,onRest:t=>{t.finished&&(fe(!1),de(!1),s(),i||Z({eventName:"onSlideChange",slideActionType:le(),currentItem:{index:"fluid"===e?-1:ae(),id:"fluid"===e?"":o[ae()].id}}))}}),g&&p&&!i&&ie(n,le())}function xe(){return ae()===o.length-1}function be(){if(ue("prev"),"fluid"===e){if(Y())return;const e=V()+U()+200;if(j){const e=F.current.scrollLeft-U();ge({customTo:e<0?0:e,from:F.current.scrollLeft})}else ge(e>=0?s?{from:V()-G()*o.length,customTo:V()-G()*o.length+U()}:{customTo:0}:{customTo:V()+U()});$.current&&($.current=!1)}else{if(!s&&0===ae()||P.current)return;_()?ge({from:V()-U()*o.length,to:o.length-1}):ge({to:me()})}}function ve(){if(ue("next"),"fluid"===e){if(Y())return;const e=Math.abs(V()-U())+100>=M.current;if(j)ge({customTo:F.current.scrollLeft+U(),from:F.current.scrollLeft});else if(s&&Math.abs(V()-U())>=o.length*G()){const e=G()*o.length;ge({from:V()+e,customTo:V()+e-U()})}else{if($.current)return;e?($.current=!0,ge({customTo:-M.current})):ge({customTo:V()-U()})}}else{if(!s&&ae()===W.length-1||P.current)return;xe()?ge({from:V()+U()*o.length,to:0}):ge({to:he()})}}d((()=>{if("fluid"!==e&&!Number.isInteger(e))throw new Error("itemsPerSlide should be an integer.");if(e>o.length)throw new Error("The itemsPerSlide prop can't be greater than the total length of the items you provide.");if(e<1)throw new Error("The itemsPerSlide prop can't be less than 1.");f||console.warn("You set shouldResizeOnWindowResize={false}; be aware that the carousel could behave in a strange way if you also use the fullscreen functionality or if you change the mobile orientation."),w<0&&console.warn("The initialActiveItem cannot be less than 0."),w>o.length&&console.warn("The initialActiveItem cannot be greater than the total length of the items you provide.")})),d((()=>{function e(){document.hidden?P.current=!0:P.current=!1}if(M.current=X(),"undefined"!=typeof window)return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),d((()=>{q.current=window.innerWidth,w>0&&w<=o.length&&(ge({to:w,immediate:!0}),ce(w))})),n.useEffect((()=>{function e(){setTimeout(K)}if(f)return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[K,f]),n.useEffect((()=>{D.current&&("x"===x&&(D.current.style.top="0px"),"y"===x&&(D.current.style.left="0px"))}),[x]),n.useEffect((()=>{setTimeout((()=>J(D.current)),150)}),[J,x,e]);const we={useListenToCustomEvent:Q,getIsFullscreen:ne,enterFullscreen:ee,exitFullscreen:te,getIsAnimating:function(){return O.current},getIsDragging:function(){return L.current},getIsNextItem:function(e){const t=pe(e),n=ae();return s&&n===o.length-1?0===t:t===n+1},getIsPrevItem:function(e){const t=pe(e),n=ae();return s&&0===n?t===o.length-1:t===n-1},slideToPrevItem:be,slideToNextItem:ve,..."number"==typeof e?{slideToItem:function(e){let t=0;if(t="string"==typeof e?o.findIndex((t=>t.id===e)):e,t>=o.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(t===ae())return;const n=pe(o[ae()].id);ue(pe(o[t].id)>n?"next":"prev"),ge({to:t})},getIsActiveItem:e=>pe(e)===ae(),getCurrentActiveItem:()=>({id:o[ae()].id,index:ae()})}:{}},Te=t.jsx(h.Provider,Object.assign({value:we},{children:t.jsx("div",Object.assign({ref:F,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},j?{onWheel(){z[x].stop()}}:{},{style:{display:"flex",position:"relative",width:"100%",height:"100%",...j?"x"===x?{overflowX:"auto"}:{overflowY:"auto"}:{}}},{children:t.jsx(r.animated.div,Object.assign({},se(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:function(e){e&&(D.current=e,J(e))},style:{display:"flex",position:"relative",touchAction:I||("x"===x?"pan-y":"pan-x"),flexDirection:"x"===x?"row":"column",...function(){const e=`calc(100% - ${2*S}px)`;return{width:"x"===x?e:"100%",height:"y"===x?e:"100%"}}(),...j?{}:z}},{children:W.map((({id:n,renderItem:r},i)=>t.jsx("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:{display:"flex",position:"relative",..."number"==typeof e?{..."x"===x?{marginRight:`${C}px`}:{marginBottom:`${C}px`},flex:`1 0 calc(100% / ${e} - ${C*(e-1)/e}px)`}:{..."x"===x?{marginRight:`${C}px`}:{marginBottom:`${C}px`}}}},{children:r}),`${n}-${i}`)))}),void 0)}),void 0)}),void 0),ye=t.jsx(h.Provider,Object.assign({value:we},{children:re}),void 0);return{...we,carouselFragment:Te,thumbsFragment:ye}},e.useSpringCarouselContext=function(){const e=n.useContext(h);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e},e.useTransitionCarousel=function({items:e,withLoop:o=!1,withThumbs:s=!1,springConfig:u=r.config.default,thumbsSlideAxis:l="x",enableThumbsWrapperScroll:d=!0,draggingSlideTreshold:f=50,prepareThumbsData:h,toPrevItemSpringProps:g,toNextItemSpringProps:x,disableGestures:b=!1,CustomThumbsWrapperComponent:v,springAnimationProps:w={initial:{opacity:1,position:"relative"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"relative"},leave:{opacity:0,position:"absolute"}}}){const T=n.useRef("next"),y=n.useRef(null),C=n.useRef(!1),[S,I]=n.useState(0),{emitObservable:R,useListenToCustomEvent:j}=c(),{enterFullscreen:E,exitFullscreen:A,getIsFullscreen:W}=a({emitObservable:R,mainCarouselWrapperRef:y}),{thumbsFragment:N,handleThumbsScroll:F}=m({items:e,withThumbs:s,thumbsSlideAxis:l,springConfig:u,prepareThumbsData:h,CustomThumbsWrapperComponent:v}),D=i.useDrag((({last:t,movement:[n]})=>{if(!O()&&t){const t=n>f,r=n<-f,i=0===S,s=S===e.length-1;if(r){if(!o&&s)return;$(),R({eventName:"onLeftSwipe"})}else if(t){if(!o&&i)return;q(),R({eventName:"onRightSwipe"})}}}),{enabled:!b}),L=r.useTransition(S,{config:u,...function(){const e=M();return"prev"===e&&g?{initial:{...w.initial},from:{...g.from},enter:{...g.enter},leave:{...g.leave}}:"next"===e&&x?{initial:{...w.initial},from:{...x.from},enter:{...x.enter},leave:{...x.leave}}:{initial:{...w.initial},from:{...w.from},enter:{...w.enter},leave:{...w.leave}}}(),onStart:()=>P(!0),keys:null,onRest:t=>{t.finished&&(P(!1),R({eventName:"onSlideChange",slideActionType:M(),currentItem:{index:S,id:e[S].id}}))}})(((n,i)=>t.jsx(r.animated.div,Object.assign({style:{...n,flex:"1 0 100%",width:"100%",height:"100%"}},{children:e[i].renderItem}),void 0)));function O(){return C.current}function P(e){C.current=e}function k(e){T.current=e}function M(){return T.current}function $(){const t=S===e.length-1;o?(k("next"),t?(R({eventName:"onSlideStartChange",slideActionType:M(),nextItem:{index:0,id:e[0].id}}),I(0)):(R({eventName:"onSlideStartChange",slideActionType:M(),nextItem:{index:S+1,id:e[S+1].id}}),I(S+1))):t||(R({eventName:"onSlideStartChange",slideActionType:M(),nextItem:{index:S+1,id:e[S+1].id}}),k("next"),I(S+1))}function q(){const t=0===S;o?(k("prev"),t?(R({eventName:"onSlideStartChange",slideActionType:M(),nextItem:{index:S-1,id:e[S-1].id}}),I(e.length-1)):(R({eventName:"onSlideStartChange",slideActionType:M(),nextItem:{index:S-1,id:e[S-1].id}}),I(S-1))):t||(k("prev"),R({eventName:"onSlideStartChange",slideActionType:M(),nextItem:{index:S-1,id:e[S-1].id}}),I(S-1))}function z(t){return e.findIndex((e=>e.id===t))}const B={activeItem:S,slideToItem:function(t){let n=0;if(n="string"==typeof t?e.findIndex((e=>e.id===t)):t,n>=e.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(n===S)return;const r=z(e[S].id),i=z(e[n].id);R({eventName:"onSlideStartChange",slideActionType:M(),nextItem:{index:i,id:e[n].id}}),k(i>r?"next":"prev"),I(n),d&&s&&F(n)},slideToNextItem:$,slideToPrevItem:q,enterFullscreen:E,exitFullscreen:A,useListenToCustomEvent:j,getIsNextItem:function(t){const n=z(t);return o&&S===e.length-1?0===n:n===S+1},getIsPrevItem:function(t){const n=z(t);return o&&0===S?n===e.length-1:n===S-1},getIsAnimating:O,getIsFullscreen:W,getIsActiveItem:e=>z(e)===S,getCurrentActiveItem:()=>({id:e[S].id,index:S})};return{carouselFragment:t.jsx(p.Provider,Object.assign({value:B},{children:t.jsx("div",Object.assign({ref:y},D(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:L}),void 0)}),void 0),thumbsFragment:t.jsx(p.Provider,Object.assign({value:B},{children:N}),void 0),...B}},e.useTransitionCarouselContext=function(){const e=n.useContext(p);if(!e)throw new Error("useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.");return e},Object.defineProperty(e,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=index.umd.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/modules/useCustomEventsModule.tsx","../src/modules/useFullscreenModule.tsx","../src/utils.ts","../src/modules/useThumbsModule.tsx","../src/useSpringCarousel.tsx","../src/useTransitionCarousel.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { Subject } from 'rxjs'\nimport { EventsObservableProps, ObservableCallbackFn, EmitObservableFn } from '../types'\n\nexport function useCustomEventsModule() {\n const eventsObserverRef = useRef(new Subject<EventsObservableProps>())\n\n function useListenToCustomEvent(fn: ObservableCallbackFn) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, MutableRefObject, useEffect } from 'react'\nimport screenfull from 'screenfull'\nimport { EmitObservableFn } from '../types'\n\ntype FullscreenModule = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn\n handleResize?(): void\n}\n\nexport function useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule) {\n const isFullscreen = useRef(false)\n\n useEffect(() => {\n function handleFullscreenChange() {\n if (document.fullscreenElement) {\n setIsFullscreen(true)\n emitObservable({\n eventName: 'onFullscreenChange',\n isFullscreen: true,\n })\n\n handleResize && handleResize()\n }\n\n if (!document.fullscreenElement) {\n setIsFullscreen(false)\n emitObservable({\n eventName: 'onFullscreenChange',\n isFullscreen: false,\n })\n handleResize && handleResize()\n }\n }\n\n if (screenfull.isEnabled) {\n screenfull.on('change', handleFullscreenChange)\n return () => {\n if (screenfull.isEnabled) {\n screenfull.off('change', handleFullscreenChange)\n }\n }\n }\n })\n\n function setIsFullscreen(_isFullscreen: boolean) {\n isFullscreen.current = _isFullscreen\n }\n\n function getIsFullscreen() {\n return isFullscreen.current\n }\n\n function enterFullscreen(elementRef?: HTMLElement) {\n if (screenfull.isEnabled) {\n screenfull.request((elementRef || mainCarouselWrapperRef.current) as Element)\n }\n }\n\n function exitFullscreen() {\n screenfull.isEnabled && screenfull.exit()\n }\n\n return {\n enterFullscreen,\n exitFullscreen,\n getIsFullscreen,\n }\n}\n","import { useRef, useEffect } from 'react'\n\ntype Callback = () => void | (() => void)\n\nexport function useMount(callback: Callback) {\n const isMounted = useRef(false)\n\n useEffect(() => {\n if (!isMounted.current) {\n const clean = callback()\n isMounted.current = true\n\n return () => {\n clean && clean()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\nexport function getIsBrowser() {\n return typeof window !== 'undefined'\n}\n","import { forwardRef, HTMLAttributes, useRef } from 'react'\nimport { useSpring, SpringConfig, animated } from 'react-spring'\nimport { useMount } from 'src/utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringThumbItem,\n PrepareThumbsData,\n UseSpringCarouselItems,\n SlideActionType,\n} from '../types'\n\ntype OffsetDimension = 'offsetWidth' | 'offsetHeight'\ntype OffsetDirection = 'offsetLeft' | 'offsetTop'\ntype ScrollDirection = 'scrollLeft' | 'scrollTop'\n\ntype Props = {\n items: UseSpringCarouselItems['items']\n withThumbs: boolean\n thumbsSlideAxis: UseSpringCarouselProps['thumbsSlideAxis']\n springConfig: SpringConfig\n prepareThumbsData?: PrepareThumbsData\n itemsPerSlide?: UseSpringCarouselProps['itemsPerSlide']\n CustomThumbsWrapperComponent?: UseSpringCarouselProps['CustomThumbsWrapperComponent']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\ntype WrapperProps = {\n children: React.ReactNode\n} & HTMLAttributes<HTMLDivElement>\n\nconst InternalWrapper = forwardRef<HTMLDivElement, WrapperProps>(\n ({ children, ...rest }, ref) => {\n return (\n <animated.div {...rest} ref={ref}>\n {children}\n </animated.div>\n )\n },\n)\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n itemsPerSlide,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n CustomThumbsWrapperComponent,\n}: Props) {\n const internalThumbsWrapperRef = useRef<HTMLDivElement | null>(null)\n const [thumbListStyles, setThumbListStyles] = useSpring(() => ({\n x: 0,\n y: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (internalThumbsWrapperRef.current) {\n internalThumbsWrapperRef.current[\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[thumbsSlideAxis])\n }\n },\n }))\n\n useMount(() => {\n if (withThumbs && !internalThumbsWrapperRef.current) {\n throw new Error(\n \"The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.\",\n )\n }\n })\n\n function getCurrentThumbScrollValue() {\n return internalThumbsWrapperRef.current![\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getThumbsTotalScrollableValue() {\n return Math.round(\n Number(\n internalThumbsWrapperRef.current?.[\n thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n internalThumbsWrapperRef.current!.getBoundingClientRect()[\n thumbsSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }\n\n function getThumbSlideValue() {\n const thumbSlideTotal = Math.round(getFluidWrapperScrollValue() / getSlideValue())\n const totalScrollableValue = getThumbsTotalScrollableValue()\n return totalScrollableValue / thumbSlideTotal\n }\n\n function handleThumbsScroll(activeItem: number, actionType?: SlideActionType) {\n if (itemsPerSlide === 'fluid') {\n const totalScrollableValue = getThumbsTotalScrollableValue()\n\n if (actionType === 'next') {\n const nextValue = getCurrentThumbScrollValue() + getThumbSlideValue()\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getCurrentThumbScrollValue(),\n },\n to: {\n [thumbsSlideAxis]:\n nextValue > totalScrollableValue ? totalScrollableValue : nextValue,\n },\n })\n }\n if (actionType === 'prev') {\n const nextValue = getCurrentThumbScrollValue() - getThumbSlideValue()\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getCurrentThumbScrollValue(),\n },\n to: {\n [thumbsSlideAxis]: nextValue < 0 ? 0 : nextValue,\n },\n })\n }\n } else {\n function getOffsetDirection() {\n return thumbsSlideAxis === 'x' ? 'offsetLeft' : 'offsetTop'\n }\n function getOffsetDimension() {\n return thumbsSlideAxis === 'x' ? 'offsetWidth' : 'offsetHeight'\n }\n function getScrollDirecton() {\n return thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n }\n function getThumbNode() {\n return internalThumbsWrapperRef.current!.querySelector(\n `#thumb-${items[activeItem].id}`,\n ) as HTMLElement\n }\n function getThumbOffsetPosition({\n thumbNode,\n offsetDirection,\n offsetDimension,\n }: {\n thumbNode: HTMLElement\n offsetDirection: OffsetDirection\n offsetDimension: OffsetDimension\n }) {\n return thumbNode[offsetDirection] + thumbNode[offsetDimension] / 2\n }\n function getThumbScrollDimension({\n thumbWrapper,\n offsetDimension,\n }: {\n thumbWrapper: HTMLDivElement\n offsetDimension: OffsetDimension\n }) {\n return thumbWrapper[offsetDimension] / 2\n }\n function getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n }: {\n thumbWrapper: HTMLDivElement\n scrollDirection: ScrollDirection\n }) {\n return thumbWrapper[scrollDirection]\n }\n function getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n }: {\n thumbWrapper: HTMLDivElement\n thumbOffsetPosition: number\n thumbScrollDimension: number\n offsetDimension: OffsetDimension\n }) {\n const scrollDimensionProperty =\n thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n\n if (\n activeItem === items.length - 1 ||\n thumbOffsetPosition - thumbScrollDimension >\n thumbWrapper[scrollDimensionProperty] - thumbWrapper[offsetDimension]\n ) {\n return thumbWrapper[scrollDimensionProperty] - thumbWrapper[offsetDimension]\n }\n if (activeItem === 0) {\n return 0\n }\n\n return thumbOffsetPosition - thumbScrollDimension\n }\n\n const thumbNode = getThumbNode()\n\n if (thumbNode) {\n const thumbWrapper = internalThumbsWrapperRef.current!\n const offsetDirection = getOffsetDirection()\n const offsetDimension = getOffsetDimension()\n const scrollDirection = getScrollDirecton()\n const thumbOffsetPosition = getThumbOffsetPosition({\n thumbNode,\n offsetDimension,\n offsetDirection,\n })\n const thumbScrollDimension = getThumbScrollDimension({\n thumbWrapper,\n offsetDimension,\n })\n\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n }),\n },\n to: {\n [thumbsSlideAxis]: getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n }),\n },\n onChange: val => {\n if (thumbsSlideAxis === 'x') {\n // @ts-ignore\n internalThumbsWrapperRef!.current!.scrollLeft = val.x\n } else {\n // @ts-ignore\n internalThumbsWrapperRef!.current!.scrollTop = val.y\n }\n },\n })\n }\n }\n }\n function handlePrepareThumbsDate() {\n function getPreparedItems(\n _items: UseSpringCarouselItems['items'],\n ): ReactSpringThumbItem[] {\n return _items.map(i => ({\n id: i.id,\n renderThumb: i.renderThumb,\n }))\n }\n\n if (prepareThumbsData) {\n return prepareThumbsData(getPreparedItems(items))\n }\n return getPreparedItems(items)\n }\n\n const Wrapper = CustomThumbsWrapperComponent\n ? animated(CustomThumbsWrapperComponent)\n : InternalWrapper\n\n const thumbsFragment = withThumbs ? (\n <Wrapper\n ref={internalThumbsWrapperRef}\n className=\"use-spring-carousel-thumbs-wrapper\"\n onWheel={() => {\n thumbListStyles[thumbsSlideAxis].stop()\n }}\n style={{\n display: 'flex',\n flex: 1,\n position: 'relative',\n flexDirection: thumbsSlideAxis === 'x' ? 'row' : 'column',\n ...(thumbsSlideAxis === 'x'\n ? { overflowX: 'auto' }\n : {\n overflowY: 'auto',\n maxHeight: '100%',\n }),\n }}\n >\n {handlePrepareThumbsDate().map(({ id, renderThumb }) => {\n const thumbId = `thumb-${id}`\n return (\n <div key={thumbId} id={thumbId}>\n {renderThumb}\n </div>\n )\n })}\n </Wrapper>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useCallback, useContext, useEffect } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from './modules'\nimport {\n UseSpringCarouselProps,\n SlideToItemFnProps,\n SlideActionType,\n UseSpringDafaultTypeReturnProps,\n UseSpringFluidTypeReturnProps,\n} from './types'\nimport { useMount } from './utils'\nimport { getIsBrowser } from './utils'\n\ntype ReturnHook<T> = T extends 'fluid'\n ? UseSpringFluidTypeReturnProps\n : UseSpringDafaultTypeReturnProps\n\nconst UseSpringCarouselContext = createContext<\n (UseSpringFluidTypeReturnProps | UseSpringDafaultTypeReturnProps) | undefined\n>(undefined)\n\nexport function useSpringCarousel<T>({\n itemsPerSlide = 1,\n items,\n withLoop = false,\n draggingSlideTreshold = 140,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition = 'start',\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n CustomThumbsWrapperComponent,\n}: UseSpringCarouselProps): ReturnHook<T> & {\n carouselFragment: JSX.Element\n thumbsFragment: JSX.Element\n} {\n function getItems() {\n if (withLoop) {\n if (items.length === itemsPerSlide) {\n return [...items, ...items, ...items, ...items, ...items]\n }\n return [...items, ...items, ...items]\n }\n return items\n }\n const slideActionType = useRef<SlideActionType>('initial')\n const internalItems = getItems()\n const activeItem = useRef(initialActiveItem)\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const carouselTrackWrapperRef = useRef<HTMLDivElement | null>(null)\n const isDragging = useRef(false)\n const isAnimating = useRef(false)\n const windowIsHidden = useRef(false)\n const currentWindowWidth = useRef(0)\n const fluidTotalWrapperScrollValue = useRef(0)\n const slideFluidEndReached = useRef(false)\n const initialWindowWidth = useRef(0)\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxis])\n }\n },\n }))\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n const getMainCarouselWrapperWidth = useCallback(() => {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ]\n }, [carouselSlideAxis])\n const getCarouselItemWidth = useCallback(() => {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ] + gutter\n )\n }, [carouselSlideAxis, gutter])\n const getCurrentSlidedValue = useCallback(() => {\n return carouselStyles[carouselSlideAxis].get()\n }, [carouselSlideAxis, carouselStyles])\n const getIfItemsNotFillTheCarousel = useCallback(() => {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }, [getCarouselItemWidth, getMainCarouselWrapperWidth, items.length])\n const getFluidWrapperScrollValue = useCallback(() => {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }, [carouselSlideAxis])\n const getIsFirstItem = useCallback(() => {\n return getCurrentActiveItem() === 0\n }, [])\n const getSlideValue = useCallback(() => {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (itemsPerSlide === 'fluid' && typeof slideAmount === 'number') {\n if (slideAmount < itemVal) {\n throw new Error('slideAmount must be greater than the width of a single item.')\n }\n return slideAmount\n }\n return itemVal\n }, [getCarouselItemWidth, itemsPerSlide, slideAmount])\n const adjustCarouselWrapperPosition = useCallback(\n (ref: HTMLDivElement) => {\n const positionProperty = carouselSlideAxis === 'x' ? 'left' : 'top'\n function getDefaultPositionValue() {\n return getCarouselItemWidth() * items.length\n }\n function setPosition(v: number) {\n ref.style.top = '0px'\n ref.style.left = '0px'\n if (withLoop) {\n ref.style[positionProperty] = `-${v - startEndGutter}px`\n }\n }\n function setStartPosition() {\n setPosition(getDefaultPositionValue())\n }\n\n if (itemsPerSlide !== 'fluid' && typeof itemsPerSlide === 'number') {\n function setCenterPosition() {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round(((itemsPerSlide as number) - 1) / 2),\n )\n }\n function setEndPosition() {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round((itemsPerSlide as number) - 1),\n )\n }\n\n if (itemsPerSlide > 1) {\n switch (initialStartingPosition) {\n default:\n case 'start': {\n setStartPosition()\n break\n }\n case 'center': {\n setCenterPosition()\n break\n }\n case 'end': {\n setEndPosition()\n break\n }\n }\n } else {\n setStartPosition()\n }\n } else {\n setStartPosition()\n }\n },\n [\n carouselSlideAxis,\n itemsPerSlide,\n getCarouselItemWidth,\n items.length,\n startEndGutter,\n getSlideValue,\n initialStartingPosition,\n withLoop,\n ],\n )\n\n const handleResize = useCallback(() => {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n currentWindowWidth.current = window.innerWidth\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: 0,\n })\n return\n }\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n const diff = currentWindowWidth.current - initialWindowWidth.current\n\n if (slideFluidEndReached.current) {\n const nextValue = -fluidTotalWrapperScrollValue.current\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: nextValue,\n })\n } else {\n const nextValue = getCurrentSlidedValue() + diff\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n x: 0,\n y: 0,\n })\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }, [\n itemsPerSlide,\n getIfItemsNotFillTheCarousel,\n getFluidWrapperScrollValue,\n freeScroll,\n setCarouselStyles,\n carouselSlideAxis,\n getCurrentSlidedValue,\n getSlideValue,\n adjustCarouselWrapperPosition,\n ])\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n itemsPerSlide,\n getFluidWrapperScrollValue,\n getSlideValue,\n CustomThumbsWrapperComponent,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n\n const bindDrag = useDrag(\n props => {\n const isDragging = props.dragging\n const movement = props.offset[carouselSlideAxis === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxis === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function resetAnimation() {\n if (itemsPerSlide === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxis]: 0,\n })\n } else if (slideFluidEndReached.current) {\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: getCurrentSlidedValue(),\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: -(getCurrentActiveItem() * getSlideValue()),\n })\n }\n }\n\n if (isDragging) {\n setIsDragging(true)\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n const direction = props.direction[carouselSlideAxis === 'x' ? 0 : 1]\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n\n if (freeScroll) {\n if (getWrapperScrollDirection() === 0 && direction > 0) {\n cancelDrag()\n } else {\n setCarouselStyles.start({\n from: {\n [carouselSlideAxis]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxis]:\n direction > 0\n ? getWrapperScrollDirection() - Math.abs(movement)\n : getWrapperScrollDirection() + Math.abs(movement),\n },\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: movement,\n })\n }\n\n const prevItemTreshold = currentMovement > draggingSlideTreshold\n const nextItemTreshold = currentMovement < -draggingSlideTreshold\n\n if (\n mainCarouselWrapperRef.current!.getBoundingClientRect().width >=\n items.length * getSlideValue() &&\n itemsPerSlide === 'fluid'\n ) {\n slideFluidEndReached.current = true\n }\n\n if (\n (prevItemTreshold || nextItemTreshold) &&\n getIfItemsNotFillTheCarousel() &&\n itemsPerSlide === 'fluid'\n ) {\n cancelDrag()\n resetAnimation()\n return\n }\n\n if (slideFluidEndReached.current && movement < 0) {\n if (nextItemTreshold) {\n cancelDrag()\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n }\n } else if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem()\n }\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem()\n }\n }\n }\n\n if (props.last && !props.pressed && !freeScroll) {\n resetAnimation()\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n },\n {\n enabled: !disableGestures,\n from: () => [carouselStyles.x.get(), carouselStyles.y.get()],\n },\n )\n\n // Perform some check on first mount\n useMount(() => {\n if (itemsPerSlide !== 'fluid' && !Number.isInteger(itemsPerSlide)) {\n throw new Error(`itemsPerSlide should be an integer.`)\n }\n if (itemsPerSlide > items.length) {\n throw new Error(\n `The itemsPerSlide prop can't be greater than the total length of the items you provide.`,\n )\n }\n if (itemsPerSlide < 1) {\n throw new Error(`The itemsPerSlide prop can't be less than 1.`)\n }\n if (!shouldResizeOnWindowResize) {\n console.warn(\n 'You set shouldResizeOnWindowResize={false}; be aware that the carousel could behave in a strange way if you also use the fullscreen functionality or if you change the mobile orientation.',\n )\n }\n if (initialActiveItem < 0) {\n console.warn('The initialActiveItem cannot be less than 0.')\n }\n if (initialActiveItem > items.length) {\n console.warn(\n 'The initialActiveItem cannot be greater than the total length of the items you provide.',\n )\n }\n })\n useMount(() => {\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n function handleVisibilityChange() {\n if (document.hidden) {\n windowIsHidden.current = true\n } else {\n windowIsHidden.current = false\n }\n }\n if (getIsBrowser()) {\n document.addEventListener('visibilitychange', handleVisibilityChange)\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange)\n }\n }\n })\n useMount(() => {\n initialWindowWidth.current = window.innerWidth\n if (initialActiveItem > 0 && initialActiveItem <= items.length) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n }\n })\n useEffect(() => {\n function resize() {\n setTimeout(handleResize)\n }\n if (shouldResizeOnWindowResize) {\n window.addEventListener('resize', resize)\n return () => {\n window.removeEventListener('resize', resize)\n }\n }\n }, [handleResize, shouldResizeOnWindowResize])\n useEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxis === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxis === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useEffect(() => {\n setTimeout(() => adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!), 150)\n }, [adjustCarouselWrapperPosition, carouselSlideAxis, itemsPerSlide])\n\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function setActiveItem(newItem: number) {\n activeItem.current = newItem\n }\n function getCurrentActiveItem() {\n return activeItem.current\n }\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setIsDragging(val: boolean) {\n isDragging.current = val\n }\n function getIsDragging() {\n return isDragging.current\n }\n function getPrevItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === 0) {\n return items.length - 1\n }\n return currentActiveItem - 1\n }\n function getNextItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === items.length - 1) {\n return 0\n }\n return currentActiveItem + 1\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n return itemIndex === activeItem - 1\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function slideToItem({\n from,\n to = -1,\n customTo,\n immediate = false,\n onRest = () => {},\n }: SlideToItemFnProps) {\n if (!immediate) {\n setActiveItem(to)\n setIsAnimating(true)\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: itemsPerSlide === 'fluid' ? -1 : to,\n id: itemsPerSlide === 'fluid' ? '' : items[to].id,\n },\n })\n }\n\n function getFromValue() {\n if (typeof from === 'number') {\n return {\n from: {\n [carouselSlideAxis]: from,\n },\n }\n }\n return {}\n }\n function getToValue() {\n if (typeof customTo === 'number') {\n return {\n [carouselSlideAxis]: customTo,\n }\n }\n return {\n [carouselSlideAxis]: -(getSlideValue() * to),\n }\n }\n\n setCarouselStyles.start({\n ...getFromValue(),\n to: getToValue(),\n immediate,\n onRest: val => {\n if (val.finished) {\n setIsDragging(false)\n setIsAnimating(false)\n onRest()\n if (!immediate) {\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: itemsPerSlide === 'fluid' ? -1 : getCurrentActiveItem(),\n id: itemsPerSlide === 'fluid' ? '' : items[getCurrentActiveItem()].id,\n },\n })\n }\n }\n },\n })\n if (enableThumbsWrapperScroll && withThumbs && !immediate) {\n handleThumbsScroll(to, getSlideActionType())\n }\n }\n function getIsLastItem() {\n return getCurrentActiveItem() === items.length - 1\n }\n function slideToPrevItem() {\n setSlideActionType('prev')\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const nextPrevValue = getCurrentSlidedValue() + getSlideValue() + 200\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft - getSlideValue()\n slideToItem({\n customTo: nextValue < 0 ? 0 : nextValue,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n })\n }\n if (slideFluidEndReached.current) {\n slideFluidEndReached.current = false\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n })\n }\n }\n }\n function slideToNextItem() {\n setSlideActionType('next')\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const willGoAfterLastFluidItem =\n Math.abs(getCurrentSlidedValue() - getSlideValue()) + 100 >=\n fluidTotalWrapperScrollValue.current\n\n if (freeScroll) {\n slideToItem({\n customTo: mainCarouselWrapperRef.current!.scrollLeft + getSlideValue(),\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (\n withLoop &&\n Math.abs(getCurrentSlidedValue() - getSlideValue()) >=\n items.length * getCarouselItemWidth()\n ) {\n const currentWidth = getCarouselItemWidth() * items.length\n slideToItem({\n from: getCurrentSlidedValue() + currentWidth,\n customTo: getCurrentSlidedValue() + currentWidth - getSlideValue(),\n })\n } else if (slideFluidEndReached.current) {\n return\n } else if (willGoAfterLastFluidItem) {\n slideFluidEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n })\n }\n }\n }\n function _slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n if (itemIndex === getCurrentActiveItem()) {\n return\n }\n\n const currentItem = findItemIndex(items[getCurrentActiveItem()].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n slideToItem({\n to: itemIndex,\n })\n }\n\n const contextProps = {\n useListenToCustomEvent,\n getIsFullscreen,\n enterFullscreen,\n exitFullscreen,\n getIsAnimating,\n getIsDragging,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem,\n slideToNextItem,\n ...(typeof itemsPerSlide === 'number'\n ? {\n slideToItem: _slideToItem,\n getIsActiveItem: (id: string) => {\n return findItemIndex(id) === getCurrentActiveItem()\n },\n getCurrentActiveItem: () => ({\n id: items[getCurrentActiveItem()].id,\n index: getCurrentActiveItem(),\n }),\n }\n : {}),\n }\n function getItemStyles() {\n if (typeof itemsPerSlide === 'number') {\n return {\n ...(carouselSlideAxis === 'x'\n ? { marginRight: `${gutter}px` }\n : { marginBottom: `${gutter}px` }),\n flex: `1 0 calc(100% / ${itemsPerSlide} - ${\n (gutter * (itemsPerSlide - 1)) / itemsPerSlide\n }px)`,\n }\n }\n return {\n ...(carouselSlideAxis === 'x'\n ? { marginRight: `${gutter}px` }\n : { marginBottom: `${gutter}px` }),\n }\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutter * 2}px)`\n return {\n width: carouselSlideAxis === 'x' ? percentValue : '100%',\n height: carouselSlideAxis === 'y' ? percentValue : '100%',\n }\n }\n function handleCarouselFragmentRef(ref: HTMLDivElement | null) {\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref)\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxis === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxis].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (!touchAction) {\n if (carouselSlideAxis === 'x') {\n return 'pan-y'\n }\n return 'pan-x'\n }\n return touchAction\n }\n const carouselFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxis === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </UseSpringCarouselContext.Provider>\n )\n const thumbsFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseSpringCarouselContext.Provider>\n )\n\n return {\n ...(contextProps as ReturnHook<T>),\n carouselFragment,\n thumbsFragment,\n }\n}\n\nexport function useSpringCarouselContext<T>() {\n const context = useContext(UseSpringCarouselContext)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context as ReturnHook<T>\n}\n","import { createContext, useRef, useState, useContext } from 'react'\nimport { useTransition, animated, config } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useThumbsModule, useFullscreenModule } from './modules'\nimport {\n UseTransitionCarouselContextProps,\n UseTransitionCarouselProps,\n SlideActionType,\n} from './types'\n\nconst UseTransitionCarouselContext = createContext<\n UseTransitionCarouselContextProps | undefined\n>(undefined)\n\nexport function useTransitionCarouselContext() {\n const context = useContext(UseTransitionCarouselContext)\n\n if (!context) {\n throw new Error(`useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.`)\n }\n\n return context\n}\n\nexport function useTransitionCarousel({\n items,\n withLoop = false,\n withThumbs = false,\n springConfig = config.default,\n thumbsSlideAxis = 'x',\n enableThumbsWrapperScroll = true,\n draggingSlideTreshold = 50,\n prepareThumbsData,\n toPrevItemSpringProps,\n toNextItemSpringProps,\n disableGestures = false,\n CustomThumbsWrapperComponent,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'relative',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'relative',\n },\n leave: {\n opacity: 0,\n position: 'absolute',\n },\n },\n}: UseTransitionCarouselProps) {\n const slideActionType = useRef<SlideActionType>('next')\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const isAnimating = useRef(false)\n const [activeItem, setActiveItem] = useState(0)\n\n const { emitObservable, useListenToCustomEvent } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n CustomThumbsWrapperComponent,\n })\n\n const bindSwipe = useDrag(\n ({ last, movement: [mx] }) => {\n if (getIsAnimating()) {\n return\n }\n\n if (last) {\n const prevItemTreshold = mx > draggingSlideTreshold\n const nextItemTreshold = mx < -draggingSlideTreshold\n const isFirstItem = activeItem === 0\n const isLastItem = activeItem === items.length - 1\n\n if (nextItemTreshold) {\n if (!withLoop && isLastItem) {\n return\n }\n\n slideToNextItem()\n emitObservable({\n eventName: 'onLeftSwipe',\n })\n } else if (prevItemTreshold) {\n if (!withLoop && isFirstItem) {\n return\n }\n\n slideToPrevItem()\n emitObservable({\n eventName: 'onRightSwipe',\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n },\n )\n\n function getTransitionConfig() {\n const slideActionType = getSlideActionType()\n\n if (slideActionType === 'prev' && toPrevItemSpringProps) {\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...toPrevItemSpringProps.from,\n },\n enter: {\n ...toPrevItemSpringProps.enter,\n },\n leave: {\n ...toPrevItemSpringProps.leave,\n },\n }\n }\n\n if (slideActionType === 'next' && toNextItemSpringProps) {\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...toNextItemSpringProps.from,\n },\n enter: {\n ...toNextItemSpringProps.enter,\n },\n leave: {\n ...toNextItemSpringProps.leave,\n },\n }\n }\n\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...springAnimationProps.from,\n },\n enter: {\n ...springAnimationProps.enter,\n },\n leave: {\n ...springAnimationProps.leave,\n },\n }\n }\n\n const transitions = useTransition(activeItem, {\n config: springConfig,\n ...getTransitionConfig(),\n onStart: () => setIsAnimating(true),\n keys: null,\n onRest: val => {\n if (val.finished) {\n setIsAnimating(false)\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: activeItem,\n id: items[activeItem].id,\n },\n })\n }\n },\n })\n const itemsFragment = transitions((styles, item) => (\n <animated.div\n style={{\n ...styles,\n flex: '1 0 100%',\n width: '100%',\n height: '100%',\n }}\n >\n {items[item].renderItem}\n </animated.div>\n ))\n\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (itemIndex === activeItem) {\n return\n }\n\n const currentItem = findItemIndex(items[activeItem].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: newActiveItem,\n id: items[itemIndex].id,\n },\n })\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n setActiveItem(itemIndex)\n\n if (enableThumbsWrapperScroll && withThumbs) {\n handleThumbsScroll(itemIndex)\n }\n }\n function slideToNextItem() {\n const isLastItem = activeItem === items.length - 1\n\n if (withLoop) {\n setSlideActionType('next')\n if (isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: 0,\n id: items[0].id,\n },\n })\n setActiveItem(0)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setActiveItem(activeItem + 1)\n }\n } else {\n if (!isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setSlideActionType('next')\n setActiveItem(activeItem + 1)\n }\n }\n }\n function slideToPrevItem() {\n const isFirstItem = activeItem === 0\n\n if (withLoop) {\n setSlideActionType('prev')\n if (isFirstItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(items.length - 1)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n } else {\n if (!isFirstItem) {\n setSlideActionType('prev')\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n }\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n\n return itemIndex === activeItem - 1\n }\n\n const contextProps: UseTransitionCarouselContextProps = {\n activeItem,\n slideToItem,\n slideToNextItem,\n slideToPrevItem,\n enterFullscreen,\n exitFullscreen,\n useListenToCustomEvent,\n getIsNextItem,\n getIsPrevItem,\n getIsAnimating,\n getIsFullscreen,\n getIsActiveItem: id => {\n return findItemIndex(id) === activeItem\n },\n getCurrentActiveItem: () => ({\n id: items[activeItem].id,\n index: activeItem,\n }),\n }\n\n const carouselFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n {...bindSwipe()}\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n }}\n >\n {itemsFragment}\n </div>\n </UseTransitionCarouselContext.Provider>\n )\n\n const thumbsFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseTransitionCarouselContext.Provider>\n )\n\n return {\n carouselFragment,\n thumbsFragment,\n ...contextProps,\n }\n}\n"],"names":["useCustomEventsModule","eventsObserverRef","useRef","Subject","useListenToCustomEvent","fn","useEffect","subscribe","current","unsubscribe","emitObservable","data","next","useFullscreenModule","mainCarouselWrapperRef","handleResize","isFullscreen","setIsFullscreen","_isFullscreen","handleFullscreenChange","document","fullscreenElement","eventName","screenfull","isEnabled","on","off","enterFullscreen","elementRef","request","exitFullscreen","exit","getIsFullscreen","useMount","callback","isMounted","clean","InternalWrapper","forwardRef","children","rest","ref","_jsx","animated","div","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","itemsPerSlide","getFluidWrapperScrollValue","getSlideValue","CustomThumbsWrapperComponent","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","Wrapper","thumbsFragment","className","onWheel","stop","style","display","flex","position","flexDirection","overflowX","overflowY","maxHeight","getPreparedItems","_items","map","i","id","renderThumb","handlePrepareThumbsDate","thumbId","handleThumbsScroll","activeItem","actionType","totalScrollableValue","nextValue","start","from","[object Object]","to","thumbNode","querySelector","thumbWrapper","offsetDimension","scrollDirection","thumbOffsetPosition","offsetDirection","getThumbOffsetPosition","thumbScrollDimension","getThumbScrollDimension","getScrollFromValue","scrollDimensionProperty","length","getScrollToValue","val","scrollLeft","scrollTop","UseSpringCarouselContext","createContext","undefined","UseTransitionCarouselContext","withLoop","draggingSlideTreshold","default","shouldResizeOnWindowResize","enableThumbsWrapperScroll","carouselSlideAxis","initialActiveItem","initialStartingPosition","disableGestures","gutter","startEndGutter","touchAction","slideAmount","freeScroll","slideActionType","internalItems","carouselTrackWrapperRef","isDragging","isAnimating","windowIsHidden","currentWindowWidth","fluidTotalWrapperScrollValue","slideFluidEndReached","initialWindowWidth","carouselStyles","setCarouselStyles","getMainCarouselWrapperWidth","useCallback","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","window","innerWidth","immediate","diff","_thumbsFragment","getWrapperScrollDirection","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","cancelDrag","cancel","resetAnimation","getSlideActionType","setIsDragging","direction","setSlideActionType","prevItemTreshold","nextItemTreshold","width","getIsLastItem","slideToNextItem","slideToPrevItem","last","pressed","enabled","type","setActiveItem","newItem","setIsAnimating","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","slideToItem","customTo","onRest","nextItem","index","finished","currentItem","nextPrevValue","willGoAfterLastFluidItem","currentWidth","isInteger","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","resize","setTimeout","contextProps","getIsAnimating","getIsDragging","getIsNextItem","itemIndex","getIsPrevItem","_item","getIsActiveItem","carouselFragment","Provider","height","percentValue","getAnimatedWrapperStyles","renderItem","marginRight","marginBottom","context","useContext","toPrevItemSpringProps","toNextItemSpringProps","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","keys","transitions","styles","newActiveItem","overflow"],"mappings":"0oBAIgBA,IACd,MAAMC,EAAoBC,SAAO,IAAIC,WAarC,MAAO,CACLC,uBAZF,SAAgCC,GAC9BC,aAAU,KACR,MAAMC,EAAYN,EAAkBO,QAAQD,UAAUF,GACtD,MAAO,IAAME,EAAUE,gBACtB,CAACJ,KASJK,eANuCC,IACvCV,EAAkBO,QAAQI,KAAKD,cCLnBE,GAAoBC,uBAClCA,EAAsBJ,eACtBA,EAAcK,aACdA,IAEA,MAAMC,EAAed,UAAO,GAkC5B,SAASe,EAAgBC,GACvBF,EAAaR,QAAUU,EAiBzB,OAlDAZ,aAAU,KACR,SAASa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MAAO,CACLC,QAAS,OACTE,SAAU,WACV6G,MAAO,OACP8C,OAAQ,OACR4B,SAAU,qBAGXR,sBAaLtL,eAPAjC,MAACkF,EAA6BgH,wBAAS7K,MAAOoK,aAC3CtD,eAOAsD,8CAxYL,MAAMgB,EAAUC,aAAWxH,GAE3B,IAAKuH,EACH,MAAM,IAAI1K,MAAM,+KAIlB,OAAO0K"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-spring-carousel",
3
- "version": "1.9.29-beta39",
3
+ "version": "1.9.29-beta42",
4
4
  "description": "A new Carousel experience for the web",
5
5
  "homepage": "https://react-spring-carousel-js.emilianobucci.com",
6
6
  "repository": "https://github.com/Emiliano-Bucci/react-spring-carousel-js",
@@ -17,9 +17,8 @@
17
17
  "react-spring-slider",
18
18
  "animated"
19
19
  ],
20
- "main": "dist/index.umd.js",
21
- "module": "dist/index.es.js",
22
- "types": "dist",
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
23
22
  "files": [
24
23
  "dist"
25
24
  ],
package/dist/index.es.js DELETED
@@ -1,2 +0,0 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useRef as t,useEffect as n,forwardRef as r,createContext as i,useCallback as o,useContext as s,useState as u}from"react";import{animated as l,useSpring as c,config as a,useTransition as d}from"react-spring";import{useDrag as m}from"@use-gesture/react";import{Subject as f}from"rxjs";import h from"screenfull";function p(){const e=t(new f);return{useListenToCustomEvent:function(t){n((()=>{const n=e.current.subscribe(t);return()=>n.unsubscribe()}),[t])},emitObservable:t=>{e.current.next(t)}}}function g({mainCarouselWrapperRef:e,emitObservable:r,handleResize:i}){const o=t(!1);function s(e){o.current=e}return n((()=>{function e(){document.fullscreenElement&&(s(!0),r({eventName:"onFullscreenChange",isFullscreen:!0}),i&&i()),document.fullscreenElement||(s(!1),r({eventName:"onFullscreenChange",isFullscreen:!1}),i&&i())}if(h.isEnabled)return h.on("change",e),()=>{h.isEnabled&&h.off("change",e)}})),{enterFullscreen:function(t){h.isEnabled&&h.request(t||e.current)},exitFullscreen:function(){h.isEnabled&&h.exit()},getIsFullscreen:function(){return o.current}}}function b(e){const r=t(!1);n((()=>{if(!r.current){const t=e();return r.current=!0,()=>{t&&t()}}}),[])}const x=r((({children:t,...n},r)=>e(l.div,Object.assign({},n,{ref:r},{children:t}),void 0)));function v({items:n,withThumbs:r,thumbsSlideAxis:i="x",springConfig:o,prepareThumbsData:s,itemsPerSlide:u,getFluidWrapperScrollValue:a=(()=>0),getSlideValue:d=(()=>0),CustomThumbsWrapperComponent:m}){const f=t(null),[h,p]=c((()=>({x:0,y:0,config:o,onChange:({value:e})=>{f.current&&(f.current["x"===i?"scrollLeft":"scrollTop"]=Math.abs(e[i]))}})));function g(){return f.current["x"===i?"scrollLeft":"scrollTop"]}function v(){return Math.round(Number(f.current?.["x"===i?"scrollWidth":"scrollHeight"])-f.current.getBoundingClientRect()["x"===i?"width":"height"])}function w(){const e=Math.round(a()/d());return v()/e}b((()=>{if(r&&!f.current)throw new Error("The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.")}));const T=m?l(m):x;return{thumbsFragment:r?e(T,Object.assign({ref:f,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{h[i].stop()},style:{display:"flex",flex:1,position:"relative",flexDirection:"x"===i?"row":"column",..."x"===i?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"}}},{children:function(){function e(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return s?s(e(n)):e(n)}().map((({id:t,renderThumb:n})=>{const r=`thumb-${t}`;return e("div",Object.assign({id:r},{children:n}),r)}))}),void 0):null,handleThumbsScroll:function(e,t){if("fluid"===u){const e=v();if("next"===t){const t=g()+w();p.start({from:{[i]:g()},to:{[i]:t>e?e:t}})}if("prev"===t){const e=g()-w();p.start({from:{[i]:g()},to:{[i]:e<0?0:e}})}}else{const t=f.current.querySelector(`#thumb-${n[e].id}`);if(t){const r=f.current,o="x"===i?"offsetWidth":"offsetHeight",s="x"===i?"scrollLeft":"scrollTop",u=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:t,offsetDimension:o,offsetDirection:"x"===i?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:r,offsetDimension:o});p.start({from:{[i]:function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:r,scrollDirection:s})},to:{[i]:function({thumbWrapper:t,thumbOffsetPosition:r,thumbScrollDimension:o,offsetDimension:s}){const u="x"===i?"scrollWidth":"scrollHeight";return e===n.length-1||r-o>t[u]-t[s]?t[u]-t[s]:0===e?0:r-o}({thumbWrapper:r,thumbOffsetPosition:u,thumbScrollDimension:l,offsetDimension:o})},onChange:e=>{"x"===i?f.current.scrollLeft=e.x:f.current.scrollTop=e.y}})}}}}}const w=i(void 0);function T({itemsPerSlide:r=1,items:i,withLoop:s=!1,draggingSlideTreshold:u=140,springConfig:d=a.default,shouldResizeOnWindowResize:f=!0,withThumbs:h=!1,enableThumbsWrapperScroll:x=!0,carouselSlideAxis:T="x",thumbsSlideAxis:y="x",prepareThumbsData:C,initialActiveItem:S=0,initialStartingPosition:I="start",disableGestures:A=!1,gutter:W=0,startEndGutter:N=0,touchAction:F,slideAmount:E,freeScroll:L=!1,CustomThumbsWrapperComponent:R}){const D=t("initial"),O=s?i.length===r?[...i,...i,...i,...i,...i]:[...i,...i,...i]:i,P=t(S),j=t(null),M=t(null),$=t(!1),z=t(!1),B=t(!1),H=t(0),k=t(0),V=t(!1),q=t(0),[G,Y]=c((()=>({y:0,x:0,config:d,onChange:({value:e})=>{j.current&&L&&(j.current["x"===T?"scrollLeft":"scrollTop"]=Math.abs(e[T]))}})));const X=o((()=>{if(!j.current)throw new Error("mainCarouselWrapperRef is not available");return j.current.getBoundingClientRect()["x"===T?"width":"height"]}),[T]),J=o((()=>{const e=M.current?.querySelector(".use-spring-carousel-item");if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===T?"width":"height"]+W}),[T,W]),K=o((()=>G[T].get()),[T,G]),Q=o((()=>J()*i.length<X()),[J,X,i.length]),U=o((()=>Math.round(Number(M.current?.["x"===T?"scrollWidth":"scrollHeight"])-M.current.getBoundingClientRect()["x"===T?"width":"height"])),[T]),Z=o((()=>0===he()),[]),_=o((()=>{if(!M.current)return 0;const e=J();if("fluid"===r&&"number"==typeof E){if(E<e)throw new Error("slideAmount must be greater than the width of a single item.");return E}return e}),[J,r,E]),ee=o((e=>{const t="x"===T?"left":"top";function n(){return J()*i.length}function o(n){e.style.top="0px",e.style.left="0px",s&&(e.style[t]=`-${n-N}px`)}function u(){o(n())}if("fluid"!==r&&"number"==typeof r){if(r>1)switch(I){default:case"start":u();break;case"center":o(n()-_()*Math.round((r-1)/2));break;case"end":o(n()-_()*Math.round(r-1))}else u()}else u()}),[T,r,J,i.length,N,_,I,s]),te=o((()=>{if(window.innerWidth!==H.current&&!L){if(H.current=window.innerWidth,"fluid"===r){if(Q())return void Y.start({immediate:!0,[T]:0});k.current=U();const e=H.current-q.current;if(V.current){const e=-k.current;Y.start({immediate:!0,[T]:e})}else{const t=K()+e;Y.start({immediate:!0,[T]:t})}q.current=window.innerWidth}else Y.start({immediate:!0,x:0,y:0}),Y.start({immediate:!0,[T]:-_()*he()});ee(M.current)}}),[r,Q,U,L,Y,T,K,_,ee]),{useListenToCustomEvent:ne,emitObservable:re}=p(),{enterFullscreen:ie,exitFullscreen:oe,getIsFullscreen:se}=g({mainCarouselWrapperRef:j,emitObservable:re,handleResize:te}),{thumbsFragment:ue,handleThumbsScroll:le}=v({withThumbs:h,items:i,thumbsSlideAxis:y,springConfig:d,prepareThumbsData:C,itemsPerSlide:r,getFluidWrapperScrollValue:U,getSlideValue:_,CustomThumbsWrapperComponent:R});function ce(){if(!j.current)throw new Error("Missing mainCarouselWrapperRef.current");return j.current["x"===T?"scrollLeft":"scrollTop"]}const ae=m((e=>{const t=e.dragging,n=e.offset["x"===T?0:1],o=e.movement["x"===T?0:1];function l(){e.cancel()}function c(){"fluid"===r?Q()||Z()&&"prev"===me()?Y.start({[T]:0}):V.current?Y.start({[T]:-k.current}):Y.start({[T]:K()}):Y.start({[T]:-he()*_()})}if(t){ge(!0),re({eventName:"onDrag",slideActionType:me(),...e});const t=e.direction["x"===T?0:1];de(t>0?"prev":"next"),L?0===ce()&&t>0?l():Y.start({from:{[T]:ce()},to:{[T]:t>0?ce()-Math.abs(n):ce()+Math.abs(n)}}):Y.start({[T]:n});const a=o>u,d=o<-u;if(j.current.getBoundingClientRect().width>=i.length*_()&&"fluid"===r&&(V.current=!0),(a||d)&&Q()&&"fluid"===r)return l(),void c();V.current&&n<0?d&&(l(),Y.start({[T]:-k.current})):d?(l(),!s&&Te()?c():Ce()):a&&(l(),!s&&Z()?c():ye())}!e.last||e.pressed||L||(c(),re({eventName:"onDrag",slideActionType:me(),...e}))}),{enabled:!A,from:()=>[G.x.get(),G.y.get()]});function de(e){D.current=e}function me(){return D.current}function fe(e){P.current=e}function he(){return P.current}function pe(e){z.current=e}function ge(e){$.current=e}function be(){const e=he();return 0===e?i.length-1:e-1}function xe(){const e=he();return e===i.length-1?0:e+1}function ve(e){return i.findIndex((t=>t.id===e))}function we({from:e,to:t=-1,customTo:n,immediate:o=!1,onRest:s=(()=>{})}){o||(fe(t),pe(!0),re({eventName:"onSlideStartChange",slideActionType:me(),nextItem:{index:"fluid"===r?-1:t,id:"fluid"===r?"":i[t].id}})),Y.start({..."number"==typeof e?{from:{[T]:e}}:{},to:"number"==typeof n?{[T]:n}:{[T]:-_()*t},immediate:o,onRest:e=>{e.finished&&(ge(!1),pe(!1),s(),o||re({eventName:"onSlideChange",slideActionType:me(),currentItem:{index:"fluid"===r?-1:he(),id:"fluid"===r?"":i[he()].id}}))}}),x&&h&&!o&&le(t,me())}function Te(){return he()===i.length-1}function ye(){if(de("prev"),"fluid"===r){if(Q())return;const e=K()+_()+200;if(L){const e=j.current.scrollLeft-_();we({customTo:e<0?0:e,from:j.current.scrollLeft})}else we(e>=0?s?{from:K()-J()*i.length,customTo:K()-J()*i.length+_()}:{customTo:0}:{customTo:K()+_()});V.current&&(V.current=!1)}else{if(!s&&0===he()||B.current)return;Z()?we({from:K()-_()*i.length,to:i.length-1}):we({to:be()})}}function Ce(){if(de("next"),"fluid"===r){if(Q())return;const e=Math.abs(K()-_())+100>=k.current;if(L)we({customTo:j.current.scrollLeft+_(),from:j.current.scrollLeft});else if(s&&Math.abs(K()-_())>=i.length*J()){const e=J()*i.length;we({from:K()+e,customTo:K()+e-_()})}else{if(V.current)return;e?(V.current=!0,we({customTo:-k.current})):we({customTo:K()-_()})}}else{if(!s&&he()===O.length-1||B.current)return;Te()?we({from:K()+_()*i.length,to:0}):we({to:xe()})}}b((()=>{if("fluid"!==r&&!Number.isInteger(r))throw new Error("itemsPerSlide should be an integer.");if(r>i.length)throw new Error("The itemsPerSlide prop can't be greater than the total length of the items you provide.");if(r<1)throw new Error("The itemsPerSlide prop can't be less than 1.");f||console.warn("You set shouldResizeOnWindowResize={false}; be aware that the carousel could behave in a strange way if you also use the fullscreen functionality or if you change the mobile orientation."),S<0&&console.warn("The initialActiveItem cannot be less than 0."),S>i.length&&console.warn("The initialActiveItem cannot be greater than the total length of the items you provide.")})),b((()=>{function e(){document.hidden?B.current=!0:B.current=!1}if(k.current=U(),"undefined"!=typeof window)return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),b((()=>{q.current=window.innerWidth,S>0&&S<=i.length&&(we({to:S,immediate:!0}),fe(S))})),n((()=>{function e(){setTimeout(te)}if(f)return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[te,f]),n((()=>{M.current&&("x"===T&&(M.current.style.top="0px"),"y"===T&&(M.current.style.left="0px"))}),[T]),n((()=>{setTimeout((()=>ee(M.current)),150)}),[ee,T,r]);const Se={useListenToCustomEvent:ne,getIsFullscreen:se,enterFullscreen:ie,exitFullscreen:oe,getIsAnimating:function(){return z.current},getIsDragging:function(){return $.current},getIsNextItem:function(e){const t=ve(e),n=he();return s&&n===i.length-1?0===t:t===n+1},getIsPrevItem:function(e){const t=ve(e),n=he();return s&&0===n?t===i.length-1:t===n-1},slideToPrevItem:ye,slideToNextItem:Ce,..."number"==typeof r?{slideToItem:function(e){let t=0;if(t="string"==typeof e?i.findIndex((t=>t.id===e)):e,t>=i.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(t===he())return;const n=ve(i[he()].id);de(ve(i[t].id)>n?"next":"prev"),we({to:t})},getIsActiveItem:e=>ve(e)===he(),getCurrentActiveItem:()=>({id:i[he()].id,index:he()})}:{}};const Ie=e(w.Provider,Object.assign({value:Se},{children:e("div",Object.assign({ref:j,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},L?{onWheel(){G[T].stop()}}:{},{style:{display:"flex",position:"relative",width:"100%",height:"100%",...L?"x"===T?{overflowX:"auto"}:{overflowY:"auto"}:{}}},{children:e(l.div,Object.assign({},ae(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:function(e){e&&(M.current=e,ee(e))},style:{display:"flex",position:"relative",touchAction:F||("x"===T?"pan-y":"pan-x"),flexDirection:"x"===T?"row":"column",...function(){const e=`calc(100% - ${2*N}px)`;return{width:"x"===T?e:"100%",height:"y"===T?e:"100%"}}(),...L?{}:G}},{children:O.map((({id:t,renderItem:n},i)=>e("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:{display:"flex",position:"relative",..."number"==typeof r?{..."x"===T?{marginRight:`${W}px`}:{marginBottom:`${W}px`},flex:`1 0 calc(100% / ${r} - ${W*(r-1)/r}px)`}:{..."x"===T?{marginRight:`${W}px`}:{marginBottom:`${W}px`}}}},{children:n}),`${t}-${i}`)))}),void 0)}),void 0)}),void 0),Ae=e(w.Provider,Object.assign({value:Se},{children:ue}),void 0);return{...Se,carouselFragment:Ie,thumbsFragment:Ae}}function y(){const e=s(w);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e}const C=i(void 0);function S(){const e=s(C);if(!e)throw new Error("useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.");return e}function I({items:n,withLoop:r=!1,withThumbs:i=!1,springConfig:o=a.default,thumbsSlideAxis:s="x",enableThumbsWrapperScroll:c=!0,draggingSlideTreshold:f=50,prepareThumbsData:h,toPrevItemSpringProps:b,toNextItemSpringProps:x,disableGestures:w=!1,CustomThumbsWrapperComponent:T,springAnimationProps:y={initial:{opacity:1,position:"relative"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"relative"},leave:{opacity:0,position:"absolute"}}}){const S=t("next"),I=t(null),A=t(!1),[W,N]=u(0),{emitObservable:F,useListenToCustomEvent:E}=p(),{enterFullscreen:L,exitFullscreen:R,getIsFullscreen:D}=g({emitObservable:F,mainCarouselWrapperRef:I}),{thumbsFragment:O,handleThumbsScroll:P}=v({items:n,withThumbs:i,thumbsSlideAxis:s,springConfig:o,prepareThumbsData:h,CustomThumbsWrapperComponent:T}),j=m((({last:e,movement:[t]})=>{if(!$()&&e){const e=t>f,i=t<-f,o=0===W,s=W===n.length-1;if(i){if(!r&&s)return;k(),F({eventName:"onLeftSwipe"})}else if(e){if(!r&&o)return;V(),F({eventName:"onRightSwipe"})}}}),{enabled:!w});const M=d(W,{config:o,...function(){const e=H();return"prev"===e&&b?{initial:{...y.initial},from:{...b.from},enter:{...b.enter},leave:{...b.leave}}:"next"===e&&x?{initial:{...y.initial},from:{...x.from},enter:{...x.enter},leave:{...x.leave}}:{initial:{...y.initial},from:{...y.from},enter:{...y.enter},leave:{...y.leave}}}(),onStart:()=>z(!0),keys:null,onRest:e=>{e.finished&&(z(!1),F({eventName:"onSlideChange",slideActionType:H(),currentItem:{index:W,id:n[W].id}}))}})(((t,r)=>e(l.div,Object.assign({style:{...t,flex:"1 0 100%",width:"100%",height:"100%"}},{children:n[r].renderItem}),void 0)));function $(){return A.current}function z(e){A.current=e}function B(e){S.current=e}function H(){return S.current}function k(){const e=W===n.length-1;r?(B("next"),e?(F({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:0,id:n[0].id}}),N(0)):(F({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:W+1,id:n[W+1].id}}),N(W+1))):e||(F({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:W+1,id:n[W+1].id}}),B("next"),N(W+1))}function V(){const e=0===W;r?(B("prev"),e?(F({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:W-1,id:n[W-1].id}}),N(n.length-1)):(F({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:W-1,id:n[W-1].id}}),N(W-1))):e||(B("prev"),F({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:W-1,id:n[W-1].id}}),N(W-1))}function q(e){return n.findIndex((t=>t.id===e))}const G={activeItem:W,slideToItem:function(e){let t=0;if(t="string"==typeof e?n.findIndex((t=>t.id===e)):e,t>=n.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(t===W)return;const r=q(n[W].id),o=q(n[t].id);F({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:o,id:n[t].id}}),B(o>r?"next":"prev"),N(t),c&&i&&P(t)},slideToNextItem:k,slideToPrevItem:V,enterFullscreen:L,exitFullscreen:R,useListenToCustomEvent:E,getIsNextItem:function(e){const t=q(e);return r&&W===n.length-1?0===t:t===W+1},getIsPrevItem:function(e){const t=q(e);return r&&0===W?t===n.length-1:t===W-1},getIsAnimating:$,getIsFullscreen:D,getIsActiveItem:e=>q(e)===W,getCurrentActiveItem:()=>({id:n[W].id,index:W})};return{carouselFragment:e(C.Provider,Object.assign({value:G},{children:e("div",Object.assign({ref:I},j(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:M}),void 0)}),void 0),thumbsFragment:e(C.Provider,Object.assign({value:G},{children:O}),void 0),...G}}export{T as useSpringCarousel,y as useSpringCarouselContext,I as useTransitionCarousel,S as useTransitionCarouselContext};
2
- //# sourceMappingURL=index.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/modules/useCustomEventsModule.tsx","../src/modules/useFullscreenModule.tsx","../src/utils.ts","../src/modules/useThumbsModule.tsx","../src/useSpringCarousel.tsx","../src/useTransitionCarousel.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { Subject } from 'rxjs'\nimport { EventsObservableProps, ObservableCallbackFn, EmitObservableFn } from '../types'\n\nexport function useCustomEventsModule() {\n const eventsObserverRef = useRef(new Subject<EventsObservableProps>())\n\n function useListenToCustomEvent(fn: ObservableCallbackFn) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, MutableRefObject, useEffect } from 'react'\nimport screenfull from 'screenfull'\nimport { EmitObservableFn } from '../types'\n\ntype FullscreenModule = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn\n handleResize?(): void\n}\n\nexport function useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule) {\n const isFullscreen = useRef(false)\n\n useEffect(() => {\n function handleFullscreenChange() {\n if (document.fullscreenElement) {\n setIsFullscreen(true)\n emitObservable({\n eventName: 'onFullscreenChange',\n isFullscreen: true,\n })\n\n handleResize && handleResize()\n }\n\n if (!document.fullscreenElement) {\n setIsFullscreen(false)\n emitObservable({\n eventName: 'onFullscreenChange',\n isFullscreen: false,\n })\n handleResize && handleResize()\n }\n }\n\n if (screenfull.isEnabled) {\n screenfull.on('change', handleFullscreenChange)\n return () => {\n if (screenfull.isEnabled) {\n screenfull.off('change', handleFullscreenChange)\n }\n }\n }\n })\n\n function setIsFullscreen(_isFullscreen: boolean) {\n isFullscreen.current = _isFullscreen\n }\n\n function getIsFullscreen() {\n return isFullscreen.current\n }\n\n function enterFullscreen(elementRef?: HTMLElement) {\n if (screenfull.isEnabled) {\n screenfull.request((elementRef || mainCarouselWrapperRef.current) as Element)\n }\n }\n\n function exitFullscreen() {\n screenfull.isEnabled && screenfull.exit()\n }\n\n return {\n enterFullscreen,\n exitFullscreen,\n getIsFullscreen,\n }\n}\n","import { useRef, useEffect } from 'react'\n\ntype Callback = () => void | (() => void)\n\nexport function useMount(callback: Callback) {\n const isMounted = useRef(false)\n\n useEffect(() => {\n if (!isMounted.current) {\n const clean = callback()\n isMounted.current = true\n\n return () => {\n clean && clean()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\nexport function getIsBrowser() {\n return typeof window !== 'undefined'\n}\n","import { forwardRef, HTMLAttributes, useRef } from 'react'\nimport { useSpring, SpringConfig, animated } from 'react-spring'\nimport { useMount } from 'src/utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringThumbItem,\n PrepareThumbsData,\n UseSpringCarouselItems,\n SlideActionType,\n} from '../types'\n\ntype OffsetDimension = 'offsetWidth' | 'offsetHeight'\ntype OffsetDirection = 'offsetLeft' | 'offsetTop'\ntype ScrollDirection = 'scrollLeft' | 'scrollTop'\n\ntype Props = {\n items: UseSpringCarouselItems['items']\n withThumbs: boolean\n thumbsSlideAxis: UseSpringCarouselProps['thumbsSlideAxis']\n springConfig: SpringConfig\n prepareThumbsData?: PrepareThumbsData\n itemsPerSlide?: UseSpringCarouselProps['itemsPerSlide']\n CustomThumbsWrapperComponent?: UseSpringCarouselProps['CustomThumbsWrapperComponent']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\ntype WrapperProps = {\n children: React.ReactNode\n} & HTMLAttributes<HTMLDivElement>\n\nconst InternalWrapper = forwardRef<HTMLDivElement, WrapperProps>(\n ({ children, ...rest }, ref) => {\n return (\n <animated.div {...rest} ref={ref}>\n {children}\n </animated.div>\n )\n },\n)\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n itemsPerSlide,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n CustomThumbsWrapperComponent,\n}: Props) {\n const internalThumbsWrapperRef = useRef<HTMLDivElement | null>(null)\n const [thumbListStyles, setThumbListStyles] = useSpring(() => ({\n x: 0,\n y: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (internalThumbsWrapperRef.current) {\n internalThumbsWrapperRef.current[\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[thumbsSlideAxis])\n }\n },\n }))\n\n useMount(() => {\n if (withThumbs && !internalThumbsWrapperRef.current) {\n throw new Error(\n \"The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.\",\n )\n }\n })\n\n function getCurrentThumbScrollValue() {\n return internalThumbsWrapperRef.current![\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getThumbsTotalScrollableValue() {\n return Math.round(\n Number(\n internalThumbsWrapperRef.current?.[\n thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n internalThumbsWrapperRef.current!.getBoundingClientRect()[\n thumbsSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }\n\n function getThumbSlideValue() {\n const thumbSlideTotal = Math.round(getFluidWrapperScrollValue() / getSlideValue())\n const totalScrollableValue = getThumbsTotalScrollableValue()\n return totalScrollableValue / thumbSlideTotal\n }\n\n function handleThumbsScroll(activeItem: number, actionType?: SlideActionType) {\n if (itemsPerSlide === 'fluid') {\n const totalScrollableValue = getThumbsTotalScrollableValue()\n\n if (actionType === 'next') {\n const nextValue = getCurrentThumbScrollValue() + getThumbSlideValue()\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getCurrentThumbScrollValue(),\n },\n to: {\n [thumbsSlideAxis]:\n nextValue > totalScrollableValue ? totalScrollableValue : nextValue,\n },\n })\n }\n if (actionType === 'prev') {\n const nextValue = getCurrentThumbScrollValue() - getThumbSlideValue()\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getCurrentThumbScrollValue(),\n },\n to: {\n [thumbsSlideAxis]: nextValue < 0 ? 0 : nextValue,\n },\n })\n }\n } else {\n function getOffsetDirection() {\n return thumbsSlideAxis === 'x' ? 'offsetLeft' : 'offsetTop'\n }\n function getOffsetDimension() {\n return thumbsSlideAxis === 'x' ? 'offsetWidth' : 'offsetHeight'\n }\n function getScrollDirecton() {\n return thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n }\n function getThumbNode() {\n return internalThumbsWrapperRef.current!.querySelector(\n `#thumb-${items[activeItem].id}`,\n ) as HTMLElement\n }\n function getThumbOffsetPosition({\n thumbNode,\n offsetDirection,\n offsetDimension,\n }: {\n thumbNode: HTMLElement\n offsetDirection: OffsetDirection\n offsetDimension: OffsetDimension\n }) {\n return thumbNode[offsetDirection] + thumbNode[offsetDimension] / 2\n }\n function getThumbScrollDimension({\n thumbWrapper,\n offsetDimension,\n }: {\n thumbWrapper: HTMLDivElement\n offsetDimension: OffsetDimension\n }) {\n return thumbWrapper[offsetDimension] / 2\n }\n function getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n }: {\n thumbWrapper: HTMLDivElement\n scrollDirection: ScrollDirection\n }) {\n return thumbWrapper[scrollDirection]\n }\n function getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n }: {\n thumbWrapper: HTMLDivElement\n thumbOffsetPosition: number\n thumbScrollDimension: number\n offsetDimension: OffsetDimension\n }) {\n const scrollDimensionProperty =\n thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n\n if (\n activeItem === items.length - 1 ||\n thumbOffsetPosition - thumbScrollDimension >\n thumbWrapper[scrollDimensionProperty] - thumbWrapper[offsetDimension]\n ) {\n return thumbWrapper[scrollDimensionProperty] - thumbWrapper[offsetDimension]\n }\n if (activeItem === 0) {\n return 0\n }\n\n return thumbOffsetPosition - thumbScrollDimension\n }\n\n const thumbNode = getThumbNode()\n\n if (thumbNode) {\n const thumbWrapper = internalThumbsWrapperRef.current!\n const offsetDirection = getOffsetDirection()\n const offsetDimension = getOffsetDimension()\n const scrollDirection = getScrollDirecton()\n const thumbOffsetPosition = getThumbOffsetPosition({\n thumbNode,\n offsetDimension,\n offsetDirection,\n })\n const thumbScrollDimension = getThumbScrollDimension({\n thumbWrapper,\n offsetDimension,\n })\n\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n }),\n },\n to: {\n [thumbsSlideAxis]: getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n }),\n },\n onChange: val => {\n if (thumbsSlideAxis === 'x') {\n // @ts-ignore\n internalThumbsWrapperRef!.current!.scrollLeft = val.x\n } else {\n // @ts-ignore\n internalThumbsWrapperRef!.current!.scrollTop = val.y\n }\n },\n })\n }\n }\n }\n function handlePrepareThumbsDate() {\n function getPreparedItems(\n _items: UseSpringCarouselItems['items'],\n ): ReactSpringThumbItem[] {\n return _items.map(i => ({\n id: i.id,\n renderThumb: i.renderThumb,\n }))\n }\n\n if (prepareThumbsData) {\n return prepareThumbsData(getPreparedItems(items))\n }\n return getPreparedItems(items)\n }\n\n const Wrapper = CustomThumbsWrapperComponent\n ? animated(CustomThumbsWrapperComponent)\n : InternalWrapper\n\n const thumbsFragment = withThumbs ? (\n <Wrapper\n ref={internalThumbsWrapperRef}\n className=\"use-spring-carousel-thumbs-wrapper\"\n onWheel={() => {\n thumbListStyles[thumbsSlideAxis].stop()\n }}\n style={{\n display: 'flex',\n flex: 1,\n position: 'relative',\n flexDirection: thumbsSlideAxis === 'x' ? 'row' : 'column',\n ...(thumbsSlideAxis === 'x'\n ? { overflowX: 'auto' }\n : {\n overflowY: 'auto',\n maxHeight: '100%',\n }),\n }}\n >\n {handlePrepareThumbsDate().map(({ id, renderThumb }) => {\n const thumbId = `thumb-${id}`\n return (\n <div key={thumbId} id={thumbId}>\n {renderThumb}\n </div>\n )\n })}\n </Wrapper>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useCallback, useContext, useEffect } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from './modules'\nimport {\n UseSpringCarouselProps,\n SlideToItemFnProps,\n SlideActionType,\n UseSpringDafaultTypeReturnProps,\n UseSpringFluidTypeReturnProps,\n} from './types'\nimport { useMount } from './utils'\nimport { getIsBrowser } from './utils'\n\ntype ReturnHook<T> = T extends 'fluid'\n ? UseSpringFluidTypeReturnProps\n : UseSpringDafaultTypeReturnProps\n\nconst UseSpringCarouselContext = createContext<\n (UseSpringFluidTypeReturnProps | UseSpringDafaultTypeReturnProps) | undefined\n>(undefined)\n\nexport function useSpringCarousel<T>({\n itemsPerSlide = 1,\n items,\n withLoop = false,\n draggingSlideTreshold = 140,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition = 'start',\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n CustomThumbsWrapperComponent,\n}: UseSpringCarouselProps): ReturnHook<T> & {\n carouselFragment: JSX.Element\n thumbsFragment: JSX.Element\n} {\n function getItems() {\n if (withLoop) {\n if (items.length === itemsPerSlide) {\n return [...items, ...items, ...items, ...items, ...items]\n }\n return [...items, ...items, ...items]\n }\n return items\n }\n const slideActionType = useRef<SlideActionType>('initial')\n const internalItems = getItems()\n const activeItem = useRef(initialActiveItem)\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const carouselTrackWrapperRef = useRef<HTMLDivElement | null>(null)\n const isDragging = useRef(false)\n const isAnimating = useRef(false)\n const windowIsHidden = useRef(false)\n const currentWindowWidth = useRef(0)\n const fluidTotalWrapperScrollValue = useRef(0)\n const slideFluidEndReached = useRef(false)\n const initialWindowWidth = useRef(0)\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxis])\n }\n },\n }))\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n const getMainCarouselWrapperWidth = useCallback(() => {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ]\n }, [carouselSlideAxis])\n const getCarouselItemWidth = useCallback(() => {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ] + gutter\n )\n }, [carouselSlideAxis, gutter])\n const getCurrentSlidedValue = useCallback(() => {\n return carouselStyles[carouselSlideAxis].get()\n }, [carouselSlideAxis, carouselStyles])\n const getIfItemsNotFillTheCarousel = useCallback(() => {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }, [getCarouselItemWidth, getMainCarouselWrapperWidth, items.length])\n const getFluidWrapperScrollValue = useCallback(() => {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }, [carouselSlideAxis])\n const getIsFirstItem = useCallback(() => {\n return getCurrentActiveItem() === 0\n }, [])\n const getSlideValue = useCallback(() => {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (itemsPerSlide === 'fluid' && typeof slideAmount === 'number') {\n if (slideAmount < itemVal) {\n throw new Error('slideAmount must be greater than the width of a single item.')\n }\n return slideAmount\n }\n return itemVal\n }, [getCarouselItemWidth, itemsPerSlide, slideAmount])\n const adjustCarouselWrapperPosition = useCallback(\n (ref: HTMLDivElement) => {\n const positionProperty = carouselSlideAxis === 'x' ? 'left' : 'top'\n function getDefaultPositionValue() {\n return getCarouselItemWidth() * items.length\n }\n function setPosition(v: number) {\n ref.style.top = '0px'\n ref.style.left = '0px'\n if (withLoop) {\n ref.style[positionProperty] = `-${v - startEndGutter}px`\n }\n }\n function setStartPosition() {\n setPosition(getDefaultPositionValue())\n }\n\n if (itemsPerSlide !== 'fluid' && typeof itemsPerSlide === 'number') {\n function setCenterPosition() {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round(((itemsPerSlide as number) - 1) / 2),\n )\n }\n function setEndPosition() {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round((itemsPerSlide as number) - 1),\n )\n }\n\n if (itemsPerSlide > 1) {\n switch (initialStartingPosition) {\n default:\n case 'start': {\n setStartPosition()\n break\n }\n case 'center': {\n setCenterPosition()\n break\n }\n case 'end': {\n setEndPosition()\n break\n }\n }\n } else {\n setStartPosition()\n }\n } else {\n setStartPosition()\n }\n },\n [\n carouselSlideAxis,\n itemsPerSlide,\n getCarouselItemWidth,\n items.length,\n startEndGutter,\n getSlideValue,\n initialStartingPosition,\n withLoop,\n ],\n )\n\n const handleResize = useCallback(() => {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n currentWindowWidth.current = window.innerWidth\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: 0,\n })\n return\n }\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n const diff = currentWindowWidth.current - initialWindowWidth.current\n\n if (slideFluidEndReached.current) {\n const nextValue = -fluidTotalWrapperScrollValue.current\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: nextValue,\n })\n } else {\n const nextValue = getCurrentSlidedValue() + diff\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n x: 0,\n y: 0,\n })\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }, [\n itemsPerSlide,\n getIfItemsNotFillTheCarousel,\n getFluidWrapperScrollValue,\n freeScroll,\n setCarouselStyles,\n carouselSlideAxis,\n getCurrentSlidedValue,\n getSlideValue,\n adjustCarouselWrapperPosition,\n ])\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n itemsPerSlide,\n getFluidWrapperScrollValue,\n getSlideValue,\n CustomThumbsWrapperComponent,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n\n const bindDrag = useDrag(\n props => {\n const isDragging = props.dragging\n const movement = props.offset[carouselSlideAxis === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxis === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function resetAnimation() {\n if (itemsPerSlide === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxis]: 0,\n })\n } else if (slideFluidEndReached.current) {\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: getCurrentSlidedValue(),\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: -(getCurrentActiveItem() * getSlideValue()),\n })\n }\n }\n\n if (isDragging) {\n setIsDragging(true)\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n const direction = props.direction[carouselSlideAxis === 'x' ? 0 : 1]\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n\n if (freeScroll) {\n if (getWrapperScrollDirection() === 0 && direction > 0) {\n cancelDrag()\n } else {\n setCarouselStyles.start({\n from: {\n [carouselSlideAxis]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxis]:\n direction > 0\n ? getWrapperScrollDirection() - Math.abs(movement)\n : getWrapperScrollDirection() + Math.abs(movement),\n },\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: movement,\n })\n }\n\n const prevItemTreshold = currentMovement > draggingSlideTreshold\n const nextItemTreshold = currentMovement < -draggingSlideTreshold\n\n if (\n mainCarouselWrapperRef.current!.getBoundingClientRect().width >=\n items.length * getSlideValue() &&\n itemsPerSlide === 'fluid'\n ) {\n slideFluidEndReached.current = true\n }\n\n if (\n (prevItemTreshold || nextItemTreshold) &&\n getIfItemsNotFillTheCarousel() &&\n itemsPerSlide === 'fluid'\n ) {\n cancelDrag()\n resetAnimation()\n return\n }\n\n if (slideFluidEndReached.current && movement < 0) {\n if (nextItemTreshold) {\n cancelDrag()\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n }\n } else if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem()\n }\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem()\n }\n }\n }\n\n if (props.last && !props.pressed && !freeScroll) {\n resetAnimation()\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n },\n {\n enabled: !disableGestures,\n from: () => [carouselStyles.x.get(), carouselStyles.y.get()],\n },\n )\n\n // Perform some check on first mount\n useMount(() => {\n if (itemsPerSlide !== 'fluid' && !Number.isInteger(itemsPerSlide)) {\n throw new Error(`itemsPerSlide should be an integer.`)\n }\n if (itemsPerSlide > items.length) {\n throw new Error(\n `The itemsPerSlide prop can't be greater than the total length of the items you provide.`,\n )\n }\n if (itemsPerSlide < 1) {\n throw new Error(`The itemsPerSlide prop can't be less than 1.`)\n }\n if (!shouldResizeOnWindowResize) {\n console.warn(\n 'You set shouldResizeOnWindowResize={false}; be aware that the carousel could behave in a strange way if you also use the fullscreen functionality or if you change the mobile orientation.',\n )\n }\n if (initialActiveItem < 0) {\n console.warn('The initialActiveItem cannot be less than 0.')\n }\n if (initialActiveItem > items.length) {\n console.warn(\n 'The initialActiveItem cannot be greater than the total length of the items you provide.',\n )\n }\n })\n useMount(() => {\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n function handleVisibilityChange() {\n if (document.hidden) {\n windowIsHidden.current = true\n } else {\n windowIsHidden.current = false\n }\n }\n if (getIsBrowser()) {\n document.addEventListener('visibilitychange', handleVisibilityChange)\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange)\n }\n }\n })\n useMount(() => {\n initialWindowWidth.current = window.innerWidth\n if (initialActiveItem > 0 && initialActiveItem <= items.length) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n }\n })\n useEffect(() => {\n function resize() {\n setTimeout(handleResize)\n }\n if (shouldResizeOnWindowResize) {\n window.addEventListener('resize', resize)\n return () => {\n window.removeEventListener('resize', resize)\n }\n }\n }, [handleResize, shouldResizeOnWindowResize])\n useEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxis === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxis === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useEffect(() => {\n setTimeout(() => adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!), 150)\n }, [adjustCarouselWrapperPosition, carouselSlideAxis, itemsPerSlide])\n\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function setActiveItem(newItem: number) {\n activeItem.current = newItem\n }\n function getCurrentActiveItem() {\n return activeItem.current\n }\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setIsDragging(val: boolean) {\n isDragging.current = val\n }\n function getIsDragging() {\n return isDragging.current\n }\n function getPrevItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === 0) {\n return items.length - 1\n }\n return currentActiveItem - 1\n }\n function getNextItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === items.length - 1) {\n return 0\n }\n return currentActiveItem + 1\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n return itemIndex === activeItem - 1\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function slideToItem({\n from,\n to = -1,\n customTo,\n immediate = false,\n onRest = () => {},\n }: SlideToItemFnProps) {\n if (!immediate) {\n setActiveItem(to)\n setIsAnimating(true)\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: itemsPerSlide === 'fluid' ? -1 : to,\n id: itemsPerSlide === 'fluid' ? '' : items[to].id,\n },\n })\n }\n\n function getFromValue() {\n if (typeof from === 'number') {\n return {\n from: {\n [carouselSlideAxis]: from,\n },\n }\n }\n return {}\n }\n function getToValue() {\n if (typeof customTo === 'number') {\n return {\n [carouselSlideAxis]: customTo,\n }\n }\n return {\n [carouselSlideAxis]: -(getSlideValue() * to),\n }\n }\n\n setCarouselStyles.start({\n ...getFromValue(),\n to: getToValue(),\n immediate,\n onRest: val => {\n if (val.finished) {\n setIsDragging(false)\n setIsAnimating(false)\n onRest()\n if (!immediate) {\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: itemsPerSlide === 'fluid' ? -1 : getCurrentActiveItem(),\n id: itemsPerSlide === 'fluid' ? '' : items[getCurrentActiveItem()].id,\n },\n })\n }\n }\n },\n })\n if (enableThumbsWrapperScroll && withThumbs && !immediate) {\n handleThumbsScroll(to, getSlideActionType())\n }\n }\n function getIsLastItem() {\n return getCurrentActiveItem() === items.length - 1\n }\n function slideToPrevItem() {\n setSlideActionType('prev')\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const nextPrevValue = getCurrentSlidedValue() + getSlideValue() + 200\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft - getSlideValue()\n slideToItem({\n customTo: nextValue < 0 ? 0 : nextValue,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n })\n }\n if (slideFluidEndReached.current) {\n slideFluidEndReached.current = false\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n })\n }\n }\n }\n function slideToNextItem() {\n setSlideActionType('next')\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const willGoAfterLastFluidItem =\n Math.abs(getCurrentSlidedValue() - getSlideValue()) + 100 >=\n fluidTotalWrapperScrollValue.current\n\n if (freeScroll) {\n slideToItem({\n customTo: mainCarouselWrapperRef.current!.scrollLeft + getSlideValue(),\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (\n withLoop &&\n Math.abs(getCurrentSlidedValue() - getSlideValue()) >=\n items.length * getCarouselItemWidth()\n ) {\n const currentWidth = getCarouselItemWidth() * items.length\n slideToItem({\n from: getCurrentSlidedValue() + currentWidth,\n customTo: getCurrentSlidedValue() + currentWidth - getSlideValue(),\n })\n } else if (slideFluidEndReached.current) {\n return\n } else if (willGoAfterLastFluidItem) {\n slideFluidEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n })\n }\n }\n }\n function _slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n if (itemIndex === getCurrentActiveItem()) {\n return\n }\n\n const currentItem = findItemIndex(items[getCurrentActiveItem()].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n slideToItem({\n to: itemIndex,\n })\n }\n\n const contextProps = {\n useListenToCustomEvent,\n getIsFullscreen,\n enterFullscreen,\n exitFullscreen,\n getIsAnimating,\n getIsDragging,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem,\n slideToNextItem,\n ...(typeof itemsPerSlide === 'number'\n ? {\n slideToItem: _slideToItem,\n getIsActiveItem: (id: string) => {\n return findItemIndex(id) === getCurrentActiveItem()\n },\n getCurrentActiveItem: () => ({\n id: items[getCurrentActiveItem()].id,\n index: getCurrentActiveItem(),\n }),\n }\n : {}),\n }\n function getItemStyles() {\n if (typeof itemsPerSlide === 'number') {\n return {\n ...(carouselSlideAxis === 'x'\n ? { marginRight: `${gutter}px` }\n : { marginBottom: `${gutter}px` }),\n flex: `1 0 calc(100% / ${itemsPerSlide} - ${\n (gutter * (itemsPerSlide - 1)) / itemsPerSlide\n }px)`,\n }\n }\n return {\n ...(carouselSlideAxis === 'x'\n ? { marginRight: `${gutter}px` }\n : { marginBottom: `${gutter}px` }),\n }\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutter * 2}px)`\n return {\n width: carouselSlideAxis === 'x' ? percentValue : '100%',\n height: carouselSlideAxis === 'y' ? percentValue : '100%',\n }\n }\n function handleCarouselFragmentRef(ref: HTMLDivElement | null) {\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref)\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxis === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxis].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (!touchAction) {\n if (carouselSlideAxis === 'x') {\n return 'pan-y'\n }\n return 'pan-x'\n }\n return touchAction\n }\n const carouselFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxis === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </UseSpringCarouselContext.Provider>\n )\n const thumbsFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseSpringCarouselContext.Provider>\n )\n\n return {\n ...(contextProps as ReturnHook<T>),\n carouselFragment,\n thumbsFragment,\n }\n}\n\nexport function useSpringCarouselContext<T>() {\n const context = useContext(UseSpringCarouselContext)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context as ReturnHook<T>\n}\n","import { createContext, useRef, useState, useContext } from 'react'\nimport { useTransition, animated, config } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useThumbsModule, useFullscreenModule } from './modules'\nimport {\n UseTransitionCarouselContextProps,\n UseTransitionCarouselProps,\n SlideActionType,\n} from './types'\n\nconst UseTransitionCarouselContext = createContext<\n UseTransitionCarouselContextProps | undefined\n>(undefined)\n\nexport function useTransitionCarouselContext() {\n const context = useContext(UseTransitionCarouselContext)\n\n if (!context) {\n throw new Error(`useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.`)\n }\n\n return context\n}\n\nexport function useTransitionCarousel({\n items,\n withLoop = false,\n withThumbs = false,\n springConfig = config.default,\n thumbsSlideAxis = 'x',\n enableThumbsWrapperScroll = true,\n draggingSlideTreshold = 50,\n prepareThumbsData,\n toPrevItemSpringProps,\n toNextItemSpringProps,\n disableGestures = false,\n CustomThumbsWrapperComponent,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'relative',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'relative',\n },\n leave: {\n opacity: 0,\n position: 'absolute',\n },\n },\n}: UseTransitionCarouselProps) {\n const slideActionType = useRef<SlideActionType>('next')\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const isAnimating = useRef(false)\n const [activeItem, setActiveItem] = useState(0)\n\n const { emitObservable, useListenToCustomEvent } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n CustomThumbsWrapperComponent,\n })\n\n const bindSwipe = useDrag(\n ({ last, movement: [mx] }) => {\n if (getIsAnimating()) {\n return\n }\n\n if (last) {\n const prevItemTreshold = mx > draggingSlideTreshold\n const nextItemTreshold = mx < -draggingSlideTreshold\n const isFirstItem = activeItem === 0\n const isLastItem = activeItem === items.length - 1\n\n if (nextItemTreshold) {\n if (!withLoop && isLastItem) {\n return\n }\n\n slideToNextItem()\n emitObservable({\n eventName: 'onLeftSwipe',\n })\n } else if (prevItemTreshold) {\n if (!withLoop && isFirstItem) {\n return\n }\n\n slideToPrevItem()\n emitObservable({\n eventName: 'onRightSwipe',\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n },\n )\n\n function getTransitionConfig() {\n const slideActionType = getSlideActionType()\n\n if (slideActionType === 'prev' && toPrevItemSpringProps) {\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...toPrevItemSpringProps.from,\n },\n enter: {\n ...toPrevItemSpringProps.enter,\n },\n leave: {\n ...toPrevItemSpringProps.leave,\n },\n }\n }\n\n if (slideActionType === 'next' && toNextItemSpringProps) {\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...toNextItemSpringProps.from,\n },\n enter: {\n ...toNextItemSpringProps.enter,\n },\n leave: {\n ...toNextItemSpringProps.leave,\n },\n }\n }\n\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...springAnimationProps.from,\n },\n enter: {\n ...springAnimationProps.enter,\n },\n leave: {\n ...springAnimationProps.leave,\n },\n }\n }\n\n const transitions = useTransition(activeItem, {\n config: springConfig,\n ...getTransitionConfig(),\n onStart: () => setIsAnimating(true),\n keys: null,\n onRest: val => {\n if (val.finished) {\n setIsAnimating(false)\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: activeItem,\n id: items[activeItem].id,\n },\n })\n }\n },\n })\n const itemsFragment = transitions((styles, item) => (\n <animated.div\n style={{\n ...styles,\n flex: '1 0 100%',\n width: '100%',\n height: '100%',\n }}\n >\n {items[item].renderItem}\n </animated.div>\n ))\n\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (itemIndex === activeItem) {\n return\n }\n\n const currentItem = findItemIndex(items[activeItem].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: newActiveItem,\n id: items[itemIndex].id,\n },\n })\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n setActiveItem(itemIndex)\n\n if (enableThumbsWrapperScroll && withThumbs) {\n handleThumbsScroll(itemIndex)\n }\n }\n function slideToNextItem() {\n const isLastItem = activeItem === items.length - 1\n\n if (withLoop) {\n setSlideActionType('next')\n if (isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: 0,\n id: items[0].id,\n },\n })\n setActiveItem(0)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setActiveItem(activeItem + 1)\n }\n } else {\n if (!isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setSlideActionType('next')\n setActiveItem(activeItem + 1)\n }\n }\n }\n function slideToPrevItem() {\n const isFirstItem = activeItem === 0\n\n if (withLoop) {\n setSlideActionType('prev')\n if (isFirstItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(items.length - 1)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n } else {\n if (!isFirstItem) {\n setSlideActionType('prev')\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n }\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n\n return itemIndex === activeItem - 1\n }\n\n const contextProps: UseTransitionCarouselContextProps = {\n activeItem,\n slideToItem,\n slideToNextItem,\n slideToPrevItem,\n enterFullscreen,\n exitFullscreen,\n useListenToCustomEvent,\n getIsNextItem,\n getIsPrevItem,\n getIsAnimating,\n getIsFullscreen,\n getIsActiveItem: id => {\n return findItemIndex(id) === activeItem\n },\n getCurrentActiveItem: () => ({\n id: items[activeItem].id,\n index: activeItem,\n }),\n }\n\n const carouselFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n {...bindSwipe()}\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n }}\n >\n {itemsFragment}\n </div>\n </UseTransitionCarouselContext.Provider>\n )\n\n const thumbsFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseTransitionCarouselContext.Provider>\n )\n\n return {\n carouselFragment,\n thumbsFragment,\n ...contextProps,\n }\n}\n"],"names":["useCustomEventsModule","eventsObserverRef","useRef","Subject","useListenToCustomEvent","fn","useEffect","subscribe","current","unsubscribe","emitObservable","data","next","useFullscreenModule","mainCarouselWrapperRef","handleResize","isFullscreen","setIsFullscreen","_isFullscreen","handleFullscreenChange","document","fullscreenElement","eventName","screenfull","isEnabled","on","off","enterFullscreen","elementRef","request","exitFullscreen","exit","getIsFullscreen","useMount","callback","isMounted","clean","InternalWrapper","forwardRef","children","rest","ref","_jsx","animated","div","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","itemsPerSlide","getFluidWrapperScrollValue","getSlideValue","CustomThumbsWrapperComponent","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","Wrapper","thumbsFragment","className","onWheel","stop","style","display","flex","position","flexDirection","overflowX","overflowY","maxHeight","getPreparedItems","_items","map","i","id","renderThumb","handlePrepareThumbsDate","thumbId","handleThumbsScroll","activeItem","actionType","totalScrollableValue","nextValue","start","from","[object Object]","to","thumbNode","querySelector","thumbWrapper","offsetDimension","scrollDirection","thumbOffsetPosition","offsetDirection","getThumbOffsetPosition","thumbScrollDimension","getThumbScrollDimension","getScrollFromValue","scrollDimensionProperty","length","getScrollToValue","val","scrollLeft","scrollTop","UseSpringCarouselContext","createContext","undefined","useSpringCarousel","withLoop","draggingSlideTreshold","default","shouldResizeOnWindowResize","enableThumbsWrapperScroll","carouselSlideAxis","initialActiveItem","initialStartingPosition","disableGestures","gutter","startEndGutter","touchAction","slideAmount","freeScroll","slideActionType","internalItems","carouselTrackWrapperRef","isDragging","isAnimating","windowIsHidden","currentWindowWidth","fluidTotalWrapperScrollValue","slideFluidEndReached","initialWindowWidth","carouselStyles","setCarouselStyles","getMainCarouselWrapperWidth","useCallback","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","window","innerWidth","immediate","diff","_thumbsFragment","getWrapperScrollDirection","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","cancelDrag","cancel","resetAnimation","getSlideActionType","setIsDragging","direction","setSlideActionType","prevItemTreshold","nextItemTreshold","width","getIsLastItem","slideToNextItem","slideToPrevItem","last","pressed","enabled","type","setActiveItem","newItem","setIsAnimating","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","slideToItem","customTo","onRest","nextItem","index","finished","currentItem","nextPrevValue","willGoAfterLastFluidItem","currentWidth","isInteger","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","resize","setTimeout","contextProps","getIsAnimating","getIsDragging","getIsNextItem","itemIndex","getIsPrevItem","_item","getIsActiveItem","carouselFragment","Provider","height","percentValue","getAnimatedWrapperStyles","renderItem","marginRight","marginBottom","useSpringCarouselContext","context","useContext","UseTransitionCarouselContext","useTransitionCarouselContext","useTransitionCarousel","toPrevItemSpringProps","toNextItemSpringProps","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","keys","transitions","styles","newActiveItem","overflow"],"mappings":"6WAIgBA,IACd,MAAMC,EAAoBC,EAAO,IAAIC,GAarC,MAAO,CACLC,uBAZF,SAAgCC,GAC9BC,GAAU,KACR,MAAMC,EAAYN,EAAkBO,QAAQD,UAAUF,GACtD,MAAO,IAAME,EAAUE,gBACtB,CAACJ,KASJK,eANuCC,IACvCV,EAAkBO,QAAQI,KAAKD,cCLnBE,GAAoBC,uBAClCA,EAAsBJ,eACtBA,EAAcK,aACdA,IAEA,MAAMC,EAAed,GAAO,GAkC5B,SAASe,EAAgBC,GACvBF,EAA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AE/B+D,qBAAsB,MACpBpE,GAAI7C,EAAMkD,GAAYL,GACtByH,MAAOpH,KA4BX,MAAO,CACL2I,iBAxBAjM,EAAC4M,EAA6BV,wBAAS7K,MAAOoK,aAC5CzL,uBACED,IAAK3B,GACDmP,KACJlL,MAAO,CACLC,QAAS,OACTE,SAAU,WACV6G,MAAO,OACP8C,OAAQ,OACRgC,SAAU,qBAGXR,sBAaL1L,eAPAjC,EAAC4M,EAA6BV,wBAAS7K,MAAOoK,aAC3CtD,eAOAsD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/modules/useCustomEventsModule.tsx","../src/modules/useFullscreenModule.tsx","../src/utils.ts","../src/modules/useThumbsModule.tsx","../src/useSpringCarousel.tsx","../src/useTransitionCarousel.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { Subject } from 'rxjs'\nimport { EventsObservableProps, ObservableCallbackFn, EmitObservableFn } from '../types'\n\nexport function useCustomEventsModule() {\n const eventsObserverRef = useRef(new Subject<EventsObservableProps>())\n\n function useListenToCustomEvent(fn: ObservableCallbackFn) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, MutableRefObject, useEffect } from 'react'\nimport screenfull from 'screenfull'\nimport { EmitObservableFn } from '../types'\n\ntype FullscreenModule = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn\n handleResize?(): void\n}\n\nexport function useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule) {\n const isFullscreen = useRef(false)\n\n useEffect(() => {\n function handleFullscreenChange() {\n if (document.fullscreenElement) {\n setIsFullscreen(true)\n emitObservable({\n eventName: 'onFullscreenChange',\n isFullscreen: true,\n })\n\n handleResize && handleResize()\n }\n\n if (!document.fullscreenElement) {\n setIsFullscreen(false)\n emitObservable({\n eventName: 'onFullscreenChange',\n isFullscreen: false,\n })\n handleResize && handleResize()\n }\n }\n\n if (screenfull.isEnabled) {\n screenfull.on('change', handleFullscreenChange)\n return () => {\n if (screenfull.isEnabled) {\n screenfull.off('change', handleFullscreenChange)\n }\n }\n }\n })\n\n function setIsFullscreen(_isFullscreen: boolean) {\n isFullscreen.current = _isFullscreen\n }\n\n function getIsFullscreen() {\n return isFullscreen.current\n }\n\n function enterFullscreen(elementRef?: HTMLElement) {\n if (screenfull.isEnabled) {\n screenfull.request((elementRef || mainCarouselWrapperRef.current) as Element)\n }\n }\n\n function exitFullscreen() {\n screenfull.isEnabled && screenfull.exit()\n }\n\n return {\n enterFullscreen,\n exitFullscreen,\n getIsFullscreen,\n }\n}\n","import { useRef, useEffect } from 'react'\n\ntype Callback = () => void | (() => void)\n\nexport function useMount(callback: Callback) {\n const isMounted = useRef(false)\n\n useEffect(() => {\n if (!isMounted.current) {\n const clean = callback()\n isMounted.current = true\n\n return () => {\n clean && clean()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\nexport function getIsBrowser() {\n return typeof window !== 'undefined'\n}\n","import { forwardRef, HTMLAttributes, useRef } from 'react'\nimport { useSpring, SpringConfig, animated } from 'react-spring'\nimport { useMount } from 'src/utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringThumbItem,\n PrepareThumbsData,\n UseSpringCarouselItems,\n SlideActionType,\n} from '../types'\n\ntype OffsetDimension = 'offsetWidth' | 'offsetHeight'\ntype OffsetDirection = 'offsetLeft' | 'offsetTop'\ntype ScrollDirection = 'scrollLeft' | 'scrollTop'\n\ntype Props = {\n items: UseSpringCarouselItems['items']\n withThumbs: boolean\n thumbsSlideAxis: UseSpringCarouselProps['thumbsSlideAxis']\n springConfig: SpringConfig\n prepareThumbsData?: PrepareThumbsData\n itemsPerSlide?: UseSpringCarouselProps['itemsPerSlide']\n CustomThumbsWrapperComponent?: UseSpringCarouselProps['CustomThumbsWrapperComponent']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\ntype WrapperProps = {\n children: React.ReactNode\n} & HTMLAttributes<HTMLDivElement>\n\nconst InternalWrapper = forwardRef<HTMLDivElement, WrapperProps>(\n ({ children, ...rest }, ref) => {\n return (\n <animated.div {...rest} ref={ref}>\n {children}\n </animated.div>\n )\n },\n)\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n itemsPerSlide,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n CustomThumbsWrapperComponent,\n}: Props) {\n const internalThumbsWrapperRef = useRef<HTMLDivElement | null>(null)\n const [thumbListStyles, setThumbListStyles] = useSpring(() => ({\n x: 0,\n y: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (internalThumbsWrapperRef.current) {\n internalThumbsWrapperRef.current[\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[thumbsSlideAxis])\n }\n },\n }))\n\n useMount(() => {\n if (withThumbs && !internalThumbsWrapperRef.current) {\n throw new Error(\n \"The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.\",\n )\n }\n })\n\n function getCurrentThumbScrollValue() {\n return internalThumbsWrapperRef.current![\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getThumbsTotalScrollableValue() {\n return Math.round(\n Number(\n internalThumbsWrapperRef.current?.[\n thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n internalThumbsWrapperRef.current!.getBoundingClientRect()[\n thumbsSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }\n\n function getThumbSlideValue() {\n const thumbSlideTotal = Math.round(getFluidWrapperScrollValue() / getSlideValue())\n const totalScrollableValue = getThumbsTotalScrollableValue()\n return totalScrollableValue / thumbSlideTotal\n }\n\n function handleThumbsScroll(activeItem: number, actionType?: SlideActionType) {\n if (itemsPerSlide === 'fluid') {\n const totalScrollableValue = getThumbsTotalScrollableValue()\n\n if (actionType === 'next') {\n const nextValue = getCurrentThumbScrollValue() + getThumbSlideValue()\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getCurrentThumbScrollValue(),\n },\n to: {\n [thumbsSlideAxis]:\n nextValue > totalScrollableValue ? totalScrollableValue : nextValue,\n },\n })\n }\n if (actionType === 'prev') {\n const nextValue = getCurrentThumbScrollValue() - getThumbSlideValue()\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getCurrentThumbScrollValue(),\n },\n to: {\n [thumbsSlideAxis]: nextValue < 0 ? 0 : nextValue,\n },\n })\n }\n } else {\n function getOffsetDirection() {\n return thumbsSlideAxis === 'x' ? 'offsetLeft' : 'offsetTop'\n }\n function getOffsetDimension() {\n return thumbsSlideAxis === 'x' ? 'offsetWidth' : 'offsetHeight'\n }\n function getScrollDirecton() {\n return thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n }\n function getThumbNode() {\n return internalThumbsWrapperRef.current!.querySelector(\n `#thumb-${items[activeItem].id}`,\n ) as HTMLElement\n }\n function getThumbOffsetPosition({\n thumbNode,\n offsetDirection,\n offsetDimension,\n }: {\n thumbNode: HTMLElement\n offsetDirection: OffsetDirection\n offsetDimension: OffsetDimension\n }) {\n return thumbNode[offsetDirection] + thumbNode[offsetDimension] / 2\n }\n function getThumbScrollDimension({\n thumbWrapper,\n offsetDimension,\n }: {\n thumbWrapper: HTMLDivElement\n offsetDimension: OffsetDimension\n }) {\n return thumbWrapper[offsetDimension] / 2\n }\n function getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n }: {\n thumbWrapper: HTMLDivElement\n scrollDirection: ScrollDirection\n }) {\n return thumbWrapper[scrollDirection]\n }\n function getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n }: {\n thumbWrapper: HTMLDivElement\n thumbOffsetPosition: number\n thumbScrollDimension: number\n offsetDimension: OffsetDimension\n }) {\n const scrollDimensionProperty =\n thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n\n if (\n activeItem === items.length - 1 ||\n thumbOffsetPosition - thumbScrollDimension >\n thumbWrapper[scrollDimensionProperty] - thumbWrapper[offsetDimension]\n ) {\n return thumbWrapper[scrollDimensionProperty] - thumbWrapper[offsetDimension]\n }\n if (activeItem === 0) {\n return 0\n }\n\n return thumbOffsetPosition - thumbScrollDimension\n }\n\n const thumbNode = getThumbNode()\n\n if (thumbNode) {\n const thumbWrapper = internalThumbsWrapperRef.current!\n const offsetDirection = getOffsetDirection()\n const offsetDimension = getOffsetDimension()\n const scrollDirection = getScrollDirecton()\n const thumbOffsetPosition = getThumbOffsetPosition({\n thumbNode,\n offsetDimension,\n offsetDirection,\n })\n const thumbScrollDimension = getThumbScrollDimension({\n thumbWrapper,\n offsetDimension,\n })\n\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n }),\n },\n to: {\n [thumbsSlideAxis]: getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n }),\n },\n onChange: val => {\n if (thumbsSlideAxis === 'x') {\n // @ts-ignore\n internalThumbsWrapperRef!.current!.scrollLeft = val.x\n } else {\n // @ts-ignore\n internalThumbsWrapperRef!.current!.scrollTop = val.y\n }\n },\n })\n }\n }\n }\n function handlePrepareThumbsDate() {\n function getPreparedItems(\n _items: UseSpringCarouselItems['items'],\n ): ReactSpringThumbItem[] {\n return _items.map(i => ({\n id: i.id,\n renderThumb: i.renderThumb,\n }))\n }\n\n if (prepareThumbsData) {\n return prepareThumbsData(getPreparedItems(items))\n }\n return getPreparedItems(items)\n }\n\n const Wrapper = CustomThumbsWrapperComponent\n ? animated(CustomThumbsWrapperComponent)\n : InternalWrapper\n\n const thumbsFragment = withThumbs ? (\n <Wrapper\n ref={internalThumbsWrapperRef}\n className=\"use-spring-carousel-thumbs-wrapper\"\n onWheel={() => {\n thumbListStyles[thumbsSlideAxis].stop()\n }}\n style={{\n display: 'flex',\n flex: 1,\n position: 'relative',\n flexDirection: thumbsSlideAxis === 'x' ? 'row' : 'column',\n ...(thumbsSlideAxis === 'x'\n ? { overflowX: 'auto' }\n : {\n overflowY: 'auto',\n maxHeight: '100%',\n }),\n }}\n >\n {handlePrepareThumbsDate().map(({ id, renderThumb }) => {\n const thumbId = `thumb-${id}`\n return (\n <div key={thumbId} id={thumbId}>\n {renderThumb}\n </div>\n )\n })}\n </Wrapper>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useCallback, useContext, useEffect } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from './modules'\nimport {\n UseSpringCarouselProps,\n SlideToItemFnProps,\n SlideActionType,\n UseSpringDafaultTypeReturnProps,\n UseSpringFluidTypeReturnProps,\n} from './types'\nimport { useMount } from './utils'\nimport { getIsBrowser } from './utils'\n\ntype ReturnHook<T> = T extends 'fluid'\n ? UseSpringFluidTypeReturnProps\n : UseSpringDafaultTypeReturnProps\n\nconst UseSpringCarouselContext = createContext<\n (UseSpringFluidTypeReturnProps | UseSpringDafaultTypeReturnProps) | undefined\n>(undefined)\n\nexport function useSpringCarousel<T>({\n itemsPerSlide = 1,\n items,\n withLoop = false,\n draggingSlideTreshold = 140,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition = 'start',\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n CustomThumbsWrapperComponent,\n}: UseSpringCarouselProps): ReturnHook<T> & {\n carouselFragment: JSX.Element\n thumbsFragment: JSX.Element\n} {\n function getItems() {\n if (withLoop) {\n if (items.length === itemsPerSlide) {\n return [...items, ...items, ...items, ...items, ...items]\n }\n return [...items, ...items, ...items]\n }\n return items\n }\n const slideActionType = useRef<SlideActionType>('initial')\n const internalItems = getItems()\n const activeItem = useRef(initialActiveItem)\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const carouselTrackWrapperRef = useRef<HTMLDivElement | null>(null)\n const isDragging = useRef(false)\n const isAnimating = useRef(false)\n const windowIsHidden = useRef(false)\n const currentWindowWidth = useRef(0)\n const fluidTotalWrapperScrollValue = useRef(0)\n const slideFluidEndReached = useRef(false)\n const initialWindowWidth = useRef(0)\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxis])\n }\n },\n }))\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n const getMainCarouselWrapperWidth = useCallback(() => {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ]\n }, [carouselSlideAxis])\n const getCarouselItemWidth = useCallback(() => {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ] + gutter\n )\n }, [carouselSlideAxis, gutter])\n const getCurrentSlidedValue = useCallback(() => {\n return carouselStyles[carouselSlideAxis].get()\n }, [carouselSlideAxis, carouselStyles])\n const getIfItemsNotFillTheCarousel = useCallback(() => {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }, [getCarouselItemWidth, getMainCarouselWrapperWidth, items.length])\n const getFluidWrapperScrollValue = useCallback(() => {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }, [carouselSlideAxis])\n const getIsFirstItem = useCallback(() => {\n return getCurrentActiveItem() === 0\n }, [])\n const getSlideValue = useCallback(() => {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (itemsPerSlide === 'fluid' && typeof slideAmount === 'number') {\n if (slideAmount < itemVal) {\n throw new Error('slideAmount must be greater than the width of a single item.')\n }\n return slideAmount\n }\n return itemVal\n }, [getCarouselItemWidth, itemsPerSlide, slideAmount])\n const adjustCarouselWrapperPosition = useCallback(\n (ref: HTMLDivElement) => {\n const positionProperty = carouselSlideAxis === 'x' ? 'left' : 'top'\n function getDefaultPositionValue() {\n return getCarouselItemWidth() * items.length\n }\n function setPosition(v: number) {\n ref.style.top = '0px'\n ref.style.left = '0px'\n if (withLoop) {\n ref.style[positionProperty] = `-${v - startEndGutter}px`\n }\n }\n function setStartPosition() {\n setPosition(getDefaultPositionValue())\n }\n\n if (itemsPerSlide !== 'fluid' && typeof itemsPerSlide === 'number') {\n function setCenterPosition() {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round(((itemsPerSlide as number) - 1) / 2),\n )\n }\n function setEndPosition() {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round((itemsPerSlide as number) - 1),\n )\n }\n\n if (itemsPerSlide > 1) {\n switch (initialStartingPosition) {\n default:\n case 'start': {\n setStartPosition()\n break\n }\n case 'center': {\n setCenterPosition()\n break\n }\n case 'end': {\n setEndPosition()\n break\n }\n }\n } else {\n setStartPosition()\n }\n } else {\n setStartPosition()\n }\n },\n [\n carouselSlideAxis,\n itemsPerSlide,\n getCarouselItemWidth,\n items.length,\n startEndGutter,\n getSlideValue,\n initialStartingPosition,\n withLoop,\n ],\n )\n\n const handleResize = useCallback(() => {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n currentWindowWidth.current = window.innerWidth\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: 0,\n })\n return\n }\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n const diff = currentWindowWidth.current - initialWindowWidth.current\n\n if (slideFluidEndReached.current) {\n const nextValue = -fluidTotalWrapperScrollValue.current\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: nextValue,\n })\n } else {\n const nextValue = getCurrentSlidedValue() + diff\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n x: 0,\n y: 0,\n })\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }, [\n itemsPerSlide,\n getIfItemsNotFillTheCarousel,\n getFluidWrapperScrollValue,\n freeScroll,\n setCarouselStyles,\n carouselSlideAxis,\n getCurrentSlidedValue,\n getSlideValue,\n adjustCarouselWrapperPosition,\n ])\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n itemsPerSlide,\n getFluidWrapperScrollValue,\n getSlideValue,\n CustomThumbsWrapperComponent,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n\n const bindDrag = useDrag(\n props => {\n const isDragging = props.dragging\n const movement = props.offset[carouselSlideAxis === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxis === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function resetAnimation() {\n if (itemsPerSlide === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxis]: 0,\n })\n } else if (slideFluidEndReached.current) {\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: getCurrentSlidedValue(),\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: -(getCurrentActiveItem() * getSlideValue()),\n })\n }\n }\n\n if (isDragging) {\n setIsDragging(true)\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n const direction = props.direction[carouselSlideAxis === 'x' ? 0 : 1]\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n\n if (freeScroll) {\n if (getWrapperScrollDirection() === 0 && direction > 0) {\n cancelDrag()\n } else {\n setCarouselStyles.start({\n from: {\n [carouselSlideAxis]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxis]:\n direction > 0\n ? getWrapperScrollDirection() - Math.abs(movement)\n : getWrapperScrollDirection() + Math.abs(movement),\n },\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: movement,\n })\n }\n\n const prevItemTreshold = currentMovement > draggingSlideTreshold\n const nextItemTreshold = currentMovement < -draggingSlideTreshold\n\n if (\n mainCarouselWrapperRef.current!.getBoundingClientRect().width >=\n items.length * getSlideValue() &&\n itemsPerSlide === 'fluid'\n ) {\n slideFluidEndReached.current = true\n }\n\n if (\n (prevItemTreshold || nextItemTreshold) &&\n getIfItemsNotFillTheCarousel() &&\n itemsPerSlide === 'fluid'\n ) {\n cancelDrag()\n resetAnimation()\n return\n }\n\n if (slideFluidEndReached.current && movement < 0) {\n if (nextItemTreshold) {\n cancelDrag()\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n }\n } else if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem()\n }\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem()\n }\n }\n }\n\n if (props.last && !props.pressed && !freeScroll) {\n resetAnimation()\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n },\n {\n enabled: !disableGestures,\n from: () => [carouselStyles.x.get(), carouselStyles.y.get()],\n },\n )\n\n // Perform some check on first mount\n useMount(() => {\n if (itemsPerSlide !== 'fluid' && !Number.isInteger(itemsPerSlide)) {\n throw new Error(`itemsPerSlide should be an integer.`)\n }\n if (itemsPerSlide > items.length) {\n throw new Error(\n `The itemsPerSlide prop can't be greater than the total length of the items you provide.`,\n )\n }\n if (itemsPerSlide < 1) {\n throw new Error(`The itemsPerSlide prop can't be less than 1.`)\n }\n if (!shouldResizeOnWindowResize) {\n console.warn(\n 'You set shouldResizeOnWindowResize={false}; be aware that the carousel could behave in a strange way if you also use the fullscreen functionality or if you change the mobile orientation.',\n )\n }\n if (initialActiveItem < 0) {\n console.warn('The initialActiveItem cannot be less than 0.')\n }\n if (initialActiveItem > items.length) {\n console.warn(\n 'The initialActiveItem cannot be greater than the total length of the items you provide.',\n )\n }\n })\n useMount(() => {\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n function handleVisibilityChange() {\n if (document.hidden) {\n windowIsHidden.current = true\n } else {\n windowIsHidden.current = false\n }\n }\n if (getIsBrowser()) {\n document.addEventListener('visibilitychange', handleVisibilityChange)\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange)\n }\n }\n })\n useMount(() => {\n initialWindowWidth.current = window.innerWidth\n if (initialActiveItem > 0 && initialActiveItem <= items.length) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n }\n })\n useEffect(() => {\n function resize() {\n setTimeout(handleResize)\n }\n if (shouldResizeOnWindowResize) {\n window.addEventListener('resize', resize)\n return () => {\n window.removeEventListener('resize', resize)\n }\n }\n }, [handleResize, shouldResizeOnWindowResize])\n useEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxis === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxis === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useEffect(() => {\n setTimeout(() => adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!), 150)\n }, [adjustCarouselWrapperPosition, carouselSlideAxis, itemsPerSlide])\n\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function setActiveItem(newItem: number) {\n activeItem.current = newItem\n }\n function getCurrentActiveItem() {\n return activeItem.current\n }\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setIsDragging(val: boolean) {\n isDragging.current = val\n }\n function getIsDragging() {\n return isDragging.current\n }\n function getPrevItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === 0) {\n return items.length - 1\n }\n return currentActiveItem - 1\n }\n function getNextItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === items.length - 1) {\n return 0\n }\n return currentActiveItem + 1\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n return itemIndex === activeItem - 1\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function slideToItem({\n from,\n to = -1,\n customTo,\n immediate = false,\n onRest = () => {},\n }: SlideToItemFnProps) {\n if (!immediate) {\n setActiveItem(to)\n setIsAnimating(true)\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: itemsPerSlide === 'fluid' ? -1 : to,\n id: itemsPerSlide === 'fluid' ? '' : items[to].id,\n },\n })\n }\n\n function getFromValue() {\n if (typeof from === 'number') {\n return {\n from: {\n [carouselSlideAxis]: from,\n },\n }\n }\n return {}\n }\n function getToValue() {\n if (typeof customTo === 'number') {\n return {\n [carouselSlideAxis]: customTo,\n }\n }\n return {\n [carouselSlideAxis]: -(getSlideValue() * to),\n }\n }\n\n setCarouselStyles.start({\n ...getFromValue(),\n to: getToValue(),\n immediate,\n onRest: val => {\n if (val.finished) {\n setIsDragging(false)\n setIsAnimating(false)\n onRest()\n if (!immediate) {\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: itemsPerSlide === 'fluid' ? -1 : getCurrentActiveItem(),\n id: itemsPerSlide === 'fluid' ? '' : items[getCurrentActiveItem()].id,\n },\n })\n }\n }\n },\n })\n if (enableThumbsWrapperScroll && withThumbs && !immediate) {\n handleThumbsScroll(to, getSlideActionType())\n }\n }\n function getIsLastItem() {\n return getCurrentActiveItem() === items.length - 1\n }\n function slideToPrevItem() {\n setSlideActionType('prev')\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const nextPrevValue = getCurrentSlidedValue() + getSlideValue() + 200\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft - getSlideValue()\n slideToItem({\n customTo: nextValue < 0 ? 0 : nextValue,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n })\n }\n if (slideFluidEndReached.current) {\n slideFluidEndReached.current = false\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n })\n }\n }\n }\n function slideToNextItem() {\n setSlideActionType('next')\n\n if (itemsPerSlide === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const willGoAfterLastFluidItem =\n Math.abs(getCurrentSlidedValue() - getSlideValue()) + 100 >=\n fluidTotalWrapperScrollValue.current\n\n if (freeScroll) {\n slideToItem({\n customTo: mainCarouselWrapperRef.current!.scrollLeft + getSlideValue(),\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (\n withLoop &&\n Math.abs(getCurrentSlidedValue() - getSlideValue()) >=\n items.length * getCarouselItemWidth()\n ) {\n const currentWidth = getCarouselItemWidth() * items.length\n slideToItem({\n from: getCurrentSlidedValue() + currentWidth,\n customTo: getCurrentSlidedValue() + currentWidth - getSlideValue(),\n })\n } else if (slideFluidEndReached.current) {\n return\n } else if (willGoAfterLastFluidItem) {\n slideFluidEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n })\n }\n }\n }\n function _slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n if (itemIndex === getCurrentActiveItem()) {\n return\n }\n\n const currentItem = findItemIndex(items[getCurrentActiveItem()].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n slideToItem({\n to: itemIndex,\n })\n }\n\n const contextProps = {\n useListenToCustomEvent,\n getIsFullscreen,\n enterFullscreen,\n exitFullscreen,\n getIsAnimating,\n getIsDragging,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem,\n slideToNextItem,\n ...(typeof itemsPerSlide === 'number'\n ? {\n slideToItem: _slideToItem,\n getIsActiveItem: (id: string) => {\n return findItemIndex(id) === getCurrentActiveItem()\n },\n getCurrentActiveItem: () => ({\n id: items[getCurrentActiveItem()].id,\n index: getCurrentActiveItem(),\n }),\n }\n : {}),\n }\n function getItemStyles() {\n if (typeof itemsPerSlide === 'number') {\n return {\n ...(carouselSlideAxis === 'x'\n ? { marginRight: `${gutter}px` }\n : { marginBottom: `${gutter}px` }),\n flex: `1 0 calc(100% / ${itemsPerSlide} - ${\n (gutter * (itemsPerSlide - 1)) / itemsPerSlide\n }px)`,\n }\n }\n return {\n ...(carouselSlideAxis === 'x'\n ? { marginRight: `${gutter}px` }\n : { marginBottom: `${gutter}px` }),\n }\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutter * 2}px)`\n return {\n width: carouselSlideAxis === 'x' ? percentValue : '100%',\n height: carouselSlideAxis === 'y' ? percentValue : '100%',\n }\n }\n function handleCarouselFragmentRef(ref: HTMLDivElement | null) {\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref)\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxis === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxis].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (!touchAction) {\n if (carouselSlideAxis === 'x') {\n return 'pan-y'\n }\n return 'pan-x'\n }\n return touchAction\n }\n const carouselFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxis === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </UseSpringCarouselContext.Provider>\n )\n const thumbsFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseSpringCarouselContext.Provider>\n )\n\n return {\n ...(contextProps as ReturnHook<T>),\n carouselFragment,\n thumbsFragment,\n }\n}\n\nexport function useSpringCarouselContext<T>() {\n const context = useContext(UseSpringCarouselContext)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context as ReturnHook<T>\n}\n","import { createContext, useRef, useState, useContext } from 'react'\nimport { useTransition, animated, config } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useThumbsModule, useFullscreenModule } from './modules'\nimport {\n UseTransitionCarouselContextProps,\n UseTransitionCarouselProps,\n SlideActionType,\n} from './types'\n\nconst UseTransitionCarouselContext = createContext<\n UseTransitionCarouselContextProps | undefined\n>(undefined)\n\nexport function useTransitionCarouselContext() {\n const context = useContext(UseTransitionCarouselContext)\n\n if (!context) {\n throw new Error(`useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.`)\n }\n\n return context\n}\n\nexport function useTransitionCarousel({\n items,\n withLoop = false,\n withThumbs = false,\n springConfig = config.default,\n thumbsSlideAxis = 'x',\n enableThumbsWrapperScroll = true,\n draggingSlideTreshold = 50,\n prepareThumbsData,\n toPrevItemSpringProps,\n toNextItemSpringProps,\n disableGestures = false,\n CustomThumbsWrapperComponent,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'relative',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'relative',\n },\n leave: {\n opacity: 0,\n position: 'absolute',\n },\n },\n}: UseTransitionCarouselProps) {\n const slideActionType = useRef<SlideActionType>('next')\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const isAnimating = useRef(false)\n const [activeItem, setActiveItem] = useState(0)\n\n const { emitObservable, useListenToCustomEvent } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n CustomThumbsWrapperComponent,\n })\n\n const bindSwipe = useDrag(\n ({ last, movement: [mx] }) => {\n if (getIsAnimating()) {\n return\n }\n\n if (last) {\n const prevItemTreshold = mx > draggingSlideTreshold\n const nextItemTreshold = mx < -draggingSlideTreshold\n const isFirstItem = activeItem === 0\n const isLastItem = activeItem === items.length - 1\n\n if (nextItemTreshold) {\n if (!withLoop && isLastItem) {\n return\n }\n\n slideToNextItem()\n emitObservable({\n eventName: 'onLeftSwipe',\n })\n } else if (prevItemTreshold) {\n if (!withLoop && isFirstItem) {\n return\n }\n\n slideToPrevItem()\n emitObservable({\n eventName: 'onRightSwipe',\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n },\n )\n\n function getTransitionConfig() {\n const slideActionType = getSlideActionType()\n\n if (slideActionType === 'prev' && toPrevItemSpringProps) {\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...toPrevItemSpringProps.from,\n },\n enter: {\n ...toPrevItemSpringProps.enter,\n },\n leave: {\n ...toPrevItemSpringProps.leave,\n },\n }\n }\n\n if (slideActionType === 'next' && toNextItemSpringProps) {\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...toNextItemSpringProps.from,\n },\n enter: {\n ...toNextItemSpringProps.enter,\n },\n leave: {\n ...toNextItemSpringProps.leave,\n },\n }\n }\n\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...springAnimationProps.from,\n },\n enter: {\n ...springAnimationProps.enter,\n },\n leave: {\n ...springAnimationProps.leave,\n },\n }\n }\n\n const transitions = useTransition(activeItem, {\n config: springConfig,\n ...getTransitionConfig(),\n onStart: () => setIsAnimating(true),\n keys: null,\n onRest: val => {\n if (val.finished) {\n setIsAnimating(false)\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: activeItem,\n id: items[activeItem].id,\n },\n })\n }\n },\n })\n const itemsFragment = transitions((styles, item) => (\n <animated.div\n style={{\n ...styles,\n flex: '1 0 100%',\n width: '100%',\n height: '100%',\n }}\n >\n {items[item].renderItem}\n </animated.div>\n ))\n\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (itemIndex === activeItem) {\n return\n }\n\n const currentItem = findItemIndex(items[activeItem].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: newActiveItem,\n id: items[itemIndex].id,\n },\n })\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n setActiveItem(itemIndex)\n\n if (enableThumbsWrapperScroll && withThumbs) {\n handleThumbsScroll(itemIndex)\n }\n }\n function slideToNextItem() {\n const isLastItem = activeItem === items.length - 1\n\n if (withLoop) {\n setSlideActionType('next')\n if (isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: 0,\n id: items[0].id,\n },\n })\n setActiveItem(0)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setActiveItem(activeItem + 1)\n }\n } else {\n if (!isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setSlideActionType('next')\n setActiveItem(activeItem + 1)\n }\n }\n }\n function slideToPrevItem() {\n const isFirstItem = activeItem === 0\n\n if (withLoop) {\n setSlideActionType('prev')\n if (isFirstItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(items.length - 1)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n } else {\n if (!isFirstItem) {\n setSlideActionType('prev')\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n }\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n\n return itemIndex === activeItem - 1\n }\n\n const contextProps: UseTransitionCarouselContextProps = {\n activeItem,\n slideToItem,\n slideToNextItem,\n slideToPrevItem,\n enterFullscreen,\n exitFullscreen,\n useListenToCustomEvent,\n getIsNextItem,\n getIsPrevItem,\n getIsAnimating,\n getIsFullscreen,\n getIsActiveItem: id => {\n return findItemIndex(id) === activeItem\n },\n getCurrentActiveItem: () => ({\n id: items[activeItem].id,\n index: activeItem,\n }),\n }\n\n const carouselFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n {...bindSwipe()}\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n }}\n >\n {itemsFragment}\n </div>\n </UseTransitionCarouselContext.Provider>\n )\n\n const thumbsFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseTransitionCarouselContext.Provider>\n )\n\n return {\n carouselFragment,\n thumbsFragment,\n ...contextProps,\n }\n}\n"],"names":["useCustomEventsModule","eventsObserverRef","useRef","Subject","useListenToCustomEvent","fn","useEffect","subscribe","current","unsubscribe","emitObservable","data","next","useFullscreenModule","mainCarouselWrapperRef","handleResize","isFullscreen","setIsFullscreen","_isFullscreen","handleFullscreenChange","document","fullscreenElement","eventName","screenfull","isEnabled","on","off","enterFullscreen","elementRef","request","exitFullscreen","exit","getIsFullscreen","useMount","callback","isMounted","clean","InternalWrapper","forwardRef","children","rest","ref","_jsx","animated","div","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","itemsPerSlide","getFluidWrapperScrollValue","getSlideValue","CustomThumbsWrapperComponent","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","Wrapper","thumbsFragment","className","onWheel","stop","style","display","flex","position","flexDirection","overflowX","overflowY","maxHeight","getPreparedItems","_items","map","i","id","renderThumb","handlePrepareThumbsDate","thumbId","handleThumbsScroll","activeItem","actionType","totalScrollableValue","nextValue","start","from","[object Object]","to","thumbNode","querySelector","thumbWrapper","offsetDimension","scrollDirection","thumbOffsetPosition","offsetDirection","getThumbOffsetPosition","thumbScrollDimension","getThumbScrollDimension","getScrollFromValue","scrollDimensionProperty","length","getScrollToValue","val","scrollLeft","scrollTop","UseSpringCarouselContext","createContext","undefined","UseTransitionCarouselContext","withLoop","draggingSlideTreshold","default","shouldResizeOnWindowResize","enableThumbsWrapperScroll","carouselSlideAxis","initialActiveItem","initialStartingPosition","disableGestures","gutter","startEndGutter","touchAction","slideAmount","freeScroll","slideActionType","internalItems","carouselTrackWrapperRef","isDragging","isAnimating","windowIsHidden","currentWindowWidth","fluidTotalWrapperScrollValue","slideFluidEndReached","initialWindowWidth","carouselStyles","setCarouselStyles","getMainCarouselWrapperWidth","useCallback","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","window","innerWidth","immediate","diff","_thumbsFragment","getWrapperScrollDirection","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","cancelDrag","cancel","resetAnimation","getSlideActionType","setIsDragging","direction","setSlideActionType","prevItemTreshold","nextItemTreshold","width","getIsLastItem","slideToNextItem","slideToPrevItem","last","pressed","enabled","type","setActiveItem","newItem","setIsAnimating","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","slideToItem","customTo","onRest","nextItem","index","finished","currentItem","nextPrevValue","willGoAfterLastFluidItem","currentWidth","isInteger","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","resize","setTimeout","contextProps","getIsAnimating","getIsDragging","getIsNextItem","itemIndex","getIsPrevItem","_item","getIsActiveItem","carouselFragment","Provider","height","percentValue","getAnimatedWrapperStyles","renderItem","marginRight","marginBottom","context","useContext","toPrevItemSpringProps","toNextItemSpringProps","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","keys","transitions","styles","newActiveItem","overflow"],"mappings":"0oBAIgBA,IACd,MAAMC,EAAoBC,SAAO,IAAIC,WAarC,MAAO,CACLC,uBAZF,SAAgCC,GAC9BC,aAAU,KACR,MAAMC,EAAYN,EAAkBO,QAAQD,UAAUF,GACtD,MAAO,IAAME,EAAUE,gBACtB,CAACJ,KASJK,eANuCC,IACvCV,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