react-spring-carousel 2.0.17 → 2.0.19-beta007

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("react-spring"),r=require("@use-gesture/react"),i=require("rxjs");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(require("screenfull"));function u(){const e=t.useRef(new i.Subject);return{useListenToCustomEvent:function(n){t.useEffect((()=>{const t=e.current.subscribe(n);return()=>t.unsubscribe()}),[n])},emitObservable:t=>{e.current.next(t)}}}const c="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function l(e){const n=t.useRef(!1);c((()=>{if(!n.current){const t=e();return n.current=!0,()=>{t&&t()}}}),[])}function a({mainCarouselWrapperRef:e,emitObservable:n,handleResize:r}){const i=t.useRef(!1);function o(e){i.current=e}return l((()=>{function e(){document.fullscreenElement&&(o(!0),n({eventName:"onFullscreenChange",isFullscreen:!0}),r&&r()),document.fullscreenElement||(o(!1),n({eventName:"onFullscreenChange",isFullscreen:!1}),r&&r())}if(s.default.isEnabled)return s.default.on("change",e),()=>{s.default.isEnabled&&s.default.off("change",e)}})),{enterFullscreen:function(t){s.default.isEnabled&&s.default.request(t||e.current)},exitFullscreen:function(){s.default.isEnabled&&s.default.exit()},getIsFullscreen:function(){return i.current}}}function f({items:r,withThumbs:i,thumbsSlideAxis:o="x",springConfig:s,prepareThumbsData:u,getFluidWrapperScrollValue:c=(()=>0),getSlideValue:a=(()=>0),slideType:f}){const d=t.useRef(null),[h,g]=n.useSpring((()=>({x:0,y:0,config:s,onChange:({value:e})=>{d.current&&"fluid"===f&&(d.current["x"===o?"scrollLeft":"scrollTop"]=Math.abs(e[o]))}})));function m(){return d.current["x"===o?"scrollLeft":"scrollTop"]}function p(){var e;return Math.round(Number(null===(e=d.current)||void 0===e?void 0:e["x"===o?"scrollWidth":"scrollHeight"])-d.current.getBoundingClientRect()["x"===o?"width":"height"])}function v(){const e=Math.round(c()/a());return p()/e}l((()=>{if(i&&!d.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.")}));return{thumbsFragment:i?e.jsx(n.animated.div,Object.assign({ref:d,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{h[o].stop()},style:Object.assign({display:"flex",flex:1,position:"relative",width:"100%",height:"100%",flexDirection:"x"===o?"row":"column"},"x"===o?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"})},{children:function(){function e(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return u?u(e(r)):e(r)}().map((({id:t,renderThumb:n})=>{const r=`thumb-${t}`;return e.jsx("div",Object.assign({id:r,className:"thumb-item"},{children:n}),r)}))})):null,handleThumbsScroll:function(e,t){if("fluid"===f){const e=p();if("next"===t){const t=m()+v();g.start({from:{[o]:m()},to:{[o]:t>e?e:t}})}if("prev"===t){const e=m()-v();g.start({from:{[o]:m()},to:{[o]:e<0?0:e}})}}else{const n=d.current.querySelector(`#thumb-${r[e].id}`);if(n){const i=d.current,s="x"===o?"offsetWidth":"offsetHeight",u="x"===o?"scrollLeft":"scrollTop",c=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:n,offsetDimension:s,offsetDirection:"x"===o?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:i,offsetDimension:s}),a=function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:i,scrollDirection:u}),f=function({thumbWrapper:t,thumbOffsetPosition:n,thumbScrollDimension:i,offsetDimension:s}){const u="x"===o?"scrollWidth":"scrollHeight";return e===r.length-1||n-i>t[u]-t[s]?t[u]-t[s]:0===e?0:n-i}({thumbWrapper:i,thumbOffsetPosition:c,thumbScrollDimension:l,offsetDimension:s});g.start({from:{[o]:a},to:{[o]:"prev"===t&&f<0?0:f},onChange:({value:e})=>{"x"===o?d.current.scrollLeft=e.x:d.current.scrollTop=e.y}})}}}}}const d=t.createContext(void 0),h=Object.assign(Object.assign({},n.config.default),{mass:1,velocity:0});const g=t.createContext(void 0);exports.useSpringCarousel=function({items:i,withLoop:o=!1,draggingSlideTreshold:s,springConfig:g=n.config.default,shouldResizeOnWindowResize:m=!0,withThumbs:p=!1,enableThumbsWrapperScroll:v=!0,slideWhenThresholdIsReached:b=!0,carouselSlideAxis:x="x",thumbsSlideAxis:y="x",prepareThumbsData:w,initialActiveItem:T=0,initialStartingPosition:j,disableGestures:O=!1,gutter:S=0,startEndGutter:C=0,touchAction:I,slideAmount:R,freeScroll:E=!1,enableFreeScrollDrag:A,itemsPerSlide:N=1,slideType:F="fixed"}){const W=t.useRef(!0),D=t.useRef("initial"),L=o?i.length===N?[...i,...i,...i,...i,...i]:[...i,...i,...i]:i,P=t.useRef(T),$=t.useRef(null),M=t.useRef(null),q=t.useRef(!1),z=t.useRef(!1),B=t.useRef(!1),H=t.useRef(0),k=t.useRef(!1),V=t.useRef(0),G=t.useRef(0),Y=t.useRef(0),X=t.useRef(i),_=t.useRef(null!=s?s:0),J=t.useRef(N),K=t.useRef(S),Q=t.useRef(C),U=t.useRef(T),Z=t.useRef(j),ee=t.useRef(x);J.current=N,K.current=S,Q.current=C,U.current=T,Z.current=j,ee.current=x;const[te,ne]=n.useSpring((()=>({y:0,x:0,onChange:({value:e})=>{$.current&&E&&($.current["x"===ee.current?"scrollLeft":"scrollTop"]=Math.abs(e[ee.current]))}})));function re(){const e=null===(t=M.current)||void 0===t?void 0:t.querySelector(".use-spring-carousel-item");var t;if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===ee.current?"width":"height"]+K.current}function ie(){return te[ee.current].get()}function oe(){return re()*i.length<function(){if(!$.current)throw new Error("mainCarouselWrapperRef is not available");return $.current.getBoundingClientRect()["x"===ee.current?"width":"height"]}()}function se(){var e;return Math.round(Number(null===(e=M.current)||void 0===e?void 0:e["x"===ee.current?"scrollWidth":"scrollHeight"])-M.current.getBoundingClientRect()["x"===ee.current?"width":"height"])}function ue(){return 0===Se()}function ce(){if(!M.current)return 0;const e=re();if("fluid"===F&&"number"==typeof R){if(R<e)throw new Error("slideAmount must be greater than the width of a single item.");return R}return e}function le(e,t){const n="x"===ee.current?"left":"top";function r(){return re()*i.length}function s(r){o?(e.style.top="0px",e.style[n]=`-${r-Q.current}px`):(e.style.left="0px",e.style.top="0px",t&&W.current&&(e.style[n]=`calc(-${t} * 100%)`))}function u(){s(r())}if("fixed"===F){if(J.current>1)switch(Z.current){default:case"start":u();break;case"center":c=J.current,s(r()-ce()*Math.round((c-1)/2));break;case"end":!function(e){s(r()-ce()*Math.round(e-1))}(J.current)}else u()}else u();var c}function ae(){if(V.current=window.innerWidth,"fluid"===F){if(oe())return void ne.start({immediate:!0,[ee.current]:0});if(H.current=se(),k.current){const e=-H.current;ne.start({immediate:!0,[ee.current]:e})}G.current=window.innerWidth}else ne.start({immediate:!0,[ee.current]:-ce()*Se()});H.current=se(),le(M.current)}function fe(){window.innerWidth===V.current||E||ae()}c((()=>{_.current=s||Math.floor(ce()/2/2),ae()}),[s,N,S,C,T,j,x,y]);const{useListenToCustomEvent:de,emitObservable:he}=u(),{enterFullscreen:ge,exitFullscreen:me,getIsFullscreen:pe}=a({mainCarouselWrapperRef:$,emitObservable:he,handleResize:fe}),{thumbsFragment:ve,handleThumbsScroll:be}=f({withThumbs:p,items:i,thumbsSlideAxis:y,springConfig:g,prepareThumbsData:w,slideType:F,getFluidWrapperScrollValue:se,getSlideValue:ce});function xe(){if(!$.current)throw new Error("Missing mainCarouselWrapperRef.current");return $.current["x"===ee.current?"scrollLeft":"scrollTop"]}function ye(){return"boolean"==typeof A?A:"function"==typeof A&&A()}const we=r.useDrag((e=>{const t=e.dragging,n=e.offset["x"===ee.current?0:1],r=e.movement["x"===ee.current?0:1],i=r>_.current,s=r<-_.current,u=e.direction["x"===ee.current?0:1];function c(){e.cancel()}function l(){Te(u>0?"prev":"next")}function a(){he(Object.assign({eventName:"onDrag",slideActionType:je()},e))}function f(){"fluid"===F?oe()||ue()&&"prev"===je()?ne.start({[ee.current]:0,config:{velocity:e.velocity}}):k.current&&"next"===je()?ne.start({[ee.current]:-H.current,config:{velocity:e.velocity}}):ne.start({[ee.current]:Y.current,config:{velocity:e.velocity}}):ne.start({[ee.current]:-Se()*ce(),config:{velocity:e.velocity}})}function d(){Math.abs(ie())+100>=H.current&&"next"===je()&&(k.current=!0),"prev"===je()&&(k.current=!1)}if(E&&ye())return l(),a(),d(),ne.start({from:{[ee.current]:xe()},to:{[ee.current]:-n},config:{velocity:e.velocity}}),0===xe()&&"prev"===je()?void c():void 0;if(t){if(Re()||Ie(!0),a(),l(),d(),E){if(ye()){if(0===xe()&&"prev"===je())return void c();ne.start({config:{velocity:e.velocity,friction:50,tension:1e3},from:{[ee.current]:xe()},to:{[ee.current]:-n}})}return}if(ne.start({[ee.current]:n,config:{velocity:e.velocity,friction:50,tension:1e3}}),(i||s)&&oe()&&"fluid"===F)c(),f();else if(k.current&&"next"===je()&&s)k.current=!1,c(),ne.start({[ee.current]:-H.current});else if(b){if(s)return c(),void(!o&&De()?f():Pe(e.velocity));if(i)return c(),void(!o&&ue()?f():Le(e.velocity))}}!e.last||b||!s&&!i||E?!e.last||s||i||E||(f(),he(Object.assign({eventName:"onDrag",slideActionType:je()},e))):s?!o&&De()?f():Pe(e.velocity):i&&(!o&&ue()?f():Le(e.velocity))}),{enabled:!O,axis:ee.current,from:()=>E?"x"===ee.current?[-xe(),0]:[0,-xe()]:[te.x.get(),te.y.get()]});function Te(e){D.current=e}function je(){return D.current}function Oe(e){P.current=e}function Se(){return P.current}function Ce(e){z.current=e}function Ie(e){q.current=e}function Re(){return q.current}function Ee(){const e=Se();return 0===e?i.length-1:e-1}function Ae(){const e=Se();return e===i.length-1?0:e+1}function Ne(e){return i.findIndex((t=>t.id===e))}function Fe(e,t){if("number"==typeof e)return{[ee.current]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[ee.current]:-ce()*t}}function We({from:e,to:t=-1,customTo:n,immediate:r=!1,onRest:o=(()=>{}),velocity:s}){r||(Oe(t),Ce(!0),he({eventName:"onSlideStartChange",slideActionType:je(),nextItem:{index:"fluid"===F?-1:t,id:"fluid"===F?"":i[t].id}})),Y.current=Fe(n,t)[x],ne.start(Object.assign(Object.assign(Object.assign(Object.assign({},function(e){return"number"==typeof e?{from:{[ee.current]:e}}:{}}(e)),{to:Fe(n,t)}),s?{config:Object.assign(Object.assign({},h),{velocity:s,friction:void 0,tension:void 0})}:{config:Object.assign({velocity:0},g)}),{immediate:r,onRest:e=>{e.finished&&(Ie(!1),Ce(!1),o(),r||he({eventName:"onSlideChange",slideActionType:je(),currentItem:{index:"fluid"===F?-1:Se(),id:"fluid"===F?"":i[Se()].id}}))}})),v&&p&&!r&&be(t,je())}function De(){return Se()===i.length-1}function Le(e){if(Te("prev"),k.current=!1,"fluid"===F){if(k.current=!1,oe())return;const t=ie()+ce()+200;if(E){const t=$.current.scrollLeft-ce();We({customTo:t<0?0:t,from:$.current.scrollLeft,velocity:e})}else We(t>=0?o?{from:ie()-re()*i.length,velocity:e,customTo:ie()-re()*i.length+ce()}:{customTo:0,velocity:e}:{customTo:ie()+ce(),velocity:e})}else{if(!o&&0===Se()||B.current)return;ue()?We({from:ie()-ce()*i.length,to:i.length-1,velocity:e}):We({to:Ee(),velocity:e})}}function Pe(e){if(Te("next"),"fluid"===F){if(oe())return;const t=Math.abs(ie()-ce())+100>=H.current;if(E){const t=$.current.scrollLeft+ce()>H.current,n=$.current.scrollLeft+ce();We({velocity:e,customTo:t?H.current:n,from:$.current.scrollLeft})}else if(o&&Math.abs(ie()-ce())>=i.length*re()){const t=re()*i.length;We({from:ie()+t,customTo:ie()+t-ce(),velocity:e})}else{if(k.current)return;t?(k.current=!0,We({customTo:-H.current,velocity:e})):We({customTo:ie()-ce(),velocity:e})}}else{if(!o&&Se()===L.length-1||B.current)return;Math.abs(ie()-ce()+25)>H.current&&!Re()?k.current=!0:k.current?We({to:i.length-J.current,velocity:e}):De()?We({from:ie()+ce()*i.length,to:0,velocity:e}):We({to:Ae(),velocity:e})}}function $e(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===Se()||i.length!==X.current.length&&Se()<i.length)return;const n=Ne(X.current[Se()].id);Te(Ne(i[t].id)>n?"next":"prev"),We({to:t})}l((()=>{if(N%2==0&&Z.current)throw new Error("initialStartingPosition can be only used if itemsPerSlide is an even value.");if(_.current<0)throw new Error("draggingSlideTreshold must be greater than 0");if(_.current>ce()/2)throw new Error(`draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(ce()/2)}`);if(J.current<1)throw new Error("The itemsPerSlide prop can't be less than 1.");if(J.current>i.length)throw new Error("The itemsPerSlide prop can't be greater than the total length of the items you provide.");if(U.current<0)throw new Error("The initialActiveItem cannot be less than 0.");if(U.current>i.length)throw new Error("The initialActiveItem cannot be greater than the total length of the items you provide.");m||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.")})),l((()=>{function e(){document.hidden?B.current=!0:B.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),l((()=>{W.current=!1,H.current=se(),G.current=window.innerWidth,V.current=window.innerWidth,T>0&&(We({to:T,immediate:!0}),Oe(T),!o&&M.current&&(M.current.style.top="0px",M.current.style.left="0px"))})),c((()=>{T<i.length&&T!==P.current&&(We({to:T,immediate:!0}),Oe(T))}),[T]),c((()=>{if(m)return window.addEventListener("resize",fe),()=>{window.removeEventListener("resize",fe)}}),[m]),c((()=>{M.current&&("x"===ee.current&&(M.current.style.top="0px"),"y"===ee.current&&(M.current.style.left="0px"))}),[x]),c((()=>{H.current=se();!(i.length===X.current.length)&&i.length<X.current.length&&$e(i.length-1),X.current=i}),[se,i]);const Me=Object.assign({useListenToCustomEvent:de,getIsFullscreen:pe,enterFullscreen:ge,exitFullscreen:me,getIsAnimating:function(){return z.current},getIsDragging:Re,getIsNextItem:function(e){const t=Ne(e),n=Se();return o&&n===i.length-1?0===t:t===n+1},getIsPrevItem:function(e){const t=Ne(e),n=Se();return o&&0===n?t===i.length-1:t===n-1},slideToPrevItem(){Le()},slideToNextItem(){Pe()}},"fixed"===F?{slideToItem:$e,getIsActiveItem:e=>Ne(e)===Se(),getCurrentActiveItem:()=>({id:i[Se()].id,index:Se()})}:{}),qe=e.jsx(d.Provider,Object.assign({value:Me},{children:e.jsx("div",Object.assign({ref:$,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},E?{onWheel(){te[ee.current].stop()}}:{},{style:Object.assign({display:"flex",position:"relative",width:"100%",height:"100%"},E?"x"===ee.current?{overflowX:"auto"}:{overflowY:"auto"}:{})},{children:e.jsx(n.animated.div,Object.assign({},we(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{e&&(M.current=e,le(e,U.current))},style:Object.assign(Object.assign(Object.assign({display:"flex",position:"relative",touchAction:O?"unset":I||("x"===ee.current?"pan-y":"pan-x"),flexDirection:"x"===ee.current?"row":"column"},function(){const e=`calc(100% - ${2*Q.current}px)`;return{width:"x"===ee.current?e:"100%",height:"y"===ee.current?e:"100%"}}()),function(){const e=i.length/N*100,t=100/N,n="x"===ee.current?"left":"y",r=Math.floor(50/t);if("fixed"===F){if("center"===Z.current)return{[n]:`calc(-${e}% + ${t*r}%)`};if("end"===Z.current)return{[n]:`calc(-${e}% + ${t*(2*r)}%)`}}return{[n]:"0px"}}()),E?{}:te)},{children:L.map((({id:t,renderItem:n},r)=>{return e.jsx("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:Object.assign({display:"flex",position:"relative"},(i=J.current,"fixed"===F?Object.assign(Object.assign({},"x"===ee.current?{marginRight:`${K.current}px`}:{marginBottom:`${K.current}px`}),{flex:`1 0 calc(100% / ${i} - ${K.current*(i-1)/i}px)`}):Object.assign({},"x"===ee.current?{marginRight:`${K.current}px`}:{marginBottom:`${K.current}px`})))},{children:n}),`${t}-${r}`);var i}))}))}))})),ze=e.jsx(d.Provider,Object.assign({value:Me},{children:ve}));return Object.assign(Object.assign({},Me),{carouselFragment:qe,thumbsFragment:ze})},exports.useSpringCarouselContext=function(){const e=t.useContext(d);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e},exports.useTransitionCarousel=function({items:i,withLoop:o=!1,withThumbs:s=!1,springConfig:c=n.config.default,thumbsSlideAxis:l="x",enableThumbsWrapperScroll:d=!0,draggingSlideTreshold:h=50,prepareThumbsData:m,toPrevItemSpringProps:p,toNextItemSpringProps:v,disableGestures:b=!1,trail:x,exitBeforeEnter:y=!1,springAnimationProps:w={initial:{opacity:1,position:"absolute"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"absolute"},leave:{opacity:0,position:"absolute"}}}){const T=t.useRef("next"),j=t.useRef(null),O=t.useRef(!1),[S,C]=t.useState(0),{emitObservable:I,useListenToCustomEvent:R}=u(),{enterFullscreen:E,exitFullscreen:A,getIsFullscreen:N}=a({emitObservable:I,mainCarouselWrapperRef:j}),{thumbsFragment:F,handleThumbsScroll:W}=f({items:i,withThumbs:s,thumbsSlideAxis:l,springConfig:c,prepareThumbsData:m,slideType:"fixed"}),D=r.useDrag((({last:e,movement:[t]})=>{if(!P()&&e){const e=t>h,n=t<-h,r=0===S,s=S===i.length-1;if(n){if(!o&&s)return;z(),I({eventName:"onLeftSwipe"})}else if(e){if(!o&&r)return;B(),I({eventName:"onRightSwipe"})}}}),{enabled:!b}),L=n.useTransition(S,Object.assign(Object.assign({config:c},function(){const e=q();return"prev"===e&&p?{initial:Object.assign({},w.initial),from:Object.assign({},p.from),enter:Object.assign({},p.enter),leave:Object.assign({},p.leave)}:"next"===e&&v?{initial:Object.assign({},w.initial),from:Object.assign({},v.from),enter:Object.assign({},v.enter),leave:Object.assign({},v.leave)}:{initial:Object.assign({},w.initial),from:Object.assign({},w.from),enter:Object.assign({},w.enter),leave:Object.assign({},w.leave)}}()),{onStart:()=>$(!0),trail:x,exitBeforeEnter:y,key:i[S].id,onRest:e=>{e.finished&&($(!1),I({eventName:"onSlideChange",slideActionType:q(),currentItem:{index:S,id:i[S].id}}))}}))(((t,r)=>e.jsx(n.animated.div,Object.assign({style:Object.assign(Object.assign({},t),{flex:"1 0 100%",width:"100%",height:"100%"})},{children:i[r].renderItem}))));function P(){return O.current}function $(e){O.current=e}function M(e){T.current=e}function q(){return T.current}function z(){const e=S===i.length-1;o?(M("next"),e?(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:0,id:i[0].id}}),C(0)):(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S+1,id:i[S+1].id}}),C(S+1))):e||(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S+1,id:i[S+1].id}}),M("next"),C(S+1))}function B(){const e=0===S;o?(M("prev"),e?(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:i.length-1,id:i[i.length-1].id}}),C(i.length-1)):(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S-1,id:i[S-1].id}}),C(S-1))):e||(M("prev"),I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S-1,id:i[S-1].id}}),C(S-1))}function H(e){return i.findIndex((t=>t.id===e))}const k={activeItem:S,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===S)return;const n=H(i[S].id),r=H(i[t].id);I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:r,id:i[t].id}}),M(r>n?"next":"prev"),C(t),d&&s&&W(t)},slideToNextItem:z,slideToPrevItem:B,enterFullscreen:E,exitFullscreen:A,useListenToCustomEvent:R,getIsNextItem:function(e){const t=H(e);return o&&S===i.length-1?0===t:t===S+1},getIsPrevItem:function(e){const t=H(e);return o&&0===S?t===i.length-1:t===S-1},getIsAnimating:P,getIsFullscreen:N,getIsActiveItem:e=>H(e)===S,getCurrentActiveItem:()=>({id:i[S].id,index:S})},V=e.jsx(g.Provider,Object.assign({value:k},{children:e.jsx("div",Object.assign({ref:j},D(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:L}))})),G=e.jsx(g.Provider,Object.assign({value:k},{children:F}));return Object.assign({carouselFragment:V,thumbsFragment:G},k)},exports.useTransitionCarouselContext=function(){const e=t.useContext(g);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};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("react-spring"),r=require("@use-gesture/react"),i=require("rxjs");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(require("screenfull"));function u(){const e=t.useRef(new i.Subject);return{useListenToCustomEvent:function(n){t.useEffect((()=>{const t=e.current.subscribe(n);return()=>t.unsubscribe()}),[n])},emitObservable:t=>{e.current.next(t)}}}const c="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function l(e){const n=t.useRef(!1);c((()=>{if(!n.current){const t=e();return n.current=!0,()=>{t&&t()}}}),[])}function a({mainCarouselWrapperRef:e,emitObservable:n,handleResize:r}){const i=t.useRef(!1);function o(e){i.current=e}return l((()=>{function e(){document.fullscreenElement&&(o(!0),n({eventName:"onFullscreenChange",isFullscreen:!0}),r&&r()),document.fullscreenElement||(o(!1),n({eventName:"onFullscreenChange",isFullscreen:!1}),r&&r())}if(s.default.isEnabled)return s.default.on("change",e),()=>{s.default.isEnabled&&s.default.off("change",e)}})),{enterFullscreen:function(t){s.default.isEnabled&&s.default.request(t||e.current)},exitFullscreen:function(){s.default.isEnabled&&s.default.exit()},getIsFullscreen:function(){return i.current}}}function f({items:r,withThumbs:i,thumbsSlideAxis:o="x",springConfig:s,prepareThumbsData:u,getFluidWrapperScrollValue:c=(()=>0),getSlideValue:a=(()=>0),slideType:f}){const d=t.useRef(null),[h,g]=n.useSpring((()=>({x:0,y:0,config:s,onChange:({value:e})=>{d.current&&"fluid"===f&&(d.current["x"===o?"scrollLeft":"scrollTop"]=Math.abs(e[o]))}})));function m(){return d.current["x"===o?"scrollLeft":"scrollTop"]}function p(){var e;return Math.round(Number(null===(e=d.current)||void 0===e?void 0:e["x"===o?"scrollWidth":"scrollHeight"])-d.current.getBoundingClientRect()["x"===o?"width":"height"])}function v(){const e=Math.round(c()/a());return p()/e}l((()=>{if(i&&!d.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.")}));return{thumbsFragment:i?e.jsx(n.animated.div,Object.assign({ref:d,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{h[o].stop()},style:Object.assign({display:"flex",flex:1,position:"relative",width:"100%",height:"100%",flexDirection:"x"===o?"row":"column"},"x"===o?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"})},{children:function(){function e(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return u?u(e(r)):e(r)}().map((({id:t,renderThumb:n})=>{const r=`thumb-${t}`;return e.jsx("div",Object.assign({id:r,className:"thumb-item"},{children:n}),r)}))})):null,handleThumbsScroll:function(e,t){if("fluid"===f){const e=p();if("next"===t){const t=m()+v();g.start({from:{[o]:m()},to:{[o]:t>e?e:t}})}if("prev"===t){const e=m()-v();g.start({from:{[o]:m()},to:{[o]:e<0?0:e}})}}else{const n=d.current.querySelector(`#thumb-${r[e].id}`);if(n){const i=d.current,s="x"===o?"offsetWidth":"offsetHeight",u="x"===o?"scrollLeft":"scrollTop",c=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:n,offsetDimension:s,offsetDirection:"x"===o?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:i,offsetDimension:s}),a=function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:i,scrollDirection:u}),f=function({thumbWrapper:t,thumbOffsetPosition:n,thumbScrollDimension:i,offsetDimension:s}){const u="x"===o?"scrollWidth":"scrollHeight";return e===r.length-1||n-i>t[u]-t[s]?t[u]-t[s]:0===e?0:n-i}({thumbWrapper:i,thumbOffsetPosition:c,thumbScrollDimension:l,offsetDimension:s});g.start({from:{[o]:a},to:{[o]:"prev"===t&&f<0?0:f},onChange:({value:e})=>{"x"===o?d.current.scrollLeft=e.x:d.current.scrollTop=e.y}})}}}}}const d=t.createContext(void 0),h=Object.assign(Object.assign({},n.config.default),{mass:1,velocity:0});const g=t.createContext(void 0);exports.useSpringCarousel=function({items:i,withLoop:o=!1,draggingSlideTreshold:s,springConfig:g=n.config.default,shouldResizeOnWindowResize:m=!0,withThumbs:p=!1,enableThumbsWrapperScroll:v=!0,slideWhenThresholdIsReached:b=!0,carouselSlideAxis:x="x",thumbsSlideAxis:y="x",prepareThumbsData:w,initialActiveItem:T=0,initialStartingPosition:j,disableGestures:O=!1,gutter:S=0,startEndGutter:C=0,touchAction:I,slideAmount:R,freeScroll:E=!1,enableFreeScrollDrag:A,itemsPerSlide:N=1,slideType:F="fixed"}){const W=t.useRef(!0),D=t.useRef("initial"),L=o?i.length===N?[...i,...i,...i,...i,...i]:[...i,...i,...i]:i,P=t.useRef(T),$=t.useRef(null),M=t.useRef(null),q=t.useRef(!1),z=t.useRef(!1),B=t.useRef(!1),H=t.useRef(0),k=t.useRef(!1),V=t.useRef(0),G=t.useRef(0),Y=t.useRef(0),X=t.useRef(i),_=t.useRef(null!=s?s:0),J=t.useRef(N),K=t.useRef(S),Q=t.useRef(C),U=t.useRef(T),Z=t.useRef(j),ee=t.useRef(x);J.current=N,K.current=S,Q.current=C,U.current=T,Z.current=j,ee.current=x;const[te,ne]=n.useSpring((()=>({y:0,x:0,onChange:({value:e})=>{$.current&&E&&($.current["x"===ee.current?"scrollLeft":"scrollTop"]=Math.abs(e[ee.current]))}})));function re(){const e=null===(t=M.current)||void 0===t?void 0:t.querySelector(".use-spring-carousel-item");var t;if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===ee.current?"width":"height"]+K.current}function ie(){return te[ee.current].get()}function oe(){return re()*i.length<function(){if(!$.current)throw new Error("mainCarouselWrapperRef is not available");return $.current.getBoundingClientRect()["x"===ee.current?"width":"height"]}()}function se(){var e;return Math.round(Number(null===(e=M.current)||void 0===e?void 0:e["x"===ee.current?"scrollWidth":"scrollHeight"])-M.current.getBoundingClientRect()["x"===ee.current?"width":"height"])}function ue(){return 0===Se()}function ce(){if(!M.current)return 0;const e=re();if("fluid"===F&&"number"==typeof R){if(R<e)throw new Error("slideAmount must be greater than the width of a single item.");return R}return e}function le(e,t){const n="x"===ee.current?"left":"top";function r(){return re()*i.length}function s(r){o?(e.style.top="0px",e.style[n]=`-${r-Q.current}px`):(e.style.left="0px",e.style.top="0px",t&&W.current&&(e.style[n]=`calc(-${t} * 100%)`))}function u(){s(r())}if("fixed"===F){if(J.current>1)switch(Z.current){default:case"start":u();break;case"center":c=J.current,s(r()-ce()*Math.round((c-1)/2));break;case"end":!function(e){s(r()-ce()*Math.round(e-1))}(J.current)}else u()}else u();var c}function ae(){if(V.current=window.innerWidth,"fluid"===F){if(oe())return void ne.start({immediate:!0,[ee.current]:0});if(H.current=se(),k.current){const e=-H.current;ne.start({immediate:!0,[ee.current]:e})}G.current=window.innerWidth}else ne.start({immediate:!0,[ee.current]:-ce()*Se()});H.current=se(),le(M.current)}function fe(){window.innerWidth===V.current||E||ae()}c((()=>{_.current=s||Math.floor(ce()/2/2),ae()}),[s,N,S,C,T,j,x,y]);const{useListenToCustomEvent:de,emitObservable:he}=u(),{enterFullscreen:ge,exitFullscreen:me,getIsFullscreen:pe}=a({mainCarouselWrapperRef:$,emitObservable:he,handleResize:fe}),{thumbsFragment:ve,handleThumbsScroll:be}=f({withThumbs:p,items:i,thumbsSlideAxis:y,springConfig:g,prepareThumbsData:w,slideType:F,getFluidWrapperScrollValue:se,getSlideValue:ce});function xe(){if(!$.current)throw new Error("Missing mainCarouselWrapperRef.current");return $.current["x"===ee.current?"scrollLeft":"scrollTop"]}function ye(){return"boolean"==typeof A?A:"function"==typeof A&&A()}const we=r.useDrag((e=>{const t=e.dragging,n=e.offset["x"===ee.current?0:1],r=e.movement["x"===ee.current?0:1],i=r>_.current,s=r<-_.current,u=e.direction["x"===ee.current?0:1];function c(){e.cancel()}function l(){Te(u>0?"prev":"next")}function a(){he(Object.assign({eventName:"onDrag",slideActionType:je()},e))}function f(){"fluid"===F?oe()||ue()&&"prev"===je()?ne.start({[ee.current]:0,config:Object.assign({velocity:e.velocity},g)}):k.current&&"next"===je()?ne.start({[ee.current]:-H.current,config:Object.assign({velocity:e.velocity},g)}):ne.start({[ee.current]:Y.current,config:Object.assign({velocity:e.velocity},g)}):ne.start({[ee.current]:-Se()*ce(),config:Object.assign({velocity:e.velocity},g)})}function d(){Math.abs(ie())+100>=H.current&&"next"===je()&&(k.current=!0),"prev"===je()&&(k.current=!1)}if(E&&ye())return t&&(Re()||Ie(!0),l(),a(),d()),ne.start({from:{[ee.current]:xe()},to:{[ee.current]:-n},config:{velocity:e.velocity,friction:50,tension:1400}}),0===xe()&&"prev"===je()?void c():void(e.last&&("prev"===je()?Le(e.velocity):Pe(e.velocity),Ie(!1)));if(t){if(Re()||Ie(!0),a(),l(),d(),E){if(ye()){if(0===xe()&&"prev"===je())return void c();ne.start({config:{velocity:e.velocity,friction:50,tension:1400},from:{[ee.current]:xe()},to:{[ee.current]:-n}})}return}if(ne.start({[ee.current]:n,config:{velocity:e.velocity,friction:50,tension:1e3}}),(i||s)&&oe()&&"fluid"===F)c(),f();else if(k.current&&"next"===je()&&s)k.current=!1,c(),ne.start({[ee.current]:-H.current});else if(b){if(s)return c(),void(!o&&De()?f():Pe(e.velocity));if(i)return c(),void(!o&&ue()?f():Le(e.velocity))}}if(e.last&&!b&&(s||i)&&!E)return Ie(!1),void(s?!o&&De()?f():Pe(e.velocity):i&&(!o&&ue()?f():Le(e.velocity)));!e.last||s||i||E||(f(),he(Object.assign({eventName:"onDrag",slideActionType:je()},e)))}),{enabled:!O,axis:ee.current,from:()=>E?"x"===ee.current?[-xe(),0]:[0,-xe()]:[te.x.get(),te.y.get()]});function Te(e){D.current=e}function je(){return D.current}function Oe(e){P.current=e}function Se(){return P.current}function Ce(e){z.current=e}function Ie(e){q.current=e}function Re(){return q.current}function Ee(){const e=Se();return 0===e?i.length-1:e-1}function Ae(){const e=Se();return e===i.length-1?0:e+1}function Ne(e){return i.findIndex((t=>t.id===e))}function Fe(e,t){if("number"==typeof e)return{[ee.current]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[ee.current]:-ce()*t}}function We({from:e,to:t=-1,customTo:n,immediate:r=!1,onRest:o=(()=>{}),velocity:s}){r||(Oe(t),Ce(!0),he({eventName:"onSlideStartChange",slideActionType:je(),nextItem:{index:"fluid"===F?-1:t,id:"fluid"===F?"":i[t].id}})),Y.current=Fe(n,t)[x],ne.start(Object.assign(Object.assign(Object.assign(Object.assign({},function(e){return"number"==typeof e?{from:{[ee.current]:e}}:{}}(e)),{to:Fe(n,t)}),s?{config:Object.assign(Object.assign({},h),{velocity:s,friction:void 0,tension:void 0})}:{config:Object.assign({velocity:0},g)}),{immediate:r,onRest:e=>{e.finished&&(Ie(!1),Ce(!1),o(),r||he({eventName:"onSlideChange",slideActionType:je(),currentItem:{index:"fluid"===F?-1:Se(),id:"fluid"===F?"":i[Se()].id}}))}})),v&&p&&!r&&be(t,je())}function De(){return Se()===i.length-1}function Le(e){if(Te("prev"),k.current=!1,"fluid"===F){if(k.current=!1,oe())return;const t=ie()+ce()+200;if(E){const t=$.current.scrollLeft-ce();We({customTo:t<0?0:t,from:$.current.scrollLeft,velocity:e})}else We(t>=0?o?{from:ie()-re()*i.length,velocity:e,customTo:ie()-re()*i.length+ce()}:{customTo:0,velocity:e}:{customTo:ie()+ce(),velocity:e})}else{if(!o&&0===Se()||B.current)return;ue()?We({from:ie()-ce()*i.length,to:i.length-1,velocity:e}):We({to:Ee(),velocity:e})}}function Pe(e){if(Te("next"),"fluid"===F){if(oe())return;const t=Math.abs(ie()-ce())+100>=H.current;if(E){const t=$.current.scrollLeft+ce()>H.current,n=$.current.scrollLeft+ce();We({velocity:e,customTo:t?H.current:n,from:$.current.scrollLeft})}else if(o&&Math.abs(ie()-ce())>=i.length*re()){const t=re()*i.length;We({from:ie()+t,customTo:ie()+t-ce(),velocity:e})}else{if(k.current)return;t?(k.current=!0,We({customTo:-H.current,velocity:e})):We({customTo:ie()-ce(),velocity:e})}}else{if(!o&&Se()===L.length-1||B.current)return;Math.abs(ie()-ce()+25)>H.current&&!Re()?k.current=!0:k.current?We({to:i.length-J.current,velocity:e}):De()?We({from:ie()+ce()*i.length,to:0,velocity:e}):We({to:Ae(),velocity:e})}}function $e(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===Se()||i.length!==X.current.length&&Se()<i.length)return;const n=Ne(X.current[Se()].id);Te(Ne(i[t].id)>n?"next":"prev"),We({to:t})}l((()=>{if(N%2==0&&Z.current)throw new Error("initialStartingPosition can be only used if itemsPerSlide is an even value.");if(_.current<0)throw new Error("draggingSlideTreshold must be greater than 0");if(_.current>ce()/2)throw new Error(`draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(ce()/2)}`);if(J.current<1)throw new Error("The itemsPerSlide prop can't be less than 1.");if(J.current>i.length)throw new Error("The itemsPerSlide prop can't be greater than the total length of the items you provide.");if(U.current<0)throw new Error("The initialActiveItem cannot be less than 0.");if(U.current>i.length)throw new Error("The initialActiveItem cannot be greater than the total length of the items you provide.");m||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.")})),l((()=>{function e(){document.hidden?B.current=!0:B.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),l((()=>{W.current=!1,H.current=se(),G.current=window.innerWidth,V.current=window.innerWidth,T>0&&(We({to:T,immediate:!0}),Oe(T),!o&&M.current&&(M.current.style.top="0px",M.current.style.left="0px"))})),c((()=>{T<i.length&&T!==P.current&&(We({to:T,immediate:!0}),Oe(T))}),[T]),c((()=>{if(m)return window.addEventListener("resize",fe),()=>{window.removeEventListener("resize",fe)}}),[m]),c((()=>{M.current&&("x"===ee.current&&(M.current.style.top="0px"),"y"===ee.current&&(M.current.style.left="0px"))}),[x]),c((()=>{H.current=se();!(i.length===X.current.length)&&i.length<X.current.length&&$e(i.length-1),X.current=i}),[se,i]);const Me=Object.assign({useListenToCustomEvent:de,getIsFullscreen:pe,enterFullscreen:ge,exitFullscreen:me,getIsAnimating:function(){return z.current},getIsDragging:Re,getIsNextItem:function(e){const t=Ne(e),n=Se();return o&&n===i.length-1?0===t:t===n+1},getIsPrevItem:function(e){const t=Ne(e),n=Se();return o&&0===n?t===i.length-1:t===n-1},slideToPrevItem(){Le()},slideToNextItem(){Pe()}},"fixed"===F?{slideToItem:$e,getIsActiveItem:e=>Ne(e)===Se(),getCurrentActiveItem:()=>({id:i[Se()].id,index:Se()})}:{}),qe=e.jsx(d.Provider,Object.assign({value:Me},{children:e.jsx("div",Object.assign({ref:$,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},E?{onWheel(){te[ee.current].stop()}}:{},{style:Object.assign({display:"flex",position:"relative",width:"100%",height:"100%"},E?"x"===ee.current?{overflowX:"auto"}:{overflowY:"auto"}:{})},{children:e.jsx(n.animated.div,Object.assign({},we(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{e&&(M.current=e,le(e,U.current))},style:Object.assign(Object.assign(Object.assign({display:"flex",position:"relative",touchAction:O?"unset":I||("x"===ee.current?"pan-y":"pan-x"),flexDirection:"x"===ee.current?"row":"column"},function(){const e=`calc(100% - ${2*Q.current}px)`;return{width:"x"===ee.current?e:"100%",height:"y"===ee.current?e:"100%"}}()),function(){const e=i.length/N*100,t=100/N,n="x"===ee.current?"left":"y",r=Math.floor(50/t);if("fixed"===F){if("center"===Z.current)return{[n]:`calc(-${e}% + ${t*r}%)`};if("end"===Z.current)return{[n]:`calc(-${e}% + ${t*(2*r)}%)`}}return{[n]:"0px"}}()),E?{}:te)},{children:L.map((({id:t,renderItem:n},r)=>{return e.jsx("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:Object.assign({display:"flex",position:"relative"},(i=J.current,"fixed"===F?Object.assign(Object.assign({},"x"===ee.current?{marginRight:`${K.current}px`}:{marginBottom:`${K.current}px`}),{flex:`1 0 calc(100% / ${i} - ${K.current*(i-1)/i}px)`}):Object.assign({},"x"===ee.current?{marginRight:`${K.current}px`}:{marginBottom:`${K.current}px`})))},{children:n}),`${t}-${r}`);var i}))}))}))})),ze=e.jsx(d.Provider,Object.assign({value:Me},{children:ve}));return Object.assign(Object.assign({},Me),{carouselFragment:qe,thumbsFragment:ze})},exports.useSpringCarouselContext=function(){const e=t.useContext(d);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e},exports.useTransitionCarousel=function({items:i,withLoop:o=!1,withThumbs:s=!1,springConfig:c=n.config.default,thumbsSlideAxis:l="x",enableThumbsWrapperScroll:d=!0,draggingSlideTreshold:h=50,prepareThumbsData:m,toPrevItemSpringProps:p,toNextItemSpringProps:v,disableGestures:b=!1,trail:x,exitBeforeEnter:y=!1,springAnimationProps:w={initial:{opacity:1,position:"absolute"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"absolute"},leave:{opacity:0,position:"absolute"}}}){const T=t.useRef("next"),j=t.useRef(null),O=t.useRef(!1),[S,C]=t.useState(0),{emitObservable:I,useListenToCustomEvent:R}=u(),{enterFullscreen:E,exitFullscreen:A,getIsFullscreen:N}=a({emitObservable:I,mainCarouselWrapperRef:j}),{thumbsFragment:F,handleThumbsScroll:W}=f({items:i,withThumbs:s,thumbsSlideAxis:l,springConfig:c,prepareThumbsData:m,slideType:"fixed"}),D=r.useDrag((({last:e,movement:[t]})=>{if(!P()&&e){const e=t>h,n=t<-h,r=0===S,s=S===i.length-1;if(n){if(!o&&s)return;z(),I({eventName:"onLeftSwipe"})}else if(e){if(!o&&r)return;B(),I({eventName:"onRightSwipe"})}}}),{enabled:!b}),L=n.useTransition(S,Object.assign(Object.assign({config:c},function(){const e=q();return"prev"===e&&p?{initial:Object.assign({},w.initial),from:Object.assign({},p.from),enter:Object.assign({},p.enter),leave:Object.assign({},p.leave)}:"next"===e&&v?{initial:Object.assign({},w.initial),from:Object.assign({},v.from),enter:Object.assign({},v.enter),leave:Object.assign({},v.leave)}:{initial:Object.assign({},w.initial),from:Object.assign({},w.from),enter:Object.assign({},w.enter),leave:Object.assign({},w.leave)}}()),{onStart:()=>$(!0),trail:x,exitBeforeEnter:y,key:i[S].id,onRest:e=>{e.finished&&($(!1),I({eventName:"onSlideChange",slideActionType:q(),currentItem:{index:S,id:i[S].id}}))}}))(((t,r)=>e.jsx(n.animated.div,Object.assign({style:Object.assign(Object.assign({},t),{flex:"1 0 100%",width:"100%",height:"100%"})},{children:i[r].renderItem}))));function P(){return O.current}function $(e){O.current=e}function M(e){T.current=e}function q(){return T.current}function z(){const e=S===i.length-1;o?(M("next"),e?(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:0,id:i[0].id}}),C(0)):(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S+1,id:i[S+1].id}}),C(S+1))):e||(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S+1,id:i[S+1].id}}),M("next"),C(S+1))}function B(){const e=0===S;o?(M("prev"),e?(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:i.length-1,id:i[i.length-1].id}}),C(i.length-1)):(I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S-1,id:i[S-1].id}}),C(S-1))):e||(M("prev"),I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S-1,id:i[S-1].id}}),C(S-1))}function H(e){return i.findIndex((t=>t.id===e))}const k={activeItem:S,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===S)return;const n=H(i[S].id),r=H(i[t].id);I({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:r,id:i[t].id}}),M(r>n?"next":"prev"),C(t),d&&s&&W(t)},slideToNextItem:z,slideToPrevItem:B,enterFullscreen:E,exitFullscreen:A,useListenToCustomEvent:R,getIsNextItem:function(e){const t=H(e);return o&&S===i.length-1?0===t:t===S+1},getIsPrevItem:function(e){const t=H(e);return o&&0===S?t===i.length-1:t===S-1},getIsAnimating:P,getIsFullscreen:N,getIsActiveItem:e=>H(e)===S,getCurrentActiveItem:()=>({id:i[S].id,index:S})},V=e.jsx(g.Provider,Object.assign({value:k},{children:e.jsx("div",Object.assign({ref:j},D(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:L}))})),G=e.jsx(g.Provider,Object.assign({value:k},{children:F}));return Object.assign({carouselFragment:V,thumbsFragment:G},k)},exports.useTransitionCarouselContext=function(){const e=t.useContext(g);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};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/modules/useCustomEventsModule.tsx","../../src/utils.ts","../../src/modules/useFullscreenModule.tsx","../../src/modules/useThumbsModule.tsx","../../src/useSpringCarousel/index.tsx","../../src/useTransitionCarousel/index.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { Subject } from 'rxjs'\nimport {\n UseSpringCarouselEventsObservableProps,\n UseTransitionCarouselEventsObservableProps,\n ObservableCallbackFn,\n EmitObservableFn,\n} from '../types'\n\nexport function useCustomEventsModule<T>() {\n const eventsObserverRef = useRef(\n new Subject<\n T extends 'use-spring'\n ? UseSpringCarouselEventsObservableProps\n : UseTransitionCarouselEventsObservableProps\n >(),\n )\n\n function useListenToCustomEvent(fn: ObservableCallbackFn<T>) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn<T> = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, useLayoutEffect, useEffect } from 'react'\n\ntype Callback = () => void | (() => void)\n\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nfunction useIsomorphicMount(callback: Callback) {\n const isMounted = useRef(false)\n\n useIsomorphicLayoutEffect(() => {\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 { useIsomorphicLayoutEffect, useIsomorphicMount }\n","import { useRef, MutableRefObject } from 'react'\nimport screenfull from 'screenfull'\nimport { EmitObservableFn } from '../types'\nimport { useIsomorphicMount } from '../utils'\n\ntype FullscreenModule<T> = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn<T>\n handleResize?(): void\n}\n\nexport function useFullscreenModule<T>({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule<T>) {\n const isFullscreen = useRef(false)\n\n useIsomorphicMount(() => {\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 } from 'react'\nimport { useSpring, SpringConfig, animated } from 'react-spring'\nimport { useIsomorphicMount } from 'src/utils'\nimport { UseSpringCarouselProps, SlideActionType } from '../types'\nimport { ReactSpringCarouselItemWithThumbs } from '../types/useSpringCarousel'\nimport { PrepareThumbsData } from '../types/index'\n\ntype OffsetDimension = 'offsetWidth' | 'offsetHeight'\ntype OffsetDirection = 'offsetLeft' | 'offsetTop'\ntype ScrollDirection = 'scrollLeft' | 'scrollTop'\n\ntype Props = {\n items: ReactSpringCarouselItemWithThumbs[]\n withThumbs: boolean\n slideType: UseSpringCarouselProps['slideType']\n thumbsSlideAxis: UseSpringCarouselProps['thumbsSlideAxis']\n springConfig: SpringConfig\n prepareThumbsData?: UseSpringCarouselProps['prepareThumbsData']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n slideType,\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 && slideType === 'fluid') {\n internalThumbsWrapperRef.current[\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[thumbsSlideAxis])\n }\n },\n }))\n\n useIsomorphicMount(() => {\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 (slideType === '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 const fromValue = getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n })\n const toValue = getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n })\n\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: fromValue,\n },\n to: {\n [thumbsSlideAxis]: actionType === 'prev' && toValue < 0 ? 0 : toValue,\n },\n onChange: ({ value }) => {\n if (thumbsSlideAxis === 'x') {\n internalThumbsWrapperRef!.current!.scrollLeft = value.x\n } else {\n internalThumbsWrapperRef!.current!.scrollTop = value.y\n }\n },\n })\n }\n }\n }\n function handlePrepareThumbsData() {\n function getPreparedItems(\n _items: ReturnType<PrepareThumbsData>,\n ): ReturnType<PrepareThumbsData> {\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 thumbsFragment = withThumbs ? (\n <animated.div\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 width: '100%',\n height: '100%',\n flexDirection: thumbsSlideAxis === 'x' ? 'row' : 'column',\n ...(thumbsSlideAxis === 'x'\n ? { overflowX: 'auto' }\n : {\n overflowY: 'auto',\n maxHeight: '100%',\n }),\n }}\n >\n {handlePrepareThumbsData().map(({ id, renderThumb }) => {\n const thumbId = `thumb-${id}`\n return (\n <div key={thumbId} id={thumbId} className=\"thumb-item\">\n {renderThumb}\n </div>\n )\n })}\n </animated.div>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useContext } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from '../modules'\nimport {\n SlideToItemFnProps,\n SlideActionType,\n UseSpringFixedSlideTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n UseSpringFluidSlideTypeReturnProps,\n UseSpringCarouselBaseProps,\n UseSpringCarouselWithThumbs,\n UseSpringCarouselFluidType,\n DisableGesturesProps,\n WithLoopProps,\n UseSpringCarouselWithNoThumbs,\n EnableGesturesProps,\n WithNoLoop,\n UseSpringCarouselFixedSlideType,\n} from '../types/useSpringCarousel'\n\ntype ReturnType<T> = T extends 'fixed'\n ? UseSpringFixedSlideTypeReturnProps\n : UseSpringFluidSlideTypeReturnProps\ntype ContextTypes<T> = Omit<ReturnType<T>, 'carouselFragment' | 'thumbsFragment'>\n\nconst Context = createContext<ContextTypes<'fixed' | 'fluid'> | undefined>(undefined)\n\nconst defaultDragSpringConfig = {\n ...config.default,\n mass: 1,\n velocity: 0,\n}\n\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFluidType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fluid'>\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFixedSlideType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fixed'>\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n slideWhenThresholdIsReached = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition,\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps): ReturnType<'fixed' | 'fluid'> {\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\n const isFirstMount = useRef(true)\n const slideActionType = useRef<SlideActionType>('initial' as SlideActionType)\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 fluidTotalWrapperScrollValue = useRef(0)\n const slideEndReached = useRef(false)\n const currentWindowWidth = useRef(0)\n const initialWindowWidth = useRef(0)\n const prevSlidedValue = useRef(0)\n const prevItems = useRef(items)\n\n /**\n * Instead of raw values, we store it in\n * useRef for performances reasons during external rerenders\n */\n const draggingSlideTresholdRef = useRef<number>(draggingSlideTreshold ?? 0)\n const itemsPerSlideRef = useRef(itemsPerSlide)\n const gutterRef = useRef(gutter)\n const startEndGutterRef = useRef(startEndGutter)\n const initialActiveItemRef = useRef(initialActiveItem)\n const initialStartingPositionRef = useRef(initialStartingPosition)\n const carouselSlideAxisRef = useRef(carouselSlideAxis)\n\n /**\n * Update inner values during external rerenders!\n */\n itemsPerSlideRef.current = itemsPerSlide\n gutterRef.current = gutter\n startEndGutterRef.current = startEndGutter\n initialActiveItemRef.current = initialActiveItem\n initialStartingPositionRef.current = initialStartingPosition\n carouselSlideAxisRef.current = carouselSlideAxis\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxisRef.current])\n }\n },\n }))\n\n useIsomorphicLayoutEffect(() => {\n if (draggingSlideTreshold) {\n draggingSlideTresholdRef.current = draggingSlideTreshold\n } else {\n draggingSlideTresholdRef.current = Math.floor(getSlideValue() / 2 / 2)\n }\n\n resize()\n }, [\n draggingSlideTreshold,\n itemsPerSlide,\n gutter,\n startEndGutter,\n initialActiveItem,\n initialStartingPosition,\n carouselSlideAxis,\n thumbsSlideAxis,\n ])\n\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n function getMainCarouselWrapperWidth() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ]\n }\n function getCarouselItemWidth() {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }\n function getCurrentSlidedValue() {\n return carouselStyles[carouselSlideAxisRef.current].get()\n }\n function getIfItemsNotFillTheCarousel() {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }\n function getFluidWrapperScrollValue() {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxisRef.current === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ],\n )\n }\n function getIsFirstItem() {\n return getCurrentActiveItem() === 0\n }\n function getSlideValue() {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (slideType === '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 }\n function adjustCarouselWrapperPosition(\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) {\n const positionProperty = carouselSlideAxisRef.current === 'x' ? 'left' : 'top'\n function getDefaultPositionValue() {\n return getCarouselItemWidth() * items.length\n }\n function setPosition(v: number) {\n if (withLoop) {\n ref.style.top = '0px'\n ref.style[positionProperty] = `-${v - startEndGutterRef.current}px`\n } else {\n ref.style.left = '0px'\n ref.style.top = '0px'\n if (_initialActiveItem && isFirstMount.current) {\n ref.style[positionProperty] = `calc(-${_initialActiveItem} * 100%)`\n }\n }\n }\n function setStartPosition() {\n setPosition(getDefaultPositionValue())\n }\n\n if (slideType === 'fixed') {\n function setCenterPosition(i: number) {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round(((i as number) - 1) / 2),\n )\n }\n function setEndPosition(i: number) {\n setPosition(\n getDefaultPositionValue() - getSlideValue() * Math.round((i as number) - 1),\n )\n }\n\n if (itemsPerSlideRef.current > 1) {\n switch (initialStartingPositionRef.current) {\n default:\n case 'start': {\n setStartPosition()\n break\n }\n case 'center': {\n setCenterPosition(itemsPerSlideRef.current)\n break\n }\n case 'end': {\n setEndPosition(itemsPerSlideRef.current)\n break\n }\n }\n } else {\n setStartPosition()\n }\n } else {\n setStartPosition()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function resize() {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: 0,\n })\n return\n }\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n\n if (slideEndReached.current) {\n const nextValue = -fluidTotalWrapperScrollValue.current\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n function handleResize() {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule<'use-spring'>()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } =\n useFullscreenModule<'use-spring'>({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getIfShouldEnableFluidDrag() {\n if (typeof enableFreeScrollDrag === 'boolean') {\n return enableFreeScrollDrag\n } else if (typeof enableFreeScrollDrag === 'function') {\n return enableFreeScrollDrag()\n }\n return false\n }\n\n const bindDrag = useDrag(\n props => {\n const isDragging = props.dragging\n const movement = props.offset[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function setDragDirection() {\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n }\n function emitDragObservable() {\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: 0,\n config: {\n velocity: props.velocity,\n },\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n config: {\n velocity: props.velocity,\n },\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: prevSlidedValue.current,\n config: {\n velocity: props.velocity,\n },\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -(getCurrentActiveItem() * getSlideValue()),\n config: {\n velocity: props.velocity,\n },\n })\n }\n }\n function checkBounds() {\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue()) + 100 >= fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && getSlideActionType() === 'next') {\n slideEndReached.current = true\n }\n if (getSlideActionType() === 'prev') {\n slideEndReached.current = false\n }\n }\n\n if (freeScroll && getIfShouldEnableFluidDrag()) {\n setDragDirection()\n emitDragObservable()\n checkBounds()\n\n setCarouselStyles.start({\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n config: {\n velocity: props.velocity,\n },\n })\n\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n }\n return\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitDragObservable()\n setDragDirection()\n checkBounds()\n\n if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1000,\n },\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: movement,\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1000,\n },\n })\n }\n\n if (\n (prevItemTreshold || nextItemTreshold) &&\n getIfItemsNotFillTheCarousel() &&\n slideType === 'fluid'\n ) {\n cancelDrag()\n resetAnimation()\n } else if (\n slideEndReached.current &&\n getSlideActionType() === 'next' &&\n nextItemTreshold\n ) {\n slideEndReached.current = false\n cancelDrag()\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (slideWhenThresholdIsReached) {\n if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n return\n }\n }\n }\n\n if (\n props.last &&\n !slideWhenThresholdIsReached &&\n (nextItemTreshold || prevItemTreshold) &&\n !freeScroll\n ) {\n if (nextItemTreshold) {\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n } else if (prevItemTreshold) {\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n }\n return\n }\n\n if (props.last && !nextItemTreshold && !prevItemTreshold) {\n if (!freeScroll) {\n resetAnimation()\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n axis: carouselSlideAxisRef.current,\n from: () => {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === 'x') {\n return [-getWrapperScrollDirection(), 0]\n }\n return [0, -getWrapperScrollDirection()]\n }\n return [carouselStyles.x.get(), carouselStyles.y.get()]\n },\n },\n )\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 getFromValue(from: SlideToItemFnProps['from']) {\n if (typeof from === 'number') {\n return {\n from: {\n [carouselSlideAxisRef.current]: from,\n },\n }\n }\n return {}\n }\n function getToValue(\n customTo: SlideToItemFnProps['customTo'],\n to: SlideToItemFnProps['to'],\n ) {\n if (typeof customTo === 'number') {\n return {\n [carouselSlideAxisRef.current]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxisRef.current]: -(getSlideValue() * to!),\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function slideToItem({\n from,\n to = -1,\n customTo,\n immediate = false,\n onRest = () => {},\n velocity,\n }: SlideToItemFnProps) {\n if (!immediate) {\n setActiveItem(to)\n setIsAnimating(true)\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: slideType === 'fluid' ? -1 : to,\n id: slideType === 'fluid' ? '' : items[to].id,\n },\n })\n }\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\n ...(velocity\n ? {\n config: {\n ...defaultDragSpringConfig,\n velocity,\n friction: undefined,\n tension: undefined,\n },\n }\n : {\n config: {\n velocity: 0,\n ...springConfig,\n },\n }),\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: slideType === 'fluid' ? -1 : getCurrentActiveItem(),\n id: slideType === '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(velocity?: number[]) {\n setSlideActionType('prev')\n slideEndReached.current = false\n\n if (slideType === 'fluid') {\n slideEndReached.current = false\n\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 velocity,\n })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n velocity,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n velocity,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n velocity,\n })\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 velocity,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n velocity,\n })\n }\n }\n }\n function slideToNextItem(velocity?: number[]) {\n setSlideActionType('next')\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue()) + 100 >=\n fluidTotalWrapperScrollValue.current\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n const willExceed = nextValue > fluidTotalWrapperScrollValue.current\n const val = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n\n slideToItem({\n velocity,\n customTo: willExceed ? fluidTotalWrapperScrollValue.current : val,\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 velocity,\n })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n velocity,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n velocity,\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue() + 25) >\n fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && !getIsDragging()) {\n slideEndReached.current = true\n } else if (slideEndReached.current) {\n slideToItem({\n to: items.length - itemsPerSlideRef.current,\n velocity,\n })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n velocity,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n velocity,\n })\n }\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 (\n itemIndex === getCurrentActiveItem() ||\n (items.length !== prevItems.current.length && getCurrentActiveItem() < items.length)\n ) {\n return\n }\n\n const currentItem = findItemIndex(prevItems.current[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 function getItemStyles(_itemsPerSlide: number) {\n if (slideType === 'fixed') {\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n flex: `1 0 calc(100% / ${_itemsPerSlide} - ${\n (gutterRef.current * (_itemsPerSlide - 1)) / _itemsPerSlide\n }px)`,\n }\n }\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n }\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutterRef.current * 2}px)`\n return {\n width: carouselSlideAxisRef.current === 'x' ? percentValue : '100%',\n height: carouselSlideAxisRef.current === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === '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[carouselSlideAxisRef.current].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxisRef.current === 'x') {\n return 'pan-y'\n }\n return 'pan-x'\n }\n return touchAction\n }\n // Perform some check on first mount\n useIsomorphicMount(() => {\n if (itemsPerSlide % 2 === 0 && initialStartingPositionRef.current) {\n throw new Error(\n `initialStartingPosition can be only used if itemsPerSlide is an even value.`,\n )\n }\n if (draggingSlideTresholdRef.current < 0) {\n throw new Error('draggingSlideTreshold must be greater than 0')\n }\n if (draggingSlideTresholdRef.current > getSlideValue() / 2) {\n throw new Error(\n `draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(\n getSlideValue() / 2,\n )}`,\n )\n }\n if (itemsPerSlideRef.current < 1) {\n throw new Error(`The itemsPerSlide prop can't be less than 1.`)\n }\n if (itemsPerSlideRef.current > 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 (initialActiveItemRef.current < 0) {\n throw new Error('The initialActiveItem cannot be less than 0.')\n }\n if (initialActiveItemRef.current > items.length) {\n throw new Error(\n 'The initialActiveItem cannot be greater than the total length of the items you provide.',\n )\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 })\n useIsomorphicMount(() => {\n function handleVisibilityChange() {\n if (document.hidden) {\n windowIsHidden.current = true\n } else {\n windowIsHidden.current = false\n }\n }\n document.addEventListener('visibilitychange', handleVisibilityChange)\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange)\n }\n })\n useIsomorphicMount(() => {\n isFirstMount.current = false\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n initialWindowWidth.current = window.innerWidth\n currentWindowWidth.current = window.innerWidth\n\n if (initialActiveItem > 0) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n if (!withLoop && carouselTrackWrapperRef.current) {\n carouselTrackWrapperRef.current.style.top = '0px'\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n })\n useIsomorphicLayoutEffect(() => {\n if (initialActiveItem < items.length && initialActiveItem !== activeItem.current) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n }\n }, [initialActiveItem])\n useIsomorphicLayoutEffect(() => {\n if (shouldResizeOnWindowResize) {\n window.addEventListener('resize', handleResize)\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [shouldResizeOnWindowResize])\n useIsomorphicLayoutEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxisRef.current === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxisRef.current === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useIsomorphicLayoutEffect(() => {\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n const itemsAreEqual = items.length === prevItems.current.length\n\n if (!itemsAreEqual && items.length < prevItems.current.length) {\n _slideToItem(items.length - 1)\n }\n\n prevItems.current = items\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getFluidWrapperScrollValue, items])\n\n const contextProps = {\n useListenToCustomEvent,\n getIsFullscreen,\n enterFullscreen,\n exitFullscreen,\n getIsAnimating,\n getIsDragging,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem() {\n slideToPrevItem()\n },\n slideToNextItem() {\n slideToNextItem()\n },\n ...(slideType === 'fixed'\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\n const handleCarouselFragmentRef = (ref: HTMLDivElement | null) => {\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n function getInitialStyles() {\n const totalValue = (items.length / itemsPerSlide) * 100\n const singleItemValue = 100 / itemsPerSlide\n const cssProp = carouselSlideAxisRef.current === 'x' ? 'left' : 'y'\n const quantityToMove = Math.floor(50 / singleItemValue)\n\n if (slideType === 'fixed') {\n if (initialStartingPositionRef.current === 'center') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * quantityToMove}%)`,\n }\n }\n if (initialStartingPositionRef.current === 'end') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * (quantityToMove * 2)}%)`,\n }\n }\n }\n return {\n [cssProp]: `0px`,\n }\n }\n\n const carouselFragment = (\n <Context.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: carouselSlideAxisRef.current === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...getInitialStyles(),\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(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </Context.Provider>\n )\n const thumbsFragment = (\n <Context.Provider value={contextProps}>{_thumbsFragment}</Context.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext<T = 'fixed' | 'fluid'>() {\n const context = useContext(Context)\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 ContextTypes<T>\n}\n\nexport { useSpringCarousel, useSpringCarouselContext }\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 { SlideActionType } from '../types'\nimport {\n UseTransitionCarouselContextProps,\n UseTransitionCarouselProps,\n} from '../types/useTransitionCarousel'\nimport { ReactSpringCarouselItemWithThumbs } from '../types/useSpringCarousel'\n\nconst UseTransitionCarouselContext = createContext<\n UseTransitionCarouselContextProps | undefined\n>(undefined)\n\nfunction 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\nfunction 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 trail,\n exitBeforeEnter = false,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'absolute',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'absolute',\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 } =\n useCustomEventsModule<'use-transition'>()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items: items as ReactSpringCarouselItemWithThumbs[],\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType: 'fixed',\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 trail,\n exitBeforeEnter,\n key: items[activeItem].id,\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: items.length - 1,\n id: items[items.length - 1].id,\n },\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\nexport { useTransitionCarouselContext, useTransitionCarousel }\n"],"names":["useCustomEventsModule","eventsObserverRef","useRef","Subject","useListenToCustomEvent","fn","useEffect","subscribe","current","unsubscribe","emitObservable","data","next","useIsomorphicLayoutEffect","window","useLayoutEffect","useIsomorphicMount","callback","isMounted","clean","useFullscreenModule","mainCarouselWrapperRef","handleResize","isFullscreen","setIsFullscreen","_isFullscreen","handleFullscreenChange","document","fullscreenElement","eventName","screenfull","isEnabled","on","off","enterFullscreen","elementRef","request","exitFullscreen","exit","getIsFullscreen","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","getFluidWrapperScrollValue","getSlideValue","slideType","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","thumbsFragment","_jsx","animated","div","ref","className","onWheel","stop","style","display","flex","position","width","height","flexDirection","overflowX","overflowY","maxHeight","getPreparedItems","_items","map","i","id","renderThumb","handlePrepareThumbsData","thumbId","handleThumbsScroll","activeItem","actionType","totalScrollableValue","nextValue","start","from","[object Object]","to","thumbNode","querySelector","thumbWrapper","offsetDimension","scrollDirection","thumbOffsetPosition","offsetDirection","getThumbOffsetPosition","thumbScrollDimension","getThumbScrollDimension","fromValue","getScrollFromValue","toValue","scrollDimensionProperty","length","getScrollToValue","scrollLeft","scrollTop","Context","createContext","undefined","defaultDragSpringConfig","default","mass","velocity","UseTransitionCarouselContext","withLoop","draggingSlideTreshold","shouldResizeOnWindowResize","enableThumbsWrapperScroll","slideWhenThresholdIsReached","carouselSlideAxis","initialActiveItem","initialStartingPosition","disableGestures","gutter","startEndGutter","touchAction","slideAmount","freeScroll","enableFreeScrollDrag","itemsPerSlide","isFirstMount","slideActionType","internalItems","carouselTrackWrapperRef","isDragging","isAnimating","windowIsHidden","fluidTotalWrapperScrollValue","slideEndReached","currentWindowWidth","initialWindowWidth","prevSlidedValue","prevItems","draggingSlideTresholdRef","itemsPerSlideRef","gutterRef","startEndGutterRef","initialActiveItemRef","initialStartingPositionRef","carouselSlideAxisRef","carouselStyles","setCarouselStyles","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getMainCarouselWrapperWidth","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","setEndPosition","resize","innerWidth","immediate","floor","_thumbsFragment","getWrapperScrollDirection","getIfShouldEnableFluidDrag","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","setDragDirection","setSlideActionType","emitDragObservable","getSlideActionType","resetAnimation","checkBounds","getIsDragging","setIsDragging","friction","tension","getIsLastItem","slideToNextItem","slideToPrevItem","last","enabled","axis","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","getToValue","customTo","slideToItem","onRest","nextItem","index","getFromValue","finished","currentItem","nextPrevValue","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","Provider","percentValue","getAnimatedWrapperStyles","totalValue","singleItemValue","cssProp","quantityToMove","getInitialStyles","renderItem","_itemsPerSlide","marginRight","marginBottom","context","useContext","toPrevItemSpringProps","toNextItemSpringProps","trail","exitBeforeEnter","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","key","transitions","styles","newActiveItem","overflow"],"mappings":"sTASgBA,IACd,MAAMC,EAAoBC,SACxB,IAAIC,WAkBN,MAAO,CACLC,uBAZF,SAAgCC,GAC9BC,aAAU,KACR,MAAMC,EAAYN,EAAkBO,QAAQD,UAAUF,GACtD,MAAO,IAAME,EAAUE,gBACtB,CAACJ,KASJK,eAN0CC,IAC1CV,EAAkBO,QAAQI,KAAKD,KCtBnC,MAAME,EACc,oBAAXC,OAAyBC,kBAAkBT,YAEpD,SAASU,EAAmBC,GAC1B,MAAMC,EAAYhB,UAAO,GAEzBW,GAA0B,KACxB,IAAKK,EAAUV,QAAS,CACtB,MAAMW,EAAQF,IAGd,OAFAC,EAAUV,SAAU,EAEb,KACLW,GAASA,QAIZ,aCTWC,GAAuBC,uBACrCA,EAAsBX,eACtBA,EAAcY,aACdA,IAEA,MAAMC,EAAerB,UAAO,GAkC5B,SAASsB,EAAgBC,GACvBF,EAAaf,QAAUiB,EAiBzB,OAlDAT,GAAmB,KACjB,SAASU,IACHC,SAASC,oBACXJ,GAAgB,GAChBd,EAAe,CACbmB,UAAW,qBACXN,cAAc,IAGhBD,GAAgBA,KAGbK,SAASC,oBACZJ,GAAgB,GAChBd,EAAe,CACbmB,UAAW,qBACXN,cAAc,IAEhBD,GAAgBA,KAIpB,GAAIQ,UAAWC,UAEb,OADAD,UAAWE,GAAG,SAAU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,IAAKgJ,EACH,MAAM,IAAI7M,MAAM,+KAIlB,OAAO6M"}
1
+ {"version":3,"file":"index.js","sources":["../../src/modules/useCustomEventsModule.tsx","../../src/utils.ts","../../src/modules/useFullscreenModule.tsx","../../src/modules/useThumbsModule.tsx","../../src/useSpringCarousel/index.tsx","../../src/useTransitionCarousel/index.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { Subject } from 'rxjs'\nimport {\n UseSpringCarouselEventsObservableProps,\n UseTransitionCarouselEventsObservableProps,\n ObservableCallbackFn,\n EmitObservableFn,\n} from '../types'\n\nexport function useCustomEventsModule<T>() {\n const eventsObserverRef = useRef(\n new Subject<\n T extends 'use-spring'\n ? UseSpringCarouselEventsObservableProps\n : UseTransitionCarouselEventsObservableProps\n >(),\n )\n\n function useListenToCustomEvent(fn: ObservableCallbackFn<T>) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn<T> = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, useLayoutEffect, useEffect } from 'react'\n\ntype Callback = () => void | (() => void)\n\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nfunction useIsomorphicMount(callback: Callback) {\n const isMounted = useRef(false)\n\n useIsomorphicLayoutEffect(() => {\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 { useIsomorphicLayoutEffect, useIsomorphicMount }\n","import { useRef, MutableRefObject } from 'react'\nimport screenfull from 'screenfull'\nimport { EmitObservableFn } from '../types'\nimport { useIsomorphicMount } from '../utils'\n\ntype FullscreenModule<T> = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn<T>\n handleResize?(): void\n}\n\nexport function useFullscreenModule<T>({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule<T>) {\n const isFullscreen = useRef(false)\n\n useIsomorphicMount(() => {\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 } from 'react'\nimport { useSpring, SpringConfig, animated } from 'react-spring'\nimport { useIsomorphicMount } from 'src/utils'\nimport { UseSpringCarouselProps, SlideActionType } from '../types'\nimport { ReactSpringCarouselItemWithThumbs } from '../types/useSpringCarousel'\nimport { PrepareThumbsData } from '../types/index'\n\ntype OffsetDimension = 'offsetWidth' | 'offsetHeight'\ntype OffsetDirection = 'offsetLeft' | 'offsetTop'\ntype ScrollDirection = 'scrollLeft' | 'scrollTop'\n\ntype Props = {\n items: ReactSpringCarouselItemWithThumbs[]\n withThumbs: boolean\n slideType: UseSpringCarouselProps['slideType']\n thumbsSlideAxis: UseSpringCarouselProps['thumbsSlideAxis']\n springConfig: SpringConfig\n prepareThumbsData?: UseSpringCarouselProps['prepareThumbsData']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n slideType,\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 && slideType === 'fluid') {\n internalThumbsWrapperRef.current[\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[thumbsSlideAxis])\n }\n },\n }))\n\n useIsomorphicMount(() => {\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 (slideType === '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 const fromValue = getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n })\n const toValue = getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n })\n\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: fromValue,\n },\n to: {\n [thumbsSlideAxis]: actionType === 'prev' && toValue < 0 ? 0 : toValue,\n },\n onChange: ({ value }) => {\n if (thumbsSlideAxis === 'x') {\n internalThumbsWrapperRef!.current!.scrollLeft = value.x\n } else {\n internalThumbsWrapperRef!.current!.scrollTop = value.y\n }\n },\n })\n }\n }\n }\n function handlePrepareThumbsData() {\n function getPreparedItems(\n _items: ReturnType<PrepareThumbsData>,\n ): ReturnType<PrepareThumbsData> {\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 thumbsFragment = withThumbs ? (\n <animated.div\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 width: '100%',\n height: '100%',\n flexDirection: thumbsSlideAxis === 'x' ? 'row' : 'column',\n ...(thumbsSlideAxis === 'x'\n ? { overflowX: 'auto' }\n : {\n overflowY: 'auto',\n maxHeight: '100%',\n }),\n }}\n >\n {handlePrepareThumbsData().map(({ id, renderThumb }) => {\n const thumbId = `thumb-${id}`\n return (\n <div key={thumbId} id={thumbId} className=\"thumb-item\">\n {renderThumb}\n </div>\n )\n })}\n </animated.div>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useContext } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from '../modules'\nimport {\n SlideToItemFnProps,\n SlideActionType,\n UseSpringFixedSlideTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n UseSpringFluidSlideTypeReturnProps,\n UseSpringCarouselBaseProps,\n UseSpringCarouselWithThumbs,\n UseSpringCarouselFluidType,\n DisableGesturesProps,\n WithLoopProps,\n UseSpringCarouselWithNoThumbs,\n EnableGesturesProps,\n WithNoLoop,\n UseSpringCarouselFixedSlideType,\n} from '../types/useSpringCarousel'\n\ntype ReturnType<T> = T extends 'fixed'\n ? UseSpringFixedSlideTypeReturnProps\n : UseSpringFluidSlideTypeReturnProps\ntype ContextTypes<T> = Omit<ReturnType<T>, 'carouselFragment' | 'thumbsFragment'>\n\nconst Context = createContext<ContextTypes<'fixed' | 'fluid'> | undefined>(undefined)\n\nconst defaultDragSpringConfig = {\n ...config.default,\n mass: 1,\n velocity: 0,\n}\n\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFluidType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fluid'>\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFixedSlideType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fixed'>\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n slideWhenThresholdIsReached = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition,\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps): ReturnType<'fixed' | 'fluid'> {\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\n const isFirstMount = useRef(true)\n const slideActionType = useRef<SlideActionType>('initial' as SlideActionType)\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 fluidTotalWrapperScrollValue = useRef(0)\n const slideEndReached = useRef(false)\n const currentWindowWidth = useRef(0)\n const initialWindowWidth = useRef(0)\n const prevSlidedValue = useRef(0)\n const prevItems = useRef(items)\n\n /**\n * Instead of raw values, we store it in\n * useRef for performances reasons during external rerenders\n */\n const draggingSlideTresholdRef = useRef<number>(draggingSlideTreshold ?? 0)\n const itemsPerSlideRef = useRef(itemsPerSlide)\n const gutterRef = useRef(gutter)\n const startEndGutterRef = useRef(startEndGutter)\n const initialActiveItemRef = useRef(initialActiveItem)\n const initialStartingPositionRef = useRef(initialStartingPosition)\n const carouselSlideAxisRef = useRef(carouselSlideAxis)\n\n /**\n * Update inner values during external rerenders!\n */\n itemsPerSlideRef.current = itemsPerSlide\n gutterRef.current = gutter\n startEndGutterRef.current = startEndGutter\n initialActiveItemRef.current = initialActiveItem\n initialStartingPositionRef.current = initialStartingPosition\n carouselSlideAxisRef.current = carouselSlideAxis\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxisRef.current])\n }\n },\n }))\n\n useIsomorphicLayoutEffect(() => {\n if (draggingSlideTreshold) {\n draggingSlideTresholdRef.current = draggingSlideTreshold\n } else {\n draggingSlideTresholdRef.current = Math.floor(getSlideValue() / 2 / 2)\n }\n\n resize()\n }, [\n draggingSlideTreshold,\n itemsPerSlide,\n gutter,\n startEndGutter,\n initialActiveItem,\n initialStartingPosition,\n carouselSlideAxis,\n thumbsSlideAxis,\n ])\n\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n function getMainCarouselWrapperWidth() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ]\n }\n function getCarouselItemWidth() {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }\n function getCurrentSlidedValue() {\n return carouselStyles[carouselSlideAxisRef.current].get()\n }\n function getIfItemsNotFillTheCarousel() {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }\n function getFluidWrapperScrollValue() {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxisRef.current === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ],\n )\n }\n function getIsFirstItem() {\n return getCurrentActiveItem() === 0\n }\n function getSlideValue() {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (slideType === '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 }\n function adjustCarouselWrapperPosition(\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) {\n const positionProperty = carouselSlideAxisRef.current === 'x' ? 'left' : 'top'\n function getDefaultPositionValue() {\n return getCarouselItemWidth() * items.length\n }\n function setPosition(v: number) {\n if (withLoop) {\n ref.style.top = '0px'\n ref.style[positionProperty] = `-${v - startEndGutterRef.current}px`\n } else {\n ref.style.left = '0px'\n ref.style.top = '0px'\n if (_initialActiveItem && isFirstMount.current) {\n ref.style[positionProperty] = `calc(-${_initialActiveItem} * 100%)`\n }\n }\n }\n function setStartPosition() {\n setPosition(getDefaultPositionValue())\n }\n\n if (slideType === 'fixed') {\n function setCenterPosition(i: number) {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round(((i as number) - 1) / 2),\n )\n }\n function setEndPosition(i: number) {\n setPosition(\n getDefaultPositionValue() - getSlideValue() * Math.round((i as number) - 1),\n )\n }\n\n if (itemsPerSlideRef.current > 1) {\n switch (initialStartingPositionRef.current) {\n default:\n case 'start': {\n setStartPosition()\n break\n }\n case 'center': {\n setCenterPosition(itemsPerSlideRef.current)\n break\n }\n case 'end': {\n setEndPosition(itemsPerSlideRef.current)\n break\n }\n }\n } else {\n setStartPosition()\n }\n } else {\n setStartPosition()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function resize() {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: 0,\n })\n return\n }\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n\n if (slideEndReached.current) {\n const nextValue = -fluidTotalWrapperScrollValue.current\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n function handleResize() {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule<'use-spring'>()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } =\n useFullscreenModule<'use-spring'>({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getIfShouldEnableFluidDrag() {\n if (typeof enableFreeScrollDrag === 'boolean') {\n return enableFreeScrollDrag\n } else if (typeof enableFreeScrollDrag === 'function') {\n return enableFreeScrollDrag()\n }\n return false\n }\n\n const bindDrag = useDrag(\n props => {\n const isDragging = props.dragging\n const movement = props.offset[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function setDragDirection() {\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n }\n function emitDragObservable() {\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: 0,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: prevSlidedValue.current,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -(getCurrentActiveItem() * getSlideValue()),\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n }\n }\n function checkBounds() {\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue()) + 100 >= fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && getSlideActionType() === 'next') {\n slideEndReached.current = true\n }\n if (getSlideActionType() === 'prev') {\n slideEndReached.current = false\n }\n }\n\n if (freeScroll && getIfShouldEnableFluidDrag()) {\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n setDragDirection()\n emitDragObservable()\n checkBounds()\n }\n\n setCarouselStyles.start({\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1400,\n },\n })\n\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n }\n if (props.last) {\n if (getSlideActionType() === 'prev') {\n slideToPrevItem(props.velocity)\n } else {\n slideToNextItem(props.velocity)\n }\n setIsDragging(false)\n }\n return\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitDragObservable()\n setDragDirection()\n checkBounds()\n\n if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1400,\n },\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: movement,\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1000,\n },\n })\n }\n\n if (\n (prevItemTreshold || nextItemTreshold) &&\n getIfItemsNotFillTheCarousel() &&\n slideType === 'fluid'\n ) {\n cancelDrag()\n resetAnimation()\n } else if (\n slideEndReached.current &&\n getSlideActionType() === 'next' &&\n nextItemTreshold\n ) {\n slideEndReached.current = false\n cancelDrag()\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (slideWhenThresholdIsReached) {\n if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n return\n }\n }\n }\n\n if (\n props.last &&\n !slideWhenThresholdIsReached &&\n (nextItemTreshold || prevItemTreshold) &&\n !freeScroll\n ) {\n setIsDragging(false)\n if (nextItemTreshold) {\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n } else if (prevItemTreshold) {\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n }\n return\n }\n\n if (props.last && !nextItemTreshold && !prevItemTreshold) {\n if (!freeScroll) {\n resetAnimation()\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n axis: carouselSlideAxisRef.current,\n from: () => {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === 'x') {\n return [-getWrapperScrollDirection(), 0]\n }\n return [0, -getWrapperScrollDirection()]\n }\n return [carouselStyles.x.get(), carouselStyles.y.get()]\n },\n },\n )\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 getFromValue(from: SlideToItemFnProps['from']) {\n if (typeof from === 'number') {\n return {\n from: {\n [carouselSlideAxisRef.current]: from,\n },\n }\n }\n return {}\n }\n function getToValue(\n customTo: SlideToItemFnProps['customTo'],\n to: SlideToItemFnProps['to'],\n ) {\n if (typeof customTo === 'number') {\n return {\n [carouselSlideAxisRef.current]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxisRef.current]: -(getSlideValue() * to!),\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function slideToItem({\n from,\n to = -1,\n customTo,\n immediate = false,\n onRest = () => {},\n velocity,\n }: SlideToItemFnProps) {\n if (!immediate) {\n setActiveItem(to)\n setIsAnimating(true)\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: slideType === 'fluid' ? -1 : to,\n id: slideType === 'fluid' ? '' : items[to].id,\n },\n })\n }\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\n ...(velocity\n ? {\n config: {\n ...defaultDragSpringConfig,\n velocity,\n friction: undefined,\n tension: undefined,\n },\n }\n : {\n config: {\n velocity: 0,\n ...springConfig,\n },\n }),\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: slideType === 'fluid' ? -1 : getCurrentActiveItem(),\n id: slideType === '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(velocity?: number[]) {\n setSlideActionType('prev')\n slideEndReached.current = false\n\n if (slideType === 'fluid') {\n slideEndReached.current = false\n\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 velocity,\n })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n velocity,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n velocity,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n velocity,\n })\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 velocity,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n velocity,\n })\n }\n }\n }\n function slideToNextItem(velocity?: number[]) {\n setSlideActionType('next')\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue()) + 100 >=\n fluidTotalWrapperScrollValue.current\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n const willExceed = nextValue > fluidTotalWrapperScrollValue.current\n const val = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n\n slideToItem({\n velocity,\n customTo: willExceed ? fluidTotalWrapperScrollValue.current : val,\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 velocity,\n })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n velocity,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n velocity,\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue() + 25) >\n fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && !getIsDragging()) {\n slideEndReached.current = true\n } else if (slideEndReached.current) {\n slideToItem({\n to: items.length - itemsPerSlideRef.current,\n velocity,\n })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n velocity,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n velocity,\n })\n }\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 (\n itemIndex === getCurrentActiveItem() ||\n (items.length !== prevItems.current.length && getCurrentActiveItem() < items.length)\n ) {\n return\n }\n\n const currentItem = findItemIndex(prevItems.current[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 function getItemStyles(_itemsPerSlide: number) {\n if (slideType === 'fixed') {\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n flex: `1 0 calc(100% / ${_itemsPerSlide} - ${\n (gutterRef.current * (_itemsPerSlide - 1)) / _itemsPerSlide\n }px)`,\n }\n }\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n }\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutterRef.current * 2}px)`\n return {\n width: carouselSlideAxisRef.current === 'x' ? percentValue : '100%',\n height: carouselSlideAxisRef.current === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === '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[carouselSlideAxisRef.current].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxisRef.current === 'x') {\n return 'pan-y'\n }\n return 'pan-x'\n }\n return touchAction\n }\n // Perform some check on first mount\n useIsomorphicMount(() => {\n if (itemsPerSlide % 2 === 0 && initialStartingPositionRef.current) {\n throw new Error(\n `initialStartingPosition can be only used if itemsPerSlide is an even value.`,\n )\n }\n if (draggingSlideTresholdRef.current < 0) {\n throw new Error('draggingSlideTreshold must be greater than 0')\n }\n if (draggingSlideTresholdRef.current > getSlideValue() / 2) {\n throw new Error(\n `draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(\n getSlideValue() / 2,\n )}`,\n )\n }\n if (itemsPerSlideRef.current < 1) {\n throw new Error(`The itemsPerSlide prop can't be less than 1.`)\n }\n if (itemsPerSlideRef.current > 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 (initialActiveItemRef.current < 0) {\n throw new Error('The initialActiveItem cannot be less than 0.')\n }\n if (initialActiveItemRef.current > items.length) {\n throw new Error(\n 'The initialActiveItem cannot be greater than the total length of the items you provide.',\n )\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 })\n useIsomorphicMount(() => {\n function handleVisibilityChange() {\n if (document.hidden) {\n windowIsHidden.current = true\n } else {\n windowIsHidden.current = false\n }\n }\n document.addEventListener('visibilitychange', handleVisibilityChange)\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange)\n }\n })\n useIsomorphicMount(() => {\n isFirstMount.current = false\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n initialWindowWidth.current = window.innerWidth\n currentWindowWidth.current = window.innerWidth\n\n if (initialActiveItem > 0) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n if (!withLoop && carouselTrackWrapperRef.current) {\n carouselTrackWrapperRef.current.style.top = '0px'\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n })\n useIsomorphicLayoutEffect(() => {\n if (initialActiveItem < items.length && initialActiveItem !== activeItem.current) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n }\n }, [initialActiveItem])\n useIsomorphicLayoutEffect(() => {\n if (shouldResizeOnWindowResize) {\n window.addEventListener('resize', handleResize)\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [shouldResizeOnWindowResize])\n useIsomorphicLayoutEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxisRef.current === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxisRef.current === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useIsomorphicLayoutEffect(() => {\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n const itemsAreEqual = items.length === prevItems.current.length\n\n if (!itemsAreEqual && items.length < prevItems.current.length) {\n _slideToItem(items.length - 1)\n }\n\n prevItems.current = items\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getFluidWrapperScrollValue, items])\n\n const contextProps = {\n useListenToCustomEvent,\n getIsFullscreen,\n enterFullscreen,\n exitFullscreen,\n getIsAnimating,\n getIsDragging,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem() {\n slideToPrevItem()\n },\n slideToNextItem() {\n slideToNextItem()\n },\n ...(slideType === 'fixed'\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\n const handleCarouselFragmentRef = (ref: HTMLDivElement | null) => {\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n function getInitialStyles() {\n const totalValue = (items.length / itemsPerSlide) * 100\n const singleItemValue = 100 / itemsPerSlide\n const cssProp = carouselSlideAxisRef.current === 'x' ? 'left' : 'y'\n const quantityToMove = Math.floor(50 / singleItemValue)\n\n if (slideType === 'fixed') {\n if (initialStartingPositionRef.current === 'center') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * quantityToMove}%)`,\n }\n }\n if (initialStartingPositionRef.current === 'end') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * (quantityToMove * 2)}%)`,\n }\n }\n }\n return {\n [cssProp]: `0px`,\n }\n }\n\n const carouselFragment = (\n <Context.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: carouselSlideAxisRef.current === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...getInitialStyles(),\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(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </Context.Provider>\n )\n const thumbsFragment = (\n <Context.Provider value={contextProps}>{_thumbsFragment}</Context.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext<T = 'fixed' | 'fluid'>() {\n const context = useContext(Context)\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 ContextTypes<T>\n}\n\nexport { useSpringCarousel, useSpringCarouselContext }\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 { SlideActionType } from '../types'\nimport {\n UseTransitionCarouselContextProps,\n UseTransitionCarouselProps,\n} from '../types/useTransitionCarousel'\nimport { ReactSpringCarouselItemWithThumbs } from '../types/useSpringCarousel'\n\nconst UseTransitionCarouselContext = createContext<\n UseTransitionCarouselContextProps | undefined\n>(undefined)\n\nfunction 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\nfunction 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 trail,\n exitBeforeEnter = false,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'absolute',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'absolute',\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 } =\n useCustomEventsModule<'use-transition'>()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items: items as ReactSpringCarouselItemWithThumbs[],\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType: 'fixed',\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 trail,\n exitBeforeEnter,\n key: items[activeItem].id,\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: items.length - 1,\n id: items[items.length - 1].id,\n },\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\nexport { useTransitionCarouselContext, useTransitionCarousel }\n"],"names":["useCustomEventsModule","eventsObserverRef","useRef","Subject","useListenToCustomEvent","fn","useEffect","subscribe","current","unsubscribe","emitObservable","data","next","useIsomorphicLayoutEffect","window","useLayoutEffect","useIsomorphicMount","callback","isMounted","clean","useFullscreenModule","mainCarouselWrapperRef","handleResize","isFullscreen","setIsFullscreen","_isFullscreen","handleFullscreenChange","document","fullscreenElement","eventName","screenfull","isEnabled","on","off","enterFullscreen","elementRef","request","exitFullscreen","exit","getIsFullscreen","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","getFluidWrapperScrollValue","getSlideValue","slideType","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","thumbsFragment","_jsx","animated","div","ref","className","onWheel","stop","style","display","flex","position","width","height","flexDirection","overflowX","overflowY","maxHeight","getPreparedItems","_items","map","i","id","renderThumb","handlePrepareThumbsData","thumbId","handleThumbsScroll","activeItem","actionType","totalScrollableValue","nextValue","start","from","[object Object]","to","thumbNode","querySelector","thumbWrapper","offsetDimension","scrollDirection","thumbOffsetPosition","offsetDirection","getThumbOffsetPosition","thumbScrollDimension","getThumbScrollDimension","fromValue","getScrollFromValue","toValue","scrollDimensionProperty","length","getScrollToValue","scrollLeft","scrollTop","Context","createContext","undefined","defaultDragSpringConfig","default","mass","velocity","UseTransitionCarouselContext","withLoop","draggingSlideTreshold","shouldResizeOnWindowResize","enableThumbsWrapperScroll","slideWhenThresholdIsReached","carouselSlideAxis","initialActiveItem","initialStartingPosition","disableGestures","gutter","startEndGutter","touchAction","slideAmount","freeScroll","enableFreeScrollDrag","itemsPerSlide","isFirstMount","slideActionType","internalItems","carouselTrackWrapperRef","isDragging","isAnimating","windowIsHidden","fluidTotalWrapperScrollValue","slideEndReached","currentWindowWidth","initialWindowWidth","prevSlidedValue","prevItems","draggingSlideTresholdRef","itemsPerSlideRef","gutterRef","startEndGutterRef","initialActiveItemRef","initialStartingPositionRef","carouselSlideAxisRef","carouselStyles","setCarouselStyles","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getMainCarouselWrapperWidth","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","setEndPosition","resize","innerWidth","immediate","floor","_thumbsFragment","getWrapperScrollDirection","getIfShouldEnableFluidDrag","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","setDragDirection","setSlideActionType","emitDragObservable","getSlideActionType","resetAnimation","checkBounds","getIsDragging","setIsDragging","friction","tension","last","slideToPrevItem","slideToNextItem","getIsLastItem","enabled","axis","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","getToValue","customTo","slideToItem","onRest","nextItem","index","getFromValue","finished","currentItem","nextPrevValue","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","Provider","percentValue","getAnimatedWrapperStyles","totalValue","singleItemValue","cssProp","quantityToMove","getInitialStyles","renderItem","_itemsPerSlide","marginRight","marginBottom","context","useContext","toPrevItemSpringProps","toNextItemSpringProps","trail","exitBeforeEnter","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","key","transitions","styles","newActiveItem","overflow"],"mappings":"sTASgBA,IACd,MAAMC,EAAoBC,SACxB,IAAIC,WAkBN,MAAO,CACLC,uBAZF,SAAgCC,GAC9BC,aAAU,KACR,MAAMC,EAAYN,EAAkBO,QAAQD,UAAUF,GACtD,MAAO,IAAME,EAAUE,gBACtB,CAACJ,KASJK,eAN0CC,IAC1CV,EAAkBO,QAAQI,KAAKD,KCtBnC,MAAME,EACc,oBAAXC,OAAyBC,kBAAkBT,YAEpD,SAASU,EAAmBC,GAC1B,MAAMC,EAAYhB,UAAO,GAEzBW,GAA0B,KACxB,IAAKK,EAAUV,QAAS,CACtB,MAAMW,EAAQF,IAGd,OAFAC,EAAUV,SAAU,EAEb,K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