react-spring-carousel 1.9.29-beta93 → 1.9.29-beta94
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 +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
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 u=o(require("screenfull"));function s(){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(u.default.isEnabled)return u.default.on("change",e),()=>{u.default.isEnabled&&u.default.off("change",e)}})),{enterFullscreen:function(t){u.default.isEnabled&&u.default.request(t||e.current)},exitFullscreen:function(){u.default.isEnabled&&u.default.exit()},getIsFullscreen:function(){return i.current}}}const f=t.forwardRef((({children:t,...r},i)=>e.jsx(n.animated.div,Object.assign({},r,{ref:i},{children:t}),void 0)));function d({items:r,withThumbs:i,thumbsSlideAxis:o="x",springConfig:u,prepareThumbsData:s,getFluidWrapperScrollValue:c=(()=>0),getSlideValue:a=(()=>0),CustomThumbsWrapperComponent:d,slideType:h}){const m=t.useRef(null),[p,g]=n.useSpring((()=>({x:0,y:0,config:u,onChange:({value:e})=>{m.current&&"fluid"===h&&(m.current["x"===o?"scrollLeft":"scrollTop"]=Math.abs(e[o]))}})));function x(){return m.current["x"===o?"scrollLeft":"scrollTop"]}function b(){return Math.round(Number(m.current?.["x"===o?"scrollWidth":"scrollHeight"])-m.current.getBoundingClientRect()["x"===o?"width":"height"])}function v(){const e=Math.round(c()/a());return b()/e}l((()=>{if(i&&!m.current)throw new Error("The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.")}));const w=d?n.animated(d):f;return{thumbsFragment:i?e.jsx(w,Object.assign({ref:m,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{p[o].stop()},style:{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 s?s(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)}))}),void 0):null,handleThumbsScroll:function(e,t){if("fluid"===h){const e=b();if("next"===t){const t=x()+v();g.start({from:{[o]:x()},to:{[o]:t>e?e:t}})}if("prev"===t){const e=x()-v();g.start({from:{[o]:x()},to:{[o]:e<0?0:e}})}}else{const n=m.current.querySelector(`#thumb-${r[e].id}`);if(n){const i=m.current,u="x"===o?"offsetWidth":"offsetHeight",s="x"===o?"scrollLeft":"scrollTop",c=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:n,offsetDimension:u,offsetDirection:"x"===o?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:i,offsetDimension:u}),a=function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:i,scrollDirection:s}),f=function({thumbWrapper:t,thumbOffsetPosition:n,thumbScrollDimension:i,offsetDimension:u}){const s="x"===o?"scrollWidth":"scrollHeight";return e===r.length-1||n-i>t[s]-t[u]?t[s]-t[u]:0===e?0:n-i}({thumbWrapper:i,thumbOffsetPosition:c,thumbScrollDimension:l,offsetDimension:u});g.start({from:{[o]:a},to:{[o]:"prev"===t&&f<0?0:f},onChange:({value:e})=>{"x"===o?m.current.scrollLeft=e.x:m.current.scrollTop=e.y}})}}}}}const h=t.createContext(void 0);const m=t.createContext(void 0);exports.useSpringCarousel=function({items:i,withLoop:o=!1,draggingSlideTreshold:u,springConfig:f=n.config.default,shouldResizeOnWindowResize:m=!0,withThumbs:p=!1,enableThumbsWrapperScroll:g=!0,carouselSlideAxis:x="x",thumbsSlideAxis:b="x",prepareThumbsData:v,initialActiveItem:w=0,initialStartingPosition:T="start",disableGestures:y=!1,gutter:C=0,startEndGutter:S=0,touchAction:I,slideAmount:R,freeScroll:E=!1,CustomThumbsWrapperComponent:W,enableFreeScrollDrag:A,itemsPerSlide:N=1,slideType:F="fixed"}){const j=t.useRef(!0),D=t.useRef("initial"),L=o?i.length===N?[...i,...i,...i,...i,...i]:[...i,...i,...i]:i,O=t.useRef(w),P=t.useRef(null),M=t.useRef(null),$=t.useRef(!1),k=t.useRef(!1),q=t.useRef(!1),z=t.useRef(0),B=t.useRef(!1),H=t.useRef(0),V=t.useRef(0),G=t.useRef(0),Y=t.useRef(i),X=t.useRef(u??0),_=t.useRef(N),J=t.useRef(C),K=t.useRef(S),Q=t.useRef(w),U=t.useRef(T);_.current=N,J.current=C,K.current=S,Q.current=w,U.current=T,c((()=>{X.current=u||Math.floor(se()/2/2),le()}),[u,N,C,S,w,T]);const[Z,ee]=n.useSpring((()=>({y:0,x:0,config:f,onChange:({value:e})=>{P.current&&E&&(P.current["x"===x?"scrollLeft":"scrollTop"]=Math.abs(e[x]))}}))),te=t.useCallback((()=>{if(!P.current)throw new Error("mainCarouselWrapperRef is not available");return P.current.getBoundingClientRect()["x"===x?"width":"height"]}),[x]),ne=t.useCallback((()=>{const e=M.current?.querySelector(".use-spring-carousel-item");if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===x?"width":"height"]+J.current}),[x]),re=t.useCallback((()=>Z[x].get()),[x,Z]),ie=t.useCallback((()=>ne()*i.length<te()),[ne,te,i.length]),oe=t.useCallback((()=>Math.round(Number(M.current?.["x"===x?"scrollWidth":"scrollHeight"])-M.current.getBoundingClientRect()["x"===x?"width":"height"])),[x]),ue=t.useCallback((()=>0===Ce()),[]),se=t.useCallback((()=>{if(!M.current)return 0;const e=ne();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}),[ne,F,R]),ce=(e,t)=>{const n="x"===x?"left":"top";function r(){return ne()*i.length}function u(r){o?(e.style.top="0px",e.style[n]=`-${r-K.current}px`):(e.style.left="0px",e.style.top="0px",t&&j.current&&(e.style[n]=`calc(-${t} * 100%)`))}function s(){u(r())}if("fixed"===F){if(_.current>1)switch(U.current){default:case"start":s();break;case"center":c=_.current,u(r()-se()*Math.round((c-1)/2));break;case"end":!function(e){u(r()-se()*Math.round(e-1))}(_.current)}else s()}else s();var c},le=()=>{if(H.current=window.innerWidth,"fluid"===F){if(ie())return void ee.start({immediate:!0,[x]:0});if(z.current=oe(),B.current){const e=-z.current;ee.start({immediate:!0,[x]:e})}V.current=window.innerWidth}else ee.start({immediate:!0,[x]:-se()*Ce()});z.current=oe(),ce(M.current)},ae=()=>{window.innerWidth===H.current||E||le()},{useListenToCustomEvent:fe,emitObservable:de}=s(),{enterFullscreen:he,exitFullscreen:me,getIsFullscreen:pe}=a({mainCarouselWrapperRef:P,emitObservable:de,handleResize:ae}),{thumbsFragment:ge,handleThumbsScroll:xe}=d({withThumbs:p,items:i,thumbsSlideAxis:b,springConfig:f,prepareThumbsData:v,slideType:F,getFluidWrapperScrollValue:oe,getSlideValue:se,CustomThumbsWrapperComponent:W});function be(){if(!P.current)throw new Error("Missing mainCarouselWrapperRef.current");return P.current["x"===x?"scrollLeft":"scrollTop"]}const ve=r.useDrag((e=>{const t=e.dragging,n=e.offset["x"===x?0:1],r=e.movement["x"===x?0:1],i=r>X.current,u=r<-X.current,s=e.direction["x"===x?0:1];function c(){e.cancel()}function l(){"fluid"===F?ie()||ue()&&"prev"===Te()?ee.start({[x]:0}):B.current&&"next"===Te()?ee.start({[x]:-z.current}):ee.start({[x]:G.current}):ee.start({[x]:-Ce()*se()})}if(t){Re()||Ie(!0),de({eventName:"onDrag",slideActionType:Te(),...e}),we(s>0?"prev":"next");if(Math.abs(re())+100>=z.current&&"next"===Te()&&(B.current=!0),"prev"===Te()&&(B.current=!1),E){if("boolean"==typeof A?A:"function"==typeof A&&A()){if(0===be()&&"prev"===Te())return void c();ee.start({from:{[x]:be()},to:{[x]:-n}})}return}if(ee.start({[x]:n}),(i||u)&&ie()&&"fluid"===F)c(),l();else if(B.current&&"next"===Te()&&u)B.current=!1,c(),ee.start({[x]:-z.current});else{if(u)return c(),void(!o&&De()?l():Oe());if(i)return c(),void(!o&&ue()?l():Le())}}!e.last||u||i||E||(l(),de({eventName:"onDrag",slideActionType:Te(),...e}))}),{enabled:!y,from:()=>E?"x"===x?[-be(),0]:[0,-be()]:[Z.x.get(),Z.y.get()]});function we(e){D.current=e}function Te(){return D.current}function ye(e){O.current=e}function Ce(){return O.current}function Se(e){k.current=e}function Ie(e){$.current=e}function Re(){return $.current}function Ee(){const e=Ce();return 0===e?i.length-1:e-1}function We(){const e=Ce();return e===i.length-1?0:e+1}function Ae(e){return i.findIndex((t=>t.id===e))}function Ne(e){return"number"==typeof e?{from:{[x]:e}}:{}}function Fe(e,t){if("number"==typeof e)return{[x]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[x]:-se()*t}}function je({from:e,to:t=-1,customTo:n,immediate:r=!1,onRest:o=(()=>{})}){r||(ye(t),Se(!0),de({eventName:"onSlideStartChange",slideActionType:Te(),nextItem:{index:"fluid"===F?-1:t,id:"fluid"===F?"":i[t].id}})),G.current=Fe(n,t)[x],ee.start({...Ne(e),to:Fe(n,t),immediate:r,onRest:e=>{e.finished&&(Ie(!1),Se(!1),o(),r||de({eventName:"onSlideChange",slideActionType:Te(),currentItem:{index:"fluid"===F?-1:Ce(),id:"fluid"===F?"":i[Ce()].id}}))}}),g&&p&&!r&&xe(t,Te())}function De(){return Ce()===i.length-1}function Le(){if(we("prev"),B.current=!1,"fluid"===F){if(B.current=!1,ie())return;const e=re()+se()+200;if(E){const e=P.current.scrollLeft-se();je({customTo:e<0?0:e,from:P.current.scrollLeft})}else je(e>=0?o?{from:re()-ne()*i.length,customTo:re()-ne()*i.length+se()}:{customTo:0}:{customTo:re()+se()})}else{if(!o&&0===Ce()||q.current)return;ue()?je({from:re()-se()*i.length,to:i.length-1}):je({to:Ee()})}}function Oe(){if(we("next"),"fluid"===F){if(ie())return;const e=Math.abs(re()-se())+100>=z.current;if(E){const e=P.current.scrollLeft+se()>z.current,t=P.current.scrollLeft+se();je({customTo:e?z.current:t,from:P.current.scrollLeft})}else if(o&&Math.abs(re()-se())>=i.length*ne()){const e=ne()*i.length;je({from:re()+e,customTo:re()+e-se()})}else{if(B.current)return;e?(B.current=!0,je({customTo:-z.current})):je({customTo:re()-se()})}}else{if(!o&&Ce()===L.length-1||q.current)return;Math.abs(re()-se()+25)>z.current&&!Re()?B.current=!0:B.current?je({to:i.length-_.current}):De()?je({from:re()+se()*i.length,to:0}):je({to:We()})}}function Pe(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===Ce()||i.length!==Y.current.length&&Ce()<i.length)return;const n=Ae(Y.current[Ce()].id);we(Ae(i[t].id)>n?"next":"prev"),je({to:t})}l((()=>{if(X.current<0)throw new Error("draggingSlideTreshold must be greater than 0");if(X.current>se()/2)throw new Error(`draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(se()/2)}`);if(_.current<1)throw new Error("The itemsPerSlide prop can't be less than 1.");if(_.current>i.length)throw new Error("The itemsPerSlide prop can't be greater than the total length of the items you provide.");if(Q.current<0)throw new Error("The initialActiveItem cannot be less than 0.");if(Q.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?q.current=!0:q.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),l((()=>{j.current=!1,z.current=oe(),V.current=window.innerWidth,H.current=window.innerWidth,w>0&&(je({to:w,immediate:!0}),ye(w),!o&&M.current&&(M.current.style.top="0px",M.current.style.left="0px"))})),t.useEffect((()=>{Q.current<i.length&&Q.current!==O.current&&(je({to:Q.current,immediate:!0}),ye(Q.current))}),[]),t.useEffect((()=>{if(m)return window.addEventListener("resize",ae),()=>{window.removeEventListener("resize",ae)}}),[m]),t.useEffect((()=>{M.current&&("x"===x&&(M.current.style.top="0px"),"y"===x&&(M.current.style.left="0px"))}),[x]),t.useEffect((()=>{z.current=oe();!(i.length===Y.current.length)&&i.length<Y.current.length&&Pe(i.length-1),Y.current=i}),[oe,i]);const Me={useListenToCustomEvent:fe,getIsFullscreen:pe,enterFullscreen:he,exitFullscreen:me,getIsAnimating:function(){return k.current},getIsDragging:Re,getIsNextItem:function(e){const t=Ae(e),n=Ce();return o&&n===i.length-1?0===t:t===n+1},getIsPrevItem:function(e){const t=Ae(e),n=Ce();return o&&0===n?t===i.length-1:t===n-1},slideToPrevItem:Le,slideToNextItem:Oe,..."fixed"===F?{slideToItem:Pe,getIsActiveItem:e=>Ae(e)===Ce(),getCurrentActiveItem:()=>({id:i[Ce()].id,index:Ce()})}:{}},$e=e.jsx(h.Provider,Object.assign({value:Me},{children:e.jsx("div",Object.assign({ref:P,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},E?{onWheel(){Z[x].stop()}}:{},{style:{display:"flex",position:"relative",width:"100%",height:"100%",...E?"x"===x?{overflowX:"auto"}:{overflowY:"auto"}:{}}},{children:e.jsx(n.animated.div,Object.assign({},ve(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{_.current=N,e&&(M.current=e,ce(e,Q.current))},style:{display:"flex",position:"relative",touchAction:y?"unset":I||("x"===x?"pan-y":"pan-x"),flexDirection:"x"===x?"row":"column",...function(){const e=`calc(100% - ${2*K.current}px)`;return{width:"x"===x?e:"100%",height:"y"===x?e:"100%"}}(),...E?{}:Z}},{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:{display:"flex",position:"relative",...(i=_.current,"fixed"===F?{..."x"===x?{marginRight:`${J.current}px`}:{marginBottom:`${J.current}px`},flex:`1 0 calc(100% / ${i} - ${J.current*(i-1)/i}px)`}:{..."x"===x?{marginRight:`${J.current}px`}:{marginBottom:`${J.current}px`}})}},{children:n}),`${t}-${r}`);var i}))}),void 0)}),void 0)}),void 0),ke=e.jsx(h.Provider,Object.assign({value:Me},{children:ge}),void 0);return{...Me,carouselFragment:$e,thumbsFragment:ke}},exports.useSpringCarouselContext=function(){const e=t.useContext(h);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:u=!1,springConfig:c=n.config.default,thumbsSlideAxis:l="x",enableThumbsWrapperScroll:f=!0,draggingSlideTreshold:h=50,prepareThumbsData:p,toPrevItemSpringProps:g,toNextItemSpringProps:x,disableGestures:b=!1,CustomThumbsWrapperComponent:v,springAnimationProps:w={initial:{opacity:1,position:"relative"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"relative"},leave:{opacity:0,position:"absolute"}}}){const T=t.useRef("next"),y=t.useRef(null),C=t.useRef(!1),[S,I]=t.useState(0),{emitObservable:R,useListenToCustomEvent:E}=s(),{enterFullscreen:W,exitFullscreen:A,getIsFullscreen:N}=a({emitObservable:R,mainCarouselWrapperRef:y}),{thumbsFragment:F,handleThumbsScroll:j}=d({items:i,withThumbs:u,thumbsSlideAxis:l,springConfig:c,prepareThumbsData:p,CustomThumbsWrapperComponent:v,slideType:"fixed"}),D=r.useDrag((({last:e,movement:[t]})=>{if(!O()&&e){const e=t>h,n=t<-h,r=0===S,u=S===i.length-1;if(n){if(!o&&u)return;k(),R({eventName:"onLeftSwipe"})}else if(e){if(!o&&r)return;q(),R({eventName:"onRightSwipe"})}}}),{enabled:!b}),L=n.useTransition(S,{config:c,...function(){const e=$();return"prev"===e&&g?{initial:{...w.initial},from:{...g.from},enter:{...g.enter},leave:{...g.leave}}:"next"===e&&x?{initial:{...w.initial},from:{...x.from},enter:{...x.enter},leave:{...x.leave}}:{initial:{...w.initial},from:{...w.from},enter:{...w.enter},leave:{...w.leave}}}(),onStart:()=>P(!0),keys:null,onRest:e=>{e.finished&&(P(!1),R({eventName:"onSlideChange",slideActionType:$(),currentItem:{index:S,id:i[S].id}}))}})(((t,r)=>e.jsx(n.animated.div,Object.assign({style:{...t,flex:"1 0 100%",width:"100%",height:"100%"}},{children:i[r].renderItem}),void 0)));function O(){return C.current}function P(e){C.current=e}function M(e){T.current=e}function $(){return T.current}function k(){const e=S===i.length-1;o?(M("next"),e?(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:0,id:i[0].id}}),I(0)):(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S+1,id:i[S+1].id}}),I(S+1))):e||(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S+1,id:i[S+1].id}}),M("next"),I(S+1))}function q(){const e=0===S;o?(M("prev"),e?(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S-1,id:i[S-1].id}}),I(i.length-1)):(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S-1,id:i[S-1].id}}),I(S-1))):e||(M("prev"),R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S-1,id:i[S-1].id}}),I(S-1))}function z(e){return i.findIndex((t=>t.id===e))}const B={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=z(i[S].id),r=z(i[t].id);R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:r,id:i[t].id}}),M(r>n?"next":"prev"),I(t),f&&u&&j(t)},slideToNextItem:k,slideToPrevItem:q,enterFullscreen:W,exitFullscreen:A,useListenToCustomEvent:E,getIsNextItem:function(e){const t=z(e);return o&&S===i.length-1?0===t:t===S+1},getIsPrevItem:function(e){const t=z(e);return o&&0===S?t===i.length-1:t===S-1},getIsAnimating:O,getIsFullscreen:N,getIsActiveItem:e=>z(e)===S,getCurrentActiveItem:()=>({id:i[S].id,index:S})};return{carouselFragment:e.jsx(m.Provider,Object.assign({value:B},{children:e.jsx("div",Object.assign({ref:y},D(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:L}),void 0)}),void 0),thumbsFragment:e.jsx(m.Provider,Object.assign({value:B},{children:F}),void 0),...B}},exports.useTransitionCarouselContext=function(){const e=t.useContext(m);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 u=o(require("screenfull"));function s(){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(u.default.isEnabled)return u.default.on("change",e),()=>{u.default.isEnabled&&u.default.off("change",e)}})),{enterFullscreen:function(t){u.default.isEnabled&&u.default.request(t||e.current)},exitFullscreen:function(){u.default.isEnabled&&u.default.exit()},getIsFullscreen:function(){return i.current}}}const f=t.forwardRef((({children:t,...r},i)=>e.jsx(n.animated.div,Object.assign({},r,{ref:i},{children:t}),void 0)));function d({items:r,withThumbs:i,thumbsSlideAxis:o="x",springConfig:u,prepareThumbsData:s,getFluidWrapperScrollValue:c=(()=>0),getSlideValue:a=(()=>0),CustomThumbsWrapperComponent:d,slideType:h}){const m=t.useRef(null),[p,g]=n.useSpring((()=>({x:0,y:0,config:u,onChange:({value:e})=>{m.current&&"fluid"===h&&(m.current["x"===o?"scrollLeft":"scrollTop"]=Math.abs(e[o]))}})));function x(){return m.current["x"===o?"scrollLeft":"scrollTop"]}function b(){return Math.round(Number(m.current?.["x"===o?"scrollWidth":"scrollHeight"])-m.current.getBoundingClientRect()["x"===o?"width":"height"])}function v(){const e=Math.round(c()/a());return b()/e}l((()=>{if(i&&!m.current)throw new Error("The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.")}));const w=d?n.animated(d):f;return{thumbsFragment:i?e.jsx(w,Object.assign({ref:m,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{p[o].stop()},style:{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 s?s(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)}))}),void 0):null,handleThumbsScroll:function(e,t){if("fluid"===h){const e=b();if("next"===t){const t=x()+v();g.start({from:{[o]:x()},to:{[o]:t>e?e:t}})}if("prev"===t){const e=x()-v();g.start({from:{[o]:x()},to:{[o]:e<0?0:e}})}}else{const n=m.current.querySelector(`#thumb-${r[e].id}`);if(n){const i=m.current,u="x"===o?"offsetWidth":"offsetHeight",s="x"===o?"scrollLeft":"scrollTop",c=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:n,offsetDimension:u,offsetDirection:"x"===o?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:i,offsetDimension:u}),a=function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:i,scrollDirection:s}),f=function({thumbWrapper:t,thumbOffsetPosition:n,thumbScrollDimension:i,offsetDimension:u}){const s="x"===o?"scrollWidth":"scrollHeight";return e===r.length-1||n-i>t[s]-t[u]?t[s]-t[u]:0===e?0:n-i}({thumbWrapper:i,thumbOffsetPosition:c,thumbScrollDimension:l,offsetDimension:u});g.start({from:{[o]:a},to:{[o]:"prev"===t&&f<0?0:f},onChange:({value:e})=>{"x"===o?m.current.scrollLeft=e.x:m.current.scrollTop=e.y}})}}}}}const h=t.createContext(void 0);const m=t.createContext(void 0);exports.useSpringCarousel=function({items:i,withLoop:o=!1,draggingSlideTreshold:u,springConfig:f=n.config.default,shouldResizeOnWindowResize:m=!0,withThumbs:p=!1,enableThumbsWrapperScroll:g=!0,carouselSlideAxis:x="x",thumbsSlideAxis:b="x",prepareThumbsData:v,initialActiveItem:w=0,initialStartingPosition:T="start",disableGestures:y=!1,gutter:C=0,startEndGutter:S=0,touchAction:I,slideAmount:R,freeScroll:E=!1,CustomThumbsWrapperComponent:W,enableFreeScrollDrag:A,itemsPerSlide:N=1,slideType:F="fixed"}){const j=t.useRef(!0),D=t.useRef("initial"),L=o?i.length===N?[...i,...i,...i,...i,...i]:[...i,...i,...i]:i,O=t.useRef(w),P=t.useRef(null),M=t.useRef(null),$=t.useRef(!1),k=t.useRef(!1),q=t.useRef(!1),z=t.useRef(0),B=t.useRef(!1),H=t.useRef(0),V=t.useRef(0),G=t.useRef(0),Y=t.useRef(i),X=t.useRef(u??0),_=t.useRef(N),J=t.useRef(C),K=t.useRef(S),Q=t.useRef(w),U=t.useRef(T);_.current=N,J.current=C,K.current=S,Q.current=w,U.current=T,c((()=>{X.current=u||Math.floor(se()/2/2),le()}),[u,N,C,S,w,T]);const[Z,ee]=n.useSpring((()=>({y:0,x:0,config:f,onChange:({value:e})=>{P.current&&E&&(P.current["x"===x?"scrollLeft":"scrollTop"]=Math.abs(e[x]))}}))),te=t.useCallback((()=>{if(!P.current)throw new Error("mainCarouselWrapperRef is not available");return P.current.getBoundingClientRect()["x"===x?"width":"height"]}),[x]),ne=t.useCallback((()=>{const e=M.current?.querySelector(".use-spring-carousel-item");if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===x?"width":"height"]+J.current}),[x]),re=t.useCallback((()=>Z[x].get()),[x,Z]),ie=t.useCallback((()=>ne()*i.length<te()),[ne,te,i.length]),oe=t.useCallback((()=>Math.round(Number(M.current?.["x"===x?"scrollWidth":"scrollHeight"])-M.current.getBoundingClientRect()["x"===x?"width":"height"])),[x]),ue=t.useCallback((()=>0===Ce()),[]),se=t.useCallback((()=>{if(!M.current)return 0;const e=ne();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}),[ne,F,R]),ce=(e,t)=>{const n="x"===x?"left":"top";function r(){return ne()*i.length}function u(r){o?(e.style.top="0px",e.style[n]=`-${r-K.current}px`):(e.style.left="0px",e.style.top="0px",t&&j.current&&(e.style[n]=`calc(-${t} * 100%)`))}function s(){u(r())}if("fixed"===F){if(_.current>1)switch(U.current){default:case"start":s();break;case"center":c=_.current,u(r()-se()*Math.round((c-1)/2));break;case"end":!function(e){u(r()-se()*Math.round(e-1))}(_.current)}else s()}else s();var c},le=()=>{if(H.current=window.innerWidth,"fluid"===F){if(ie())return void ee.start({immediate:!0,[x]:0});if(z.current=oe(),B.current){const e=-z.current;ee.start({immediate:!0,[x]:e})}V.current=window.innerWidth}else ee.start({immediate:!0,[x]:-se()*Ce()});z.current=oe(),ce(M.current)},ae=()=>{window.innerWidth===H.current||E||le()},{useListenToCustomEvent:fe,emitObservable:de}=s(),{enterFullscreen:he,exitFullscreen:me,getIsFullscreen:pe}=a({mainCarouselWrapperRef:P,emitObservable:de,handleResize:ae}),{thumbsFragment:ge,handleThumbsScroll:xe}=d({withThumbs:p,items:i,thumbsSlideAxis:b,springConfig:f,prepareThumbsData:v,slideType:F,getFluidWrapperScrollValue:oe,getSlideValue:se,CustomThumbsWrapperComponent:W});function be(){if(!P.current)throw new Error("Missing mainCarouselWrapperRef.current");return P.current["x"===x?"scrollLeft":"scrollTop"]}const ve=r.useDrag((e=>{const t=e.dragging,n=e.offset["x"===x?0:1],r=e.movement["x"===x?0:1],i=r>X.current,u=r<-X.current,s=e.direction["x"===x?0:1];function c(){e.cancel()}function l(){"fluid"===F?ie()||ue()&&"prev"===Te()?ee.start({[x]:0}):B.current&&"next"===Te()?ee.start({[x]:-z.current}):ee.start({[x]:G.current}):ee.start({[x]:-Ce()*se()})}if(t){Re()||Ie(!0),de({eventName:"onDrag",slideActionType:Te(),...e}),we(s>0?"prev":"next");if(Math.abs(re())+100>=z.current&&"next"===Te()&&(B.current=!0),"prev"===Te()&&(B.current=!1),E){if("boolean"==typeof A?A:"function"==typeof A&&A()){if(0===be()&&"prev"===Te())return void c();ee.start({from:{[x]:be()},to:{[x]:-n}})}return}if(ee.start({[x]:n}),(i||u)&&ie()&&"fluid"===F)c(),l();else if(B.current&&"next"===Te()&&u)B.current=!1,c(),ee.start({[x]:-z.current});else{if(u)return c(),void(!o&&De()?l():Oe());if(i)return c(),void(!o&&ue()?l():Le())}}!e.last||u||i||E||(l(),de({eventName:"onDrag",slideActionType:Te(),...e}))}),{enabled:!y,from:()=>E?"x"===x?[-be(),0]:[0,-be()]:[Z.x.get(),Z.y.get()]});function we(e){D.current=e}function Te(){return D.current}function ye(e){O.current=e}function Ce(){return O.current}function Se(e){k.current=e}function Ie(e){$.current=e}function Re(){return $.current}function Ee(){const e=Ce();return 0===e?i.length-1:e-1}function We(){const e=Ce();return e===i.length-1?0:e+1}function Ae(e){return i.findIndex((t=>t.id===e))}function Ne(e){return"number"==typeof e?{from:{[x]:e}}:{}}function Fe(e,t){if("number"==typeof e)return{[x]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[x]:-se()*t}}function je({from:e,to:t=-1,customTo:n,immediate:r=!1,onRest:o=(()=>{})}){r||(ye(t),Se(!0),de({eventName:"onSlideStartChange",slideActionType:Te(),nextItem:{index:"fluid"===F?-1:t,id:"fluid"===F?"":i[t].id}})),G.current=Fe(n,t)[x],ee.start({...Ne(e),to:Fe(n,t),immediate:r,onRest:e=>{e.finished&&(Ie(!1),Se(!1),o(),r||de({eventName:"onSlideChange",slideActionType:Te(),currentItem:{index:"fluid"===F?-1:Ce(),id:"fluid"===F?"":i[Ce()].id}}))}}),g&&p&&!r&&xe(t,Te())}function De(){return Ce()===i.length-1}function Le(){if(we("prev"),B.current=!1,"fluid"===F){if(B.current=!1,ie())return;const e=re()+se()+200;if(E){const e=P.current.scrollLeft-se();je({customTo:e<0?0:e,from:P.current.scrollLeft})}else je(e>=0?o?{from:re()-ne()*i.length,customTo:re()-ne()*i.length+se()}:{customTo:0}:{customTo:re()+se()})}else{if(!o&&0===Ce()||q.current)return;ue()?je({from:re()-se()*i.length,to:i.length-1}):je({to:Ee()})}}function Oe(){if(we("next"),"fluid"===F){if(ie())return;const e=Math.abs(re()-se())+100>=z.current;if(E){const e=P.current.scrollLeft+se()>z.current,t=P.current.scrollLeft+se();je({customTo:e?z.current:t,from:P.current.scrollLeft})}else if(o&&Math.abs(re()-se())>=i.length*ne()){const e=ne()*i.length;je({from:re()+e,customTo:re()+e-se()})}else{if(B.current)return;e?(B.current=!0,je({customTo:-z.current})):je({customTo:re()-se()})}}else{if(!o&&Ce()===L.length-1||q.current)return;Math.abs(re()-se()+25)>z.current&&!Re()?B.current=!0:B.current?je({to:i.length-_.current}):De()?je({from:re()+se()*i.length,to:0}):je({to:We()})}}function Pe(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===Ce()||i.length!==Y.current.length&&Ce()<i.length)return;const n=Ae(Y.current[Ce()].id);we(Ae(i[t].id)>n?"next":"prev"),je({to:t})}l((()=>{if(X.current<0)throw new Error("draggingSlideTreshold must be greater than 0");if(X.current>se()/2)throw new Error(`draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(se()/2)}`);if(_.current<1)throw new Error("The itemsPerSlide prop can't be less than 1.");if(_.current>i.length)throw new Error("The itemsPerSlide prop can't be greater than the total length of the items you provide.");if(Q.current<0)throw new Error("The initialActiveItem cannot be less than 0.");if(Q.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?q.current=!0:q.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),l((()=>{j.current=!1,z.current=oe(),V.current=window.innerWidth,H.current=window.innerWidth,w>0&&(je({to:w,immediate:!0}),ye(w),!o&&M.current&&(M.current.style.top="0px",M.current.style.left="0px"))})),c((()=>{Q.current<i.length&&Q.current!==O.current&&(je({to:Q.current,immediate:!0}),ye(Q.current))}),[]),c((()=>{if(m)return window.addEventListener("resize",ae),()=>{window.removeEventListener("resize",ae)}}),[m]),c((()=>{M.current&&("x"===x&&(M.current.style.top="0px"),"y"===x&&(M.current.style.left="0px"))}),[x]),c((()=>{z.current=oe();!(i.length===Y.current.length)&&i.length<Y.current.length&&Pe(i.length-1),Y.current=i}),[oe,i]);const Me={useListenToCustomEvent:fe,getIsFullscreen:pe,enterFullscreen:he,exitFullscreen:me,getIsAnimating:function(){return k.current},getIsDragging:Re,getIsNextItem:function(e){const t=Ae(e),n=Ce();return o&&n===i.length-1?0===t:t===n+1},getIsPrevItem:function(e){const t=Ae(e),n=Ce();return o&&0===n?t===i.length-1:t===n-1},slideToPrevItem:Le,slideToNextItem:Oe,..."fixed"===F?{slideToItem:Pe,getIsActiveItem:e=>Ae(e)===Ce(),getCurrentActiveItem:()=>({id:i[Ce()].id,index:Ce()})}:{}},$e=e.jsx(h.Provider,Object.assign({value:Me},{children:e.jsx("div",Object.assign({ref:P,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},E?{onWheel(){Z[x].stop()}}:{},{style:{display:"flex",position:"relative",width:"100%",height:"100%",...E?"x"===x?{overflowX:"auto"}:{overflowY:"auto"}:{}}},{children:e.jsx(n.animated.div,Object.assign({},ve(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{_.current=N,e&&(M.current=e,ce(e,Q.current))},style:{display:"flex",position:"relative",touchAction:y?"unset":I||("x"===x?"pan-y":"pan-x"),flexDirection:"x"===x?"row":"column",...function(){const e=`calc(100% - ${2*K.current}px)`;return{width:"x"===x?e:"100%",height:"y"===x?e:"100%"}}(),...E?{}:Z}},{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:{display:"flex",position:"relative",...(i=_.current,"fixed"===F?{..."x"===x?{marginRight:`${J.current}px`}:{marginBottom:`${J.current}px`},flex:`1 0 calc(100% / ${i} - ${J.current*(i-1)/i}px)`}:{..."x"===x?{marginRight:`${J.current}px`}:{marginBottom:`${J.current}px`}})}},{children:n}),`${t}-${r}`);var i}))}),void 0)}),void 0)}),void 0),ke=e.jsx(h.Provider,Object.assign({value:Me},{children:ge}),void 0);return{...Me,carouselFragment:$e,thumbsFragment:ke}},exports.useSpringCarouselContext=function(){const e=t.useContext(h);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:u=!1,springConfig:c=n.config.default,thumbsSlideAxis:l="x",enableThumbsWrapperScroll:f=!0,draggingSlideTreshold:h=50,prepareThumbsData:p,toPrevItemSpringProps:g,toNextItemSpringProps:x,disableGestures:b=!1,CustomThumbsWrapperComponent:v,springAnimationProps:w={initial:{opacity:1,position:"relative"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"relative"},leave:{opacity:0,position:"absolute"}}}){const T=t.useRef("next"),y=t.useRef(null),C=t.useRef(!1),[S,I]=t.useState(0),{emitObservable:R,useListenToCustomEvent:E}=s(),{enterFullscreen:W,exitFullscreen:A,getIsFullscreen:N}=a({emitObservable:R,mainCarouselWrapperRef:y}),{thumbsFragment:F,handleThumbsScroll:j}=d({items:i,withThumbs:u,thumbsSlideAxis:l,springConfig:c,prepareThumbsData:p,CustomThumbsWrapperComponent:v,slideType:"fixed"}),D=r.useDrag((({last:e,movement:[t]})=>{if(!O()&&e){const e=t>h,n=t<-h,r=0===S,u=S===i.length-1;if(n){if(!o&&u)return;k(),R({eventName:"onLeftSwipe"})}else if(e){if(!o&&r)return;q(),R({eventName:"onRightSwipe"})}}}),{enabled:!b}),L=n.useTransition(S,{config:c,...function(){const e=$();return"prev"===e&&g?{initial:{...w.initial},from:{...g.from},enter:{...g.enter},leave:{...g.leave}}:"next"===e&&x?{initial:{...w.initial},from:{...x.from},enter:{...x.enter},leave:{...x.leave}}:{initial:{...w.initial},from:{...w.from},enter:{...w.enter},leave:{...w.leave}}}(),onStart:()=>P(!0),keys:null,onRest:e=>{e.finished&&(P(!1),R({eventName:"onSlideChange",slideActionType:$(),currentItem:{index:S,id:i[S].id}}))}})(((t,r)=>e.jsx(n.animated.div,Object.assign({style:{...t,flex:"1 0 100%",width:"100%",height:"100%"}},{children:i[r].renderItem}),void 0)));function O(){return C.current}function P(e){C.current=e}function M(e){T.current=e}function $(){return T.current}function k(){const e=S===i.length-1;o?(M("next"),e?(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:0,id:i[0].id}}),I(0)):(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S+1,id:i[S+1].id}}),I(S+1))):e||(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S+1,id:i[S+1].id}}),M("next"),I(S+1))}function q(){const e=0===S;o?(M("prev"),e?(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S-1,id:i[S-1].id}}),I(i.length-1)):(R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S-1,id:i[S-1].id}}),I(S-1))):e||(M("prev"),R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:S-1,id:i[S-1].id}}),I(S-1))}function z(e){return i.findIndex((t=>t.id===e))}const B={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=z(i[S].id),r=z(i[t].id);R({eventName:"onSlideStartChange",slideActionType:$(),nextItem:{index:r,id:i[t].id}}),M(r>n?"next":"prev"),I(t),f&&u&&j(t)},slideToNextItem:k,slideToPrevItem:q,enterFullscreen:W,exitFullscreen:A,useListenToCustomEvent:E,getIsNextItem:function(e){const t=z(e);return o&&S===i.length-1?0===t:t===S+1},getIsPrevItem:function(e){const t=z(e);return o&&0===S?t===i.length-1:t===S-1},getIsAnimating:O,getIsFullscreen:N,getIsActiveItem:e=>z(e)===S,getCurrentActiveItem:()=>({id:i[S].id,index:S})};return{carouselFragment:e.jsx(m.Provider,Object.assign({value:B},{children:e.jsx("div",Object.assign({ref:y},D(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:L}),void 0)}),void 0),thumbsFragment:e.jsx(m.Provider,Object.assign({value:B},{children:F}),void 0),...B}},exports.useTransitionCarouselContext=function(){const e=t.useContext(m);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
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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 { EventsObservableProps, ObservableCallbackFn, EmitObservableFn } from '../types'\n\nexport function useCustomEventsModule() {\n const eventsObserverRef = useRef(new Subject<EventsObservableProps>())\n\n function useListenToCustomEvent(fn: ObservableCallbackFn) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, 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 = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn\n handleResize?(): void\n}\n\nexport function useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule) {\n const isFullscreen = useRef(false)\n\n 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 { forwardRef, HTMLAttributes, 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 CustomThumbsWrapperComponent?: UseSpringCarouselProps['CustomThumbsWrapperComponent']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\ntype WrapperProps = {\n children: React.ReactNode\n} & HTMLAttributes<HTMLDivElement>\n\nconst InternalWrapper = forwardRef<HTMLDivElement, WrapperProps>(\n ({ children, ...rest }, ref) => {\n return (\n <animated.div {...rest} ref={ref}>\n {children}\n </animated.div>\n )\n },\n)\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n CustomThumbsWrapperComponent,\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 Wrapper = CustomThumbsWrapperComponent\n ? animated(CustomThumbsWrapperComponent)\n : InternalWrapper\n\n const thumbsFragment = withThumbs ? (\n <Wrapper\n ref={internalThumbsWrapperRef}\n className=\"use-spring-carousel-thumbs-wrapper\"\n onWheel={() => {\n thumbListStyles[thumbsSlideAxis].stop()\n }}\n style={{\n display: 'flex',\n flex: 1,\n position: 'relative',\n 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 </Wrapper>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useCallback, useContext, useEffect } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from '../modules'\nimport {\n SlideToItemFnProps,\n SlideActionType,\n UseSpringDafaultTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n} from '../types/useSpringCarousel'\nimport { UseSpringFluidTypeReturnProps } from 'react-spring-carousel'\n\nconst UseSpringCarouselContext = createContext<\n (UseSpringFluidTypeReturnProps | UseSpringDafaultTypeReturnProps) | undefined\n>(undefined)\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition = 'start',\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n CustomThumbsWrapperComponent,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps) {\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')\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\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\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 ])\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxis])\n }\n },\n }))\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n const getMainCarouselWrapperWidth = useCallback(() => {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ]\n }, [carouselSlideAxis])\n const getCarouselItemWidth = useCallback(() => {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }, [carouselSlideAxis])\n const getCurrentSlidedValue = useCallback(() => {\n return carouselStyles[carouselSlideAxis].get()\n }, [carouselSlideAxis, carouselStyles])\n const getIfItemsNotFillTheCarousel = useCallback(() => {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }, [getCarouselItemWidth, getMainCarouselWrapperWidth, items.length])\n const getFluidWrapperScrollValue = useCallback(() => {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }, [carouselSlideAxis])\n const getIsFirstItem = useCallback(() => {\n return getCurrentActiveItem() === 0\n }, [])\n const getSlideValue = useCallback(() => {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (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 }, [getCarouselItemWidth, slideType, slideAmount])\n const adjustCarouselWrapperPosition = (\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) => {\n const positionProperty = carouselSlideAxis === '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 const resize = () => {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: 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 [carouselSlideAxis]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n const handleResize = () => {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n CustomThumbsWrapperComponent,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n 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[carouselSlideAxis === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxis === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxis === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxis]: 0,\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: prevSlidedValue.current,\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: -(getCurrentActiveItem() * getSlideValue()),\n })\n }\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n\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 if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n from: {\n [carouselSlideAxis]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxis]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: movement,\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 [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem()\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem()\n }\n return\n }\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 from: () => {\n if (freeScroll) {\n if (carouselSlideAxis === '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 [carouselSlideAxis]: 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 [carouselSlideAxis]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxis]: -(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 }: 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\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\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() {\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 })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n })\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n })\n }\n }\n }\n function slideToNextItem() {\n setSlideActionType('next')\n\n if (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 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 })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n 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 })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n })\n }\n }\n }\n // 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 ...(carouselSlideAxis === '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 ...(carouselSlideAxis === '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: carouselSlideAxis === 'x' ? percentValue : '100%',\n height: carouselSlideAxis === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxis === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxis].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxis === '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 (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\n useEffect(() => {\n if (\n initialActiveItemRef.current < items.length &&\n initialActiveItemRef.current !== activeItem.current\n ) {\n slideToItem({\n to: initialActiveItemRef.current,\n immediate: true,\n })\n setActiveItem(initialActiveItemRef.current)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n useEffect(() => {\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 useEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxis === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxis === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useEffect(() => {\n 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 slideToNextItem,\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 itemsPerSlideRef.current = itemsPerSlide\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n const carouselFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxis === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </UseSpringCarouselContext.Provider>\n )\n const thumbsFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseSpringCarouselContext.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext() {\n const context = useContext(UseSpringCarouselContext)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context\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 CustomThumbsWrapperComponent,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'relative',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'relative',\n },\n leave: {\n opacity: 0,\n position: 'absolute',\n },\n },\n}: UseTransitionCarouselProps) {\n const slideActionType = useRef<SlideActionType>('next')\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const isAnimating = useRef(false)\n const [activeItem, setActiveItem] = useState(0)\n\n const { emitObservable, useListenToCustomEvent } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items: items as ReactSpringCarouselItemWithThumbs[],\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n CustomThumbsWrapperComponent,\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 keys: null,\n onRest: val => {\n if (val.finished) {\n setIsAnimating(false)\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: activeItem,\n id: items[activeItem].id,\n },\n })\n }\n },\n })\n const itemsFragment = transitions((styles, item) => (\n <animated.div\n style={{\n ...styles,\n flex: '1 0 100%',\n width: '100%',\n height: '100%',\n }}\n >\n {items[item].renderItem}\n </animated.div>\n ))\n\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (itemIndex === activeItem) {\n return\n }\n\n const currentItem = findItemIndex(items[activeItem].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: newActiveItem,\n id: items[itemIndex].id,\n },\n })\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n setActiveItem(itemIndex)\n\n if (enableThumbsWrapperScroll && withThumbs) {\n handleThumbsScroll(itemIndex)\n }\n }\n function slideToNextItem() {\n const isLastItem = activeItem === items.length - 1\n\n if (withLoop) {\n setSlideActionType('next')\n if (isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: 0,\n id: items[0].id,\n },\n })\n setActiveItem(0)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setActiveItem(activeItem + 1)\n }\n } else {\n if (!isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setSlideActionType('next')\n setActiveItem(activeItem + 1)\n }\n }\n }\n function slideToPrevItem() {\n const isFirstItem = activeItem === 0\n\n if (withLoop) {\n setSlideActionType('prev')\n if (isFirstItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(items.length - 1)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n } else {\n if (!isFirstItem) {\n setSlideActionType('prev')\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n }\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n\n return itemIndex === activeItem - 1\n }\n\n const contextProps: UseTransitionCarouselContextProps = {\n activeItem,\n slideToItem,\n slideToNextItem,\n slideToPrevItem,\n enterFullscreen,\n exitFullscreen,\n useListenToCustomEvent,\n getIsNextItem,\n getIsPrevItem,\n getIsAnimating,\n getIsFullscreen,\n getIsActiveItem: id => {\n return findItemIndex(id) === activeItem\n },\n getCurrentActiveItem: () => ({\n id: items[activeItem].id,\n index: activeItem,\n }),\n }\n\n const carouselFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n {...bindSwipe()}\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n }}\n >\n {itemsFragment}\n </div>\n </UseTransitionCarouselContext.Provider>\n )\n\n const thumbsFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseTransitionCarouselContext.Provider>\n )\n\n return {\n carouselFragment,\n thumbsFragment,\n ...contextProps,\n }\n}\n\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","InternalWrapper","forwardRef","children","rest","ref","_jsx","animated","div","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","getFluidWrapperScrollValue","getSlideValue","CustomThumbsWrapperComponent","slideType","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","Wrapper","thumbsFragment","className","onWheel","stop","style","display","flex","position","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","UseSpringCarouselContext","createContext","undefined","UseTransitionCarouselContext","withLoop","draggingSlideTreshold","default","shouldResizeOnWindowResize","enableThumbsWrapperScroll","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","floor","resize","carouselStyles","setCarouselStyles","getMainCarouselWrapperWidth","useCallback","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","setEndPosition","innerWidth","immediate","_thumbsFragment","getWrapperScrollDirection","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","resetAnimation","getSlideActionType","getIsDragging","setIsDragging","setSlideActionType","getIsLastItem","slideToNextItem","slideToPrevItem","last","enabled","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","getFromValue","getToValue","customTo","slideToItem","onRest","nextItem","index","finished","currentItem","nextPrevValue","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","Provider","percentValue","getAnimatedWrapperStyles","renderItem","_itemsPerSlide","marginRight","marginBottom","context","useContext","toPrevItemSpringProps","toNextItemSpringProps","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","keys","transitions","styles","newActiveItem","overflow"],"mappings":"sTAIg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6B6H,wBAAS7L,MAAOuL,aAC5C5M,2BACED,IAAKvB,GACD2P,KACJ9L,MAAO,CACLC,QAAS,OACTE,SAAU,WACVC,MAAO,OACPC,OAAQ,OACRqM,SAAU,qBAGXR,sBAaLtM,eAPAjC,MAACqF,EAA6B6H,wBAAS7L,MAAOuL,aAC3CzD,eAOAyD,yCA1YP,WACE,MAAMa,EAAUC,aAAWrI,GAE3B,IAAKoI,EACH,MAAM,IAAI1L,MAAM,+KAIlB,OAAO0L"}
|
|
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 { EventsObservableProps, ObservableCallbackFn, EmitObservableFn } from '../types'\n\nexport function useCustomEventsModule() {\n const eventsObserverRef = useRef(new Subject<EventsObservableProps>())\n\n function useListenToCustomEvent(fn: ObservableCallbackFn) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, 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 = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn\n handleResize?(): void\n}\n\nexport function useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule) {\n const isFullscreen = useRef(false)\n\n 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 { forwardRef, HTMLAttributes, 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 CustomThumbsWrapperComponent?: UseSpringCarouselProps['CustomThumbsWrapperComponent']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\ntype WrapperProps = {\n children: React.ReactNode\n} & HTMLAttributes<HTMLDivElement>\n\nconst InternalWrapper = forwardRef<HTMLDivElement, WrapperProps>(\n ({ children, ...rest }, ref) => {\n return (\n <animated.div {...rest} ref={ref}>\n {children}\n </animated.div>\n )\n },\n)\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n CustomThumbsWrapperComponent,\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 Wrapper = CustomThumbsWrapperComponent\n ? animated(CustomThumbsWrapperComponent)\n : InternalWrapper\n\n const thumbsFragment = withThumbs ? (\n <Wrapper\n ref={internalThumbsWrapperRef}\n className=\"use-spring-carousel-thumbs-wrapper\"\n onWheel={() => {\n thumbListStyles[thumbsSlideAxis].stop()\n }}\n style={{\n display: 'flex',\n flex: 1,\n position: 'relative',\n 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 </Wrapper>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useCallback, 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 UseSpringDafaultTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n} from '../types/useSpringCarousel'\nimport { UseSpringFluidTypeReturnProps } from 'react-spring-carousel'\n\nconst UseSpringCarouselContext = createContext<\n (UseSpringFluidTypeReturnProps | UseSpringDafaultTypeReturnProps) | undefined\n>(undefined)\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition = 'start',\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n CustomThumbsWrapperComponent,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps) {\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')\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\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\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 ])\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxis])\n }\n },\n }))\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n const getMainCarouselWrapperWidth = useCallback(() => {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ]\n }, [carouselSlideAxis])\n const getCarouselItemWidth = useCallback(() => {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }, [carouselSlideAxis])\n const getCurrentSlidedValue = useCallback(() => {\n return carouselStyles[carouselSlideAxis].get()\n }, [carouselSlideAxis, carouselStyles])\n const getIfItemsNotFillTheCarousel = useCallback(() => {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }, [getCarouselItemWidth, getMainCarouselWrapperWidth, items.length])\n const getFluidWrapperScrollValue = useCallback(() => {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }, [carouselSlideAxis])\n const getIsFirstItem = useCallback(() => {\n return getCurrentActiveItem() === 0\n }, [])\n const getSlideValue = useCallback(() => {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (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 }, [getCarouselItemWidth, slideType, slideAmount])\n const adjustCarouselWrapperPosition = (\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) => {\n const positionProperty = carouselSlideAxis === '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 const resize = () => {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: 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 [carouselSlideAxis]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n const handleResize = () => {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n CustomThumbsWrapperComponent,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n 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[carouselSlideAxis === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxis === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxis === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxis]: 0,\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: prevSlidedValue.current,\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: -(getCurrentActiveItem() * getSlideValue()),\n })\n }\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n\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 if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n from: {\n [carouselSlideAxis]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxis]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: movement,\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 [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem()\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem()\n }\n return\n }\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 from: () => {\n if (freeScroll) {\n if (carouselSlideAxis === '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 [carouselSlideAxis]: 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 [carouselSlideAxis]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxis]: -(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 }: 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\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\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() {\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 })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n })\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n })\n }\n }\n }\n function slideToNextItem() {\n setSlideActionType('next')\n\n if (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 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 })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n 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 })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n })\n }\n }\n }\n // 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 ...(carouselSlideAxis === '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 ...(carouselSlideAxis === '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: carouselSlideAxis === 'x' ? percentValue : '100%',\n height: carouselSlideAxis === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxis === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxis].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxis === '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 (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 (\n initialActiveItemRef.current < items.length &&\n initialActiveItemRef.current !== activeItem.current\n ) {\n slideToItem({\n to: initialActiveItemRef.current,\n immediate: true,\n })\n setActiveItem(initialActiveItemRef.current)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\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 (carouselSlideAxis === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxis === '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 slideToNextItem,\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 itemsPerSlideRef.current = itemsPerSlide\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n const carouselFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxis === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </UseSpringCarouselContext.Provider>\n )\n const thumbsFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseSpringCarouselContext.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext() {\n const context = useContext(UseSpringCarouselContext)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context\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 CustomThumbsWrapperComponent,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'relative',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'relative',\n },\n leave: {\n opacity: 0,\n position: 'absolute',\n },\n },\n}: UseTransitionCarouselProps) {\n const slideActionType = useRef<SlideActionType>('next')\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const isAnimating = useRef(false)\n const [activeItem, setActiveItem] = useState(0)\n\n const { emitObservable, useListenToCustomEvent } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items: items as ReactSpringCarouselItemWithThumbs[],\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n CustomThumbsWrapperComponent,\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 keys: null,\n onRest: val => {\n if (val.finished) {\n setIsAnimating(false)\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: activeItem,\n id: items[activeItem].id,\n },\n })\n }\n },\n })\n const itemsFragment = transitions((styles, item) => (\n <animated.div\n style={{\n ...styles,\n flex: '1 0 100%',\n width: '100%',\n height: '100%',\n }}\n >\n {items[item].renderItem}\n </animated.div>\n ))\n\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (itemIndex === activeItem) {\n return\n }\n\n const currentItem = findItemIndex(items[activeItem].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: newActiveItem,\n id: items[itemIndex].id,\n },\n })\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n setActiveItem(itemIndex)\n\n if (enableThumbsWrapperScroll && withThumbs) {\n handleThumbsScroll(itemIndex)\n }\n }\n function slideToNextItem() {\n const isLastItem = activeItem === items.length - 1\n\n if (withLoop) {\n setSlideActionType('next')\n if (isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: 0,\n id: items[0].id,\n },\n })\n setActiveItem(0)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setActiveItem(activeItem + 1)\n }\n } else {\n if (!isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setSlideActionType('next')\n setActiveItem(activeItem + 1)\n }\n }\n }\n function slideToPrevItem() {\n const isFirstItem = activeItem === 0\n\n if (withLoop) {\n setSlideActionType('prev')\n if (isFirstItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(items.length - 1)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n } else {\n if (!isFirstItem) {\n setSlideActionType('prev')\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n }\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n\n return itemIndex === activeItem - 1\n }\n\n const contextProps: UseTransitionCarouselContextProps = {\n activeItem,\n slideToItem,\n slideToNextItem,\n slideToPrevItem,\n enterFullscreen,\n exitFullscreen,\n useListenToCustomEvent,\n getIsNextItem,\n getIsPrevItem,\n getIsAnimating,\n getIsFullscreen,\n getIsActiveItem: id => {\n return findItemIndex(id) === activeItem\n },\n getCurrentActiveItem: () => ({\n id: items[activeItem].id,\n index: activeItem,\n }),\n }\n\n const carouselFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n {...bindSwipe()}\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n }}\n >\n {itemsFragment}\n </div>\n </UseTransitionCarouselContext.Provider>\n )\n\n const thumbsFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseTransitionCarouselContext.Provider>\n )\n\n return {\n carouselFragment,\n thumbsFragment,\n ...contextProps,\n }\n}\n\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","InternalWrapper","forwardRef","children","rest","ref","_jsx","animated","div","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","getFluidWrapperScrollValue","getSlideValue","CustomThumbsWrapperComponent","slideType","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","Wrapper","thumbsFragment","className","onWheel","stop","style","display","flex","position","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","UseSpringCarouselContext","createContext","undefined","UseTransitionCarouselContext","withLoop","draggingSlideTreshold","default","shouldResizeOnWindowResize","enableThumbsWrapperScroll","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","floor","resize","carouselStyles","setCarouselStyles","getMainCarouselWrapperWidth","useCallback","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","setEndPosition","innerWidth","immediate","_thumbsFragment","getWrapperScrollDirection","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","resetAnimation","getSlideActionType","getIsDragging","setIsDragging","setSlideActionType","getIsLastItem","slideToNextItem","slideToPrevItem","last","enabled","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","getFromValue","getToValue","customTo","slideToItem","onRest","nextItem","index","finished","currentItem","nextPrevValue","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","Provider","percentValue","getAnimatedWrapperStyles","renderItem","_itemsPerSlide","marginRight","marginBottom","context","useContext","toPrevItemSpringProps","toNextItemSpringProps","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","keys","transitions","styles","newActiveItem","overflow"],"mappings":"sTAIgBA,IACd,MAAMC,EAAoBC,SAAO,IAAIC,WAarC,MAAO,CACLC,uBAZF,SAAgCC,GAC9BC,aAAU,KACR,MAAMC,E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AU,WACVC,MAAO,OACPC,OAAQ,OACRqM,SAAU,qBAGXR,sBAaLtM,eAPAjC,MAACqF,EAA6B6H,wBAAS7L,MAAOuL,aAC3CzD,eAOAyD,yCA1YP,WACE,MAAMa,EAAUC,aAAWrI,GAE3B,IAAKoI,EACH,MAAM,IAAI1L,MAAM,+KAIlB,OAAO0L"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useRef as t,useEffect as n,useLayoutEffect as r,forwardRef as i,createContext as o,useCallback as u,useContext as s,useState as c}from"react";import{animated as l,useSpring as a,config as d,useTransition as f}from"react-spring";import{useDrag as h}from"@use-gesture/react";import{Subject as m}from"rxjs";import p from"screenfull";function g(){const e=t(new m);return{useListenToCustomEvent:function(t){n((()=>{const n=e.current.subscribe(t);return()=>n.unsubscribe()}),[t])},emitObservable:t=>{e.current.next(t)}}}const x="undefined"!=typeof window?r:n;function b(e){const n=t(!1);x((()=>{if(!n.current){const t=e();return n.current=!0,()=>{t&&t()}}}),[])}function v({mainCarouselWrapperRef:e,emitObservable:n,handleResize:r}){const i=t(!1);function o(e){i.current=e}return b((()=>{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(p.isEnabled)return p.on("change",e),()=>{p.isEnabled&&p.off("change",e)}})),{enterFullscreen:function(t){p.isEnabled&&p.request(t||e.current)},exitFullscreen:function(){p.isEnabled&&p.exit()},getIsFullscreen:function(){return i.current}}}const w=i((({children:t,...n},r)=>e(l.div,Object.assign({},n,{ref:r},{children:t}),void 0)));function T({items:n,withThumbs:r,thumbsSlideAxis:i="x",springConfig:o,prepareThumbsData:u,getFluidWrapperScrollValue:s=(()=>0),getSlideValue:c=(()=>0),CustomThumbsWrapperComponent:d,slideType:f}){const h=t(null),[m,p]=a((()=>({x:0,y:0,config:o,onChange:({value:e})=>{h.current&&"fluid"===f&&(h.current["x"===i?"scrollLeft":"scrollTop"]=Math.abs(e[i]))}})));function g(){return h.current["x"===i?"scrollLeft":"scrollTop"]}function x(){return Math.round(Number(h.current?.["x"===i?"scrollWidth":"scrollHeight"])-h.current.getBoundingClientRect()["x"===i?"width":"height"])}function v(){const e=Math.round(s()/c());return x()/e}b((()=>{if(r&&!h.current)throw new Error("The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.")}));const T=d?l(d):w;return{thumbsFragment:r?e(T,Object.assign({ref:h,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{m[i].stop()},style:{display:"flex",flex:1,position:"relative",width:"100%",height:"100%",flexDirection:"x"===i?"row":"column",..."x"===i?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"}}},{children:function(){function e(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return u?u(e(n)):e(n)}().map((({id:t,renderThumb:n})=>{const r=`thumb-${t}`;return e("div",Object.assign({id:r,className:"thumb-item"},{children:n}),r)}))}),void 0):null,handleThumbsScroll:function(e,t){if("fluid"===f){const e=x();if("next"===t){const t=g()+v();p.start({from:{[i]:g()},to:{[i]:t>e?e:t}})}if("prev"===t){const e=g()-v();p.start({from:{[i]:g()},to:{[i]:e<0?0:e}})}}else{const r=h.current.querySelector(`#thumb-${n[e].id}`);if(r){const o=h.current,u="x"===i?"offsetWidth":"offsetHeight",s="x"===i?"scrollLeft":"scrollTop",c=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:r,offsetDimension:u,offsetDirection:"x"===i?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:o,offsetDimension:u}),a=function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:o,scrollDirection:s}),d=function({thumbWrapper:t,thumbOffsetPosition:r,thumbScrollDimension:o,offsetDimension:u}){const s="x"===i?"scrollWidth":"scrollHeight";return e===n.length-1||r-o>t[s]-t[u]?t[s]-t[u]:0===e?0:r-o}({thumbWrapper:o,thumbOffsetPosition:c,thumbScrollDimension:l,offsetDimension:u});p.start({from:{[i]:a},to:{[i]:"prev"===t&&d<0?0:d},onChange:({value:e})=>{"x"===i?h.current.scrollLeft=e.x:h.current.scrollTop=e.y}})}}}}}const y=o(void 0);function C({items:r,withLoop:i=!1,draggingSlideTreshold:o,springConfig:s=d.default,shouldResizeOnWindowResize:c=!0,withThumbs:f=!1,enableThumbsWrapperScroll:m=!0,carouselSlideAxis:p="x",thumbsSlideAxis:w="x",prepareThumbsData:C,initialActiveItem:S=0,initialStartingPosition:I="start",disableGestures:W=!1,gutter:A=0,startEndGutter:E=0,touchAction:N,slideAmount:F,freeScroll:L=!1,CustomThumbsWrapperComponent:D,enableFreeScrollDrag:O,itemsPerSlide:R=1,slideType:P="fixed"}){const j=t(!0),M=t("initial"),$=i?r.length===R?[...r,...r,...r,...r,...r]:[...r,...r,...r]:r,z=t(S),B=t(null),H=t(null),k=t(!1),q=t(!1),V=t(!1),G=t(0),Y=t(!1),X=t(0),J=t(0),K=t(0),Q=t(r),U=t(o??0),Z=t(R),_=t(A),ee=t(E),te=t(S),ne=t(I);Z.current=R,_.current=A,ee.current=E,te.current=S,ne.current=I,x((()=>{U.current=o||Math.floor(de()/2/2),he()}),[o,R,A,E,S,I]);const[re,ie]=a((()=>({y:0,x:0,config:s,onChange:({value:e})=>{B.current&&L&&(B.current["x"===p?"scrollLeft":"scrollTop"]=Math.abs(e[p]))}})));const oe=u((()=>{if(!B.current)throw new Error("mainCarouselWrapperRef is not available");return B.current.getBoundingClientRect()["x"===p?"width":"height"]}),[p]),ue=u((()=>{const e=H.current?.querySelector(".use-spring-carousel-item");if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===p?"width":"height"]+_.current}),[p]),se=u((()=>re[p].get()),[p,re]),ce=u((()=>ue()*r.length<oe()),[ue,oe,r.length]),le=u((()=>Math.round(Number(H.current?.["x"===p?"scrollWidth":"scrollHeight"])-H.current.getBoundingClientRect()["x"===p?"width":"height"])),[p]),ae=u((()=>0===Ae()),[]),de=u((()=>{if(!H.current)return 0;const e=ue();if("fluid"===P&&"number"==typeof F){if(F<e)throw new Error("slideAmount must be greater than the width of a single item.");return F}return e}),[ue,P,F]),fe=(e,t)=>{const n="x"===p?"left":"top";function o(){return ue()*r.length}function u(r){i?(e.style.top="0px",e.style[n]=`-${r-ee.current}px`):(e.style.left="0px",e.style.top="0px",t&&j.current&&(e.style[n]=`calc(-${t} * 100%)`))}function s(){u(o())}if("fixed"===P){if(Z.current>1)switch(ne.current){default:case"start":s();break;case"center":c=Z.current,u(o()-de()*Math.round((c-1)/2));break;case"end":!function(e){u(o()-de()*Math.round(e-1))}(Z.current)}else s()}else s();var c},he=()=>{if(X.current=window.innerWidth,"fluid"===P){if(ce())return void ie.start({immediate:!0,[p]:0});if(G.current=le(),Y.current){const e=-G.current;ie.start({immediate:!0,[p]:e})}J.current=window.innerWidth}else ie.start({immediate:!0,[p]:-de()*Ae()});G.current=le(),fe(H.current)},me=()=>{window.innerWidth===X.current||L||he()},{useListenToCustomEvent:pe,emitObservable:ge}=g(),{enterFullscreen:xe,exitFullscreen:be,getIsFullscreen:ve}=v({mainCarouselWrapperRef:B,emitObservable:ge,handleResize:me}),{thumbsFragment:we,handleThumbsScroll:Te}=T({withThumbs:f,items:r,thumbsSlideAxis:w,springConfig:s,prepareThumbsData:C,slideType:P,getFluidWrapperScrollValue:le,getSlideValue:de,CustomThumbsWrapperComponent:D});function ye(){if(!B.current)throw new Error("Missing mainCarouselWrapperRef.current");return B.current["x"===p?"scrollLeft":"scrollTop"]}const Ce=h((e=>{const t=e.dragging,n=e.offset["x"===p?0:1],r=e.movement["x"===p?0:1],o=r>U.current,u=r<-U.current,s=e.direction["x"===p?0:1];function c(){e.cancel()}function l(){"fluid"===P?ce()||ae()&&"prev"===Ie()?ie.start({[p]:0}):Y.current&&"next"===Ie()?ie.start({[p]:-G.current}):ie.start({[p]:K.current}):ie.start({[p]:-Ae()*de()})}if(t){Fe()||Ne(!0),ge({eventName:"onDrag",slideActionType:Ie(),...e}),Se(s>0?"prev":"next");if(Math.abs(se())+100>=G.current&&"next"===Ie()&&(Y.current=!0),"prev"===Ie()&&(Y.current=!1),L){if("boolean"==typeof O?O:"function"==typeof O&&O()){if(0===ye()&&"prev"===Ie())return void c();ie.start({from:{[p]:ye()},to:{[p]:-n}})}return}if(ie.start({[p]:n}),(o||u)&&ce()&&"fluid"===P)c(),l();else if(Y.current&&"next"===Ie()&&u)Y.current=!1,c(),ie.start({[p]:-G.current});else{if(u)return c(),void(!i&&Me()?l():ze());if(o)return c(),void(!i&&ae()?l():$e())}}!e.last||u||o||L||(l(),ge({eventName:"onDrag",slideActionType:Ie(),...e}))}),{enabled:!W,from:()=>L?"x"===p?[-ye(),0]:[0,-ye()]:[re.x.get(),re.y.get()]});function Se(e){M.current=e}function Ie(){return M.current}function We(e){z.current=e}function Ae(){return z.current}function Ee(e){q.current=e}function Ne(e){k.current=e}function Fe(){return k.current}function Le(){const e=Ae();return 0===e?r.length-1:e-1}function De(){const e=Ae();return e===r.length-1?0:e+1}function Oe(e){return r.findIndex((t=>t.id===e))}function Re(e){return"number"==typeof e?{from:{[p]:e}}:{}}function Pe(e,t){if("number"==typeof e)return{[p]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[p]:-de()*t}}function je({from:e,to:t=-1,customTo:n,immediate:i=!1,onRest:o=(()=>{})}){i||(We(t),Ee(!0),ge({eventName:"onSlideStartChange",slideActionType:Ie(),nextItem:{index:"fluid"===P?-1:t,id:"fluid"===P?"":r[t].id}})),K.current=Pe(n,t)[p],ie.start({...Re(e),to:Pe(n,t),immediate:i,onRest:e=>{e.finished&&(Ne(!1),Ee(!1),o(),i||ge({eventName:"onSlideChange",slideActionType:Ie(),currentItem:{index:"fluid"===P?-1:Ae(),id:"fluid"===P?"":r[Ae()].id}}))}}),m&&f&&!i&&Te(t,Ie())}function Me(){return Ae()===r.length-1}function $e(){if(Se("prev"),Y.current=!1,"fluid"===P){if(Y.current=!1,ce())return;const e=se()+de()+200;if(L){const e=B.current.scrollLeft-de();je({customTo:e<0?0:e,from:B.current.scrollLeft})}else je(e>=0?i?{from:se()-ue()*r.length,customTo:se()-ue()*r.length+de()}:{customTo:0}:{customTo:se()+de()})}else{if(!i&&0===Ae()||V.current)return;ae()?je({from:se()-de()*r.length,to:r.length-1}):je({to:Le()})}}function ze(){if(Se("next"),"fluid"===P){if(ce())return;const e=Math.abs(se()-de())+100>=G.current;if(L){const e=B.current.scrollLeft+de()>G.current,t=B.current.scrollLeft+de();je({customTo:e?G.current:t,from:B.current.scrollLeft})}else if(i&&Math.abs(se()-de())>=r.length*ue()){const e=ue()*r.length;je({from:se()+e,customTo:se()+e-de()})}else{if(Y.current)return;e?(Y.current=!0,je({customTo:-G.current})):je({customTo:se()-de()})}}else{if(!i&&Ae()===$.length-1||V.current)return;Math.abs(se()-de()+25)>G.current&&!Fe()?Y.current=!0:Y.current?je({to:r.length-Z.current}):Me()?je({from:se()+de()*r.length,to:0}):je({to:De()})}}function Be(e){let t=0;if(t="string"==typeof e?r.findIndex((t=>t.id===e)):e,t>=r.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(t===Ae()||r.length!==Q.current.length&&Ae()<r.length)return;const n=Oe(Q.current[Ae()].id);Se(Oe(r[t].id)>n?"next":"prev"),je({to:t})}b((()=>{if(U.current<0)throw new Error("draggingSlideTreshold must be greater than 0");if(U.current>de()/2)throw new Error(`draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(de()/2)}`);if(Z.current<1)throw new Error("The itemsPerSlide prop can't be less than 1.");if(Z.current>r.length)throw new Error("The itemsPerSlide prop can't be greater than the total length of the items you provide.");if(te.current<0)throw new Error("The initialActiveItem cannot be less than 0.");if(te.current>r.length)throw new Error("The initialActiveItem cannot be greater than the total length of the items you provide.");c||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.")})),b((()=>{function e(){document.hidden?V.current=!0:V.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),b((()=>{j.current=!1,G.current=le(),J.current=window.innerWidth,X.current=window.innerWidth,S>0&&(je({to:S,immediate:!0}),We(S),!i&&H.current&&(H.current.style.top="0px",H.current.style.left="0px"))})),n((()=>{te.current<r.length&&te.current!==z.current&&(je({to:te.current,immediate:!0}),We(te.current))}),[]),n((()=>{if(c)return window.addEventListener("resize",me),()=>{window.removeEventListener("resize",me)}}),[c]),n((()=>{H.current&&("x"===p&&(H.current.style.top="0px"),"y"===p&&(H.current.style.left="0px"))}),[p]),n((()=>{G.current=le();!(r.length===Q.current.length)&&r.length<Q.current.length&&Be(r.length-1),Q.current=r}),[le,r]);const He={useListenToCustomEvent:pe,getIsFullscreen:ve,enterFullscreen:xe,exitFullscreen:be,getIsAnimating:function(){return q.current},getIsDragging:Fe,getIsNextItem:function(e){const t=Oe(e),n=Ae();return i&&n===r.length-1?0===t:t===n+1},getIsPrevItem:function(e){const t=Oe(e),n=Ae();return i&&0===n?t===r.length-1:t===n-1},slideToPrevItem:$e,slideToNextItem:ze,..."fixed"===P?{slideToItem:Be,getIsActiveItem:e=>Oe(e)===Ae(),getCurrentActiveItem:()=>({id:r[Ae()].id,index:Ae()})}:{}},ke=e(y.Provider,Object.assign({value:He},{children:e("div",Object.assign({ref:B,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},L?{onWheel(){re[p].stop()}}:{},{style:{display:"flex",position:"relative",width:"100%",height:"100%",...L?"x"===p?{overflowX:"auto"}:{overflowY:"auto"}:{}}},{children:e(l.div,Object.assign({},Ce(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{Z.current=R,e&&(H.current=e,fe(e,te.current))},style:{display:"flex",position:"relative",touchAction:W?"unset":N||("x"===p?"pan-y":"pan-x"),flexDirection:"x"===p?"row":"column",...function(){const e=`calc(100% - ${2*ee.current}px)`;return{width:"x"===p?e:"100%",height:"y"===p?e:"100%"}}(),...L?{}:re}},{children:$.map((({id:t,renderItem:n},r)=>{return e("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:{display:"flex",position:"relative",...(i=Z.current,"fixed"===P?{..."x"===p?{marginRight:`${_.current}px`}:{marginBottom:`${_.current}px`},flex:`1 0 calc(100% / ${i} - ${_.current*(i-1)/i}px)`}:{..."x"===p?{marginRight:`${_.current}px`}:{marginBottom:`${_.current}px`}})}},{children:n}),`${t}-${r}`);var i}))}),void 0)}),void 0)}),void 0),qe=e(y.Provider,Object.assign({value:He},{children:we}),void 0);return{...He,carouselFragment:ke,thumbsFragment:qe}}function S(){const e=s(y);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e}const I=o(void 0);function W(){const e=s(I);if(!e)throw new Error("useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.");return e}function A({items:n,withLoop:r=!1,withThumbs:i=!1,springConfig:o=d.default,thumbsSlideAxis:u="x",enableThumbsWrapperScroll:s=!0,draggingSlideTreshold:a=50,prepareThumbsData:m,toPrevItemSpringProps:p,toNextItemSpringProps:x,disableGestures:b=!1,CustomThumbsWrapperComponent:w,springAnimationProps:y={initial:{opacity:1,position:"relative"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"relative"},leave:{opacity:0,position:"absolute"}}}){const C=t("next"),S=t(null),W=t(!1),[A,E]=c(0),{emitObservable:N,useListenToCustomEvent:F}=g(),{enterFullscreen:L,exitFullscreen:D,getIsFullscreen:O}=v({emitObservable:N,mainCarouselWrapperRef:S}),{thumbsFragment:R,handleThumbsScroll:P}=T({items:n,withThumbs:i,thumbsSlideAxis:u,springConfig:o,prepareThumbsData:m,CustomThumbsWrapperComponent:w,slideType:"fixed"}),j=h((({last:e,movement:[t]})=>{if(!$()&&e){const e=t>a,i=t<-a,o=0===A,u=A===n.length-1;if(i){if(!r&&u)return;k(),N({eventName:"onLeftSwipe"})}else if(e){if(!r&&o)return;q(),N({eventName:"onRightSwipe"})}}}),{enabled:!b});const M=f(A,{config:o,...function(){const e=H();return"prev"===e&&p?{initial:{...y.initial},from:{...p.from},enter:{...p.enter},leave:{...p.leave}}:"next"===e&&x?{initial:{...y.initial},from:{...x.from},enter:{...x.enter},leave:{...x.leave}}:{initial:{...y.initial},from:{...y.from},enter:{...y.enter},leave:{...y.leave}}}(),onStart:()=>z(!0),keys:null,onRest:e=>{e.finished&&(z(!1),N({eventName:"onSlideChange",slideActionType:H(),currentItem:{index:A,id:n[A].id}}))}})(((t,r)=>e(l.div,Object.assign({style:{...t,flex:"1 0 100%",width:"100%",height:"100%"}},{children:n[r].renderItem}),void 0)));function $(){return W.current}function z(e){W.current=e}function B(e){C.current=e}function H(){return C.current}function k(){const e=A===n.length-1;r?(B("next"),e?(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:0,id:n[0].id}}),E(0)):(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A+1,id:n[A+1].id}}),E(A+1))):e||(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A+1,id:n[A+1].id}}),B("next"),E(A+1))}function q(){const e=0===A;r?(B("prev"),e?(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A-1,id:n[A-1].id}}),E(n.length-1)):(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A-1,id:n[A-1].id}}),E(A-1))):e||(B("prev"),N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A-1,id:n[A-1].id}}),E(A-1))}function V(e){return n.findIndex((t=>t.id===e))}const G={activeItem:A,slideToItem:function(e){let t=0;if(t="string"==typeof e?n.findIndex((t=>t.id===e)):e,t>=n.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(t===A)return;const r=V(n[A].id),o=V(n[t].id);N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:o,id:n[t].id}}),B(o>r?"next":"prev"),E(t),s&&i&&P(t)},slideToNextItem:k,slideToPrevItem:q,enterFullscreen:L,exitFullscreen:D,useListenToCustomEvent:F,getIsNextItem:function(e){const t=V(e);return r&&A===n.length-1?0===t:t===A+1},getIsPrevItem:function(e){const t=V(e);return r&&0===A?t===n.length-1:t===A-1},getIsAnimating:$,getIsFullscreen:O,getIsActiveItem:e=>V(e)===A,getCurrentActiveItem:()=>({id:n[A].id,index:A})};return{carouselFragment:e(I.Provider,Object.assign({value:G},{children:e("div",Object.assign({ref:S},j(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:M}),void 0)}),void 0),thumbsFragment:e(I.Provider,Object.assign({value:G},{children:R}),void 0),...G}}export{C as useSpringCarousel,S as useSpringCarouselContext,A as useTransitionCarousel,W as useTransitionCarouselContext};
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useRef as t,useEffect as n,useLayoutEffect as r,forwardRef as i,createContext as o,useCallback as u,useContext as s,useState as c}from"react";import{animated as l,useSpring as a,config as d,useTransition as f}from"react-spring";import{useDrag as h}from"@use-gesture/react";import{Subject as m}from"rxjs";import p from"screenfull";function g(){const e=t(new m);return{useListenToCustomEvent:function(t){n((()=>{const n=e.current.subscribe(t);return()=>n.unsubscribe()}),[t])},emitObservable:t=>{e.current.next(t)}}}const x="undefined"!=typeof window?r:n;function b(e){const n=t(!1);x((()=>{if(!n.current){const t=e();return n.current=!0,()=>{t&&t()}}}),[])}function v({mainCarouselWrapperRef:e,emitObservable:n,handleResize:r}){const i=t(!1);function o(e){i.current=e}return b((()=>{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(p.isEnabled)return p.on("change",e),()=>{p.isEnabled&&p.off("change",e)}})),{enterFullscreen:function(t){p.isEnabled&&p.request(t||e.current)},exitFullscreen:function(){p.isEnabled&&p.exit()},getIsFullscreen:function(){return i.current}}}const w=i((({children:t,...n},r)=>e(l.div,Object.assign({},n,{ref:r},{children:t}),void 0)));function T({items:n,withThumbs:r,thumbsSlideAxis:i="x",springConfig:o,prepareThumbsData:u,getFluidWrapperScrollValue:s=(()=>0),getSlideValue:c=(()=>0),CustomThumbsWrapperComponent:d,slideType:f}){const h=t(null),[m,p]=a((()=>({x:0,y:0,config:o,onChange:({value:e})=>{h.current&&"fluid"===f&&(h.current["x"===i?"scrollLeft":"scrollTop"]=Math.abs(e[i]))}})));function g(){return h.current["x"===i?"scrollLeft":"scrollTop"]}function x(){return Math.round(Number(h.current?.["x"===i?"scrollWidth":"scrollHeight"])-h.current.getBoundingClientRect()["x"===i?"width":"height"])}function v(){const e=Math.round(s()/c());return x()/e}b((()=>{if(r&&!h.current)throw new Error("The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.")}));const T=d?l(d):w;return{thumbsFragment:r?e(T,Object.assign({ref:h,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{m[i].stop()},style:{display:"flex",flex:1,position:"relative",width:"100%",height:"100%",flexDirection:"x"===i?"row":"column",..."x"===i?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"}}},{children:function(){function e(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return u?u(e(n)):e(n)}().map((({id:t,renderThumb:n})=>{const r=`thumb-${t}`;return e("div",Object.assign({id:r,className:"thumb-item"},{children:n}),r)}))}),void 0):null,handleThumbsScroll:function(e,t){if("fluid"===f){const e=x();if("next"===t){const t=g()+v();p.start({from:{[i]:g()},to:{[i]:t>e?e:t}})}if("prev"===t){const e=g()-v();p.start({from:{[i]:g()},to:{[i]:e<0?0:e}})}}else{const r=h.current.querySelector(`#thumb-${n[e].id}`);if(r){const o=h.current,u="x"===i?"offsetWidth":"offsetHeight",s="x"===i?"scrollLeft":"scrollTop",c=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:r,offsetDimension:u,offsetDirection:"x"===i?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:o,offsetDimension:u}),a=function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:o,scrollDirection:s}),d=function({thumbWrapper:t,thumbOffsetPosition:r,thumbScrollDimension:o,offsetDimension:u}){const s="x"===i?"scrollWidth":"scrollHeight";return e===n.length-1||r-o>t[s]-t[u]?t[s]-t[u]:0===e?0:r-o}({thumbWrapper:o,thumbOffsetPosition:c,thumbScrollDimension:l,offsetDimension:u});p.start({from:{[i]:a},to:{[i]:"prev"===t&&d<0?0:d},onChange:({value:e})=>{"x"===i?h.current.scrollLeft=e.x:h.current.scrollTop=e.y}})}}}}}const y=o(void 0);function C({items:n,withLoop:r=!1,draggingSlideTreshold:i,springConfig:o=d.default,shouldResizeOnWindowResize:s=!0,withThumbs:c=!1,enableThumbsWrapperScroll:f=!0,carouselSlideAxis:m="x",thumbsSlideAxis:p="x",prepareThumbsData:w,initialActiveItem:C=0,initialStartingPosition:S="start",disableGestures:I=!1,gutter:W=0,startEndGutter:A=0,touchAction:E,slideAmount:N,freeScroll:F=!1,CustomThumbsWrapperComponent:L,enableFreeScrollDrag:D,itemsPerSlide:O=1,slideType:R="fixed"}){const P=t(!0),j=t("initial"),M=r?n.length===O?[...n,...n,...n,...n,...n]:[...n,...n,...n]:n,$=t(C),z=t(null),B=t(null),H=t(!1),k=t(!1),q=t(!1),V=t(0),G=t(!1),Y=t(0),X=t(0),J=t(0),K=t(n),Q=t(i??0),U=t(O),Z=t(W),_=t(A),ee=t(C),te=t(S);U.current=O,Z.current=W,_.current=A,ee.current=C,te.current=S,x((()=>{Q.current=i||Math.floor(ae()/2/2),fe()}),[i,O,W,A,C,S]);const[ne,re]=a((()=>({y:0,x:0,config:o,onChange:({value:e})=>{z.current&&F&&(z.current["x"===m?"scrollLeft":"scrollTop"]=Math.abs(e[m]))}})));const ie=u((()=>{if(!z.current)throw new Error("mainCarouselWrapperRef is not available");return z.current.getBoundingClientRect()["x"===m?"width":"height"]}),[m]),oe=u((()=>{const e=B.current?.querySelector(".use-spring-carousel-item");if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===m?"width":"height"]+Z.current}),[m]),ue=u((()=>ne[m].get()),[m,ne]),se=u((()=>oe()*n.length<ie()),[oe,ie,n.length]),ce=u((()=>Math.round(Number(B.current?.["x"===m?"scrollWidth":"scrollHeight"])-B.current.getBoundingClientRect()["x"===m?"width":"height"])),[m]),le=u((()=>0===We()),[]),ae=u((()=>{if(!B.current)return 0;const e=oe();if("fluid"===R&&"number"==typeof N){if(N<e)throw new Error("slideAmount must be greater than the width of a single item.");return N}return e}),[oe,R,N]),de=(e,t)=>{const i="x"===m?"left":"top";function o(){return oe()*n.length}function u(n){r?(e.style.top="0px",e.style[i]=`-${n-_.current}px`):(e.style.left="0px",e.style.top="0px",t&&P.current&&(e.style[i]=`calc(-${t} * 100%)`))}function s(){u(o())}if("fixed"===R){if(U.current>1)switch(te.current){default:case"start":s();break;case"center":c=U.current,u(o()-ae()*Math.round((c-1)/2));break;case"end":!function(e){u(o()-ae()*Math.round(e-1))}(U.current)}else s()}else s();var c},fe=()=>{if(Y.current=window.innerWidth,"fluid"===R){if(se())return void re.start({immediate:!0,[m]:0});if(V.current=ce(),G.current){const e=-V.current;re.start({immediate:!0,[m]:e})}X.current=window.innerWidth}else re.start({immediate:!0,[m]:-ae()*We()});V.current=ce(),de(B.current)},he=()=>{window.innerWidth===Y.current||F||fe()},{useListenToCustomEvent:me,emitObservable:pe}=g(),{enterFullscreen:ge,exitFullscreen:xe,getIsFullscreen:be}=v({mainCarouselWrapperRef:z,emitObservable:pe,handleResize:he}),{thumbsFragment:ve,handleThumbsScroll:we}=T({withThumbs:c,items:n,thumbsSlideAxis:p,springConfig:o,prepareThumbsData:w,slideType:R,getFluidWrapperScrollValue:ce,getSlideValue:ae,CustomThumbsWrapperComponent:L});function Te(){if(!z.current)throw new Error("Missing mainCarouselWrapperRef.current");return z.current["x"===m?"scrollLeft":"scrollTop"]}const ye=h((e=>{const t=e.dragging,n=e.offset["x"===m?0:1],i=e.movement["x"===m?0:1],o=i>Q.current,u=i<-Q.current,s=e.direction["x"===m?0:1];function c(){e.cancel()}function l(){"fluid"===R?se()||le()&&"prev"===Se()?re.start({[m]:0}):G.current&&"next"===Se()?re.start({[m]:-V.current}):re.start({[m]:J.current}):re.start({[m]:-We()*ae()})}if(t){Ne()||Ee(!0),pe({eventName:"onDrag",slideActionType:Se(),...e}),Ce(s>0?"prev":"next");if(Math.abs(ue())+100>=V.current&&"next"===Se()&&(G.current=!0),"prev"===Se()&&(G.current=!1),F){if("boolean"==typeof D?D:"function"==typeof D&&D()){if(0===Te()&&"prev"===Se())return void c();re.start({from:{[m]:Te()},to:{[m]:-n}})}return}if(re.start({[m]:n}),(o||u)&&se()&&"fluid"===R)c(),l();else if(G.current&&"next"===Se()&&u)G.current=!1,c(),re.start({[m]:-V.current});else{if(u)return c(),void(!r&&je()?l():$e());if(o)return c(),void(!r&&le()?l():Me())}}!e.last||u||o||F||(l(),pe({eventName:"onDrag",slideActionType:Se(),...e}))}),{enabled:!I,from:()=>F?"x"===m?[-Te(),0]:[0,-Te()]:[ne.x.get(),ne.y.get()]});function Ce(e){j.current=e}function Se(){return j.current}function Ie(e){$.current=e}function We(){return $.current}function Ae(e){k.current=e}function Ee(e){H.current=e}function Ne(){return H.current}function Fe(){const e=We();return 0===e?n.length-1:e-1}function Le(){const e=We();return e===n.length-1?0:e+1}function De(e){return n.findIndex((t=>t.id===e))}function Oe(e){return"number"==typeof e?{from:{[m]:e}}:{}}function Re(e,t){if("number"==typeof e)return{[m]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[m]:-ae()*t}}function Pe({from:e,to:t=-1,customTo:r,immediate:i=!1,onRest:o=(()=>{})}){i||(Ie(t),Ae(!0),pe({eventName:"onSlideStartChange",slideActionType:Se(),nextItem:{index:"fluid"===R?-1:t,id:"fluid"===R?"":n[t].id}})),J.current=Re(r,t)[m],re.start({...Oe(e),to:Re(r,t),immediate:i,onRest:e=>{e.finished&&(Ee(!1),Ae(!1),o(),i||pe({eventName:"onSlideChange",slideActionType:Se(),currentItem:{index:"fluid"===R?-1:We(),id:"fluid"===R?"":n[We()].id}}))}}),f&&c&&!i&&we(t,Se())}function je(){return We()===n.length-1}function Me(){if(Ce("prev"),G.current=!1,"fluid"===R){if(G.current=!1,se())return;const e=ue()+ae()+200;if(F){const e=z.current.scrollLeft-ae();Pe({customTo:e<0?0:e,from:z.current.scrollLeft})}else Pe(e>=0?r?{from:ue()-oe()*n.length,customTo:ue()-oe()*n.length+ae()}:{customTo:0}:{customTo:ue()+ae()})}else{if(!r&&0===We()||q.current)return;le()?Pe({from:ue()-ae()*n.length,to:n.length-1}):Pe({to:Fe()})}}function $e(){if(Ce("next"),"fluid"===R){if(se())return;const e=Math.abs(ue()-ae())+100>=V.current;if(F){const e=z.current.scrollLeft+ae()>V.current,t=z.current.scrollLeft+ae();Pe({customTo:e?V.current:t,from:z.current.scrollLeft})}else if(r&&Math.abs(ue()-ae())>=n.length*oe()){const e=oe()*n.length;Pe({from:ue()+e,customTo:ue()+e-ae()})}else{if(G.current)return;e?(G.current=!0,Pe({customTo:-V.current})):Pe({customTo:ue()-ae()})}}else{if(!r&&We()===M.length-1||q.current)return;Math.abs(ue()-ae()+25)>V.current&&!Ne()?G.current=!0:G.current?Pe({to:n.length-U.current}):je()?Pe({from:ue()+ae()*n.length,to:0}):Pe({to:Le()})}}function ze(e){let t=0;if(t="string"==typeof e?n.findIndex((t=>t.id===e)):e,t>=n.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(t===We()||n.length!==K.current.length&&We()<n.length)return;const r=De(K.current[We()].id);Ce(De(n[t].id)>r?"next":"prev"),Pe({to:t})}b((()=>{if(Q.current<0)throw new Error("draggingSlideTreshold must be greater than 0");if(Q.current>ae()/2)throw new Error(`draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(ae()/2)}`);if(U.current<1)throw new Error("The itemsPerSlide prop can't be less than 1.");if(U.current>n.length)throw new Error("The itemsPerSlide prop can't be greater than the total length of the items you provide.");if(ee.current<0)throw new Error("The initialActiveItem cannot be less than 0.");if(ee.current>n.length)throw new Error("The initialActiveItem cannot be greater than the total length of the items you provide.");s||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.")})),b((()=>{function e(){document.hidden?q.current=!0:q.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),b((()=>{P.current=!1,V.current=ce(),X.current=window.innerWidth,Y.current=window.innerWidth,C>0&&(Pe({to:C,immediate:!0}),Ie(C),!r&&B.current&&(B.current.style.top="0px",B.current.style.left="0px"))})),x((()=>{ee.current<n.length&&ee.current!==$.current&&(Pe({to:ee.current,immediate:!0}),Ie(ee.current))}),[]),x((()=>{if(s)return window.addEventListener("resize",he),()=>{window.removeEventListener("resize",he)}}),[s]),x((()=>{B.current&&("x"===m&&(B.current.style.top="0px"),"y"===m&&(B.current.style.left="0px"))}),[m]),x((()=>{V.current=ce();!(n.length===K.current.length)&&n.length<K.current.length&&ze(n.length-1),K.current=n}),[ce,n]);const Be={useListenToCustomEvent:me,getIsFullscreen:be,enterFullscreen:ge,exitFullscreen:xe,getIsAnimating:function(){return k.current},getIsDragging:Ne,getIsNextItem:function(e){const t=De(e),i=We();return r&&i===n.length-1?0===t:t===i+1},getIsPrevItem:function(e){const t=De(e),i=We();return r&&0===i?t===n.length-1:t===i-1},slideToPrevItem:Me,slideToNextItem:$e,..."fixed"===R?{slideToItem:ze,getIsActiveItem:e=>De(e)===We(),getCurrentActiveItem:()=>({id:n[We()].id,index:We()})}:{}},He=e(y.Provider,Object.assign({value:Be},{children:e("div",Object.assign({ref:z,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},F?{onWheel(){ne[m].stop()}}:{},{style:{display:"flex",position:"relative",width:"100%",height:"100%",...F?"x"===m?{overflowX:"auto"}:{overflowY:"auto"}:{}}},{children:e(l.div,Object.assign({},ye(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{U.current=O,e&&(B.current=e,de(e,ee.current))},style:{display:"flex",position:"relative",touchAction:I?"unset":E||("x"===m?"pan-y":"pan-x"),flexDirection:"x"===m?"row":"column",...function(){const e=`calc(100% - ${2*_.current}px)`;return{width:"x"===m?e:"100%",height:"y"===m?e:"100%"}}(),...F?{}:ne}},{children:M.map((({id:t,renderItem:n},r)=>{return e("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:{display:"flex",position:"relative",...(i=U.current,"fixed"===R?{..."x"===m?{marginRight:`${Z.current}px`}:{marginBottom:`${Z.current}px`},flex:`1 0 calc(100% / ${i} - ${Z.current*(i-1)/i}px)`}:{..."x"===m?{marginRight:`${Z.current}px`}:{marginBottom:`${Z.current}px`}})}},{children:n}),`${t}-${r}`);var i}))}),void 0)}),void 0)}),void 0),ke=e(y.Provider,Object.assign({value:Be},{children:ve}),void 0);return{...Be,carouselFragment:He,thumbsFragment:ke}}function S(){const e=s(y);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e}const I=o(void 0);function W(){const e=s(I);if(!e)throw new Error("useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.");return e}function A({items:n,withLoop:r=!1,withThumbs:i=!1,springConfig:o=d.default,thumbsSlideAxis:u="x",enableThumbsWrapperScroll:s=!0,draggingSlideTreshold:a=50,prepareThumbsData:m,toPrevItemSpringProps:p,toNextItemSpringProps:x,disableGestures:b=!1,CustomThumbsWrapperComponent:w,springAnimationProps:y={initial:{opacity:1,position:"relative"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"relative"},leave:{opacity:0,position:"absolute"}}}){const C=t("next"),S=t(null),W=t(!1),[A,E]=c(0),{emitObservable:N,useListenToCustomEvent:F}=g(),{enterFullscreen:L,exitFullscreen:D,getIsFullscreen:O}=v({emitObservable:N,mainCarouselWrapperRef:S}),{thumbsFragment:R,handleThumbsScroll:P}=T({items:n,withThumbs:i,thumbsSlideAxis:u,springConfig:o,prepareThumbsData:m,CustomThumbsWrapperComponent:w,slideType:"fixed"}),j=h((({last:e,movement:[t]})=>{if(!$()&&e){const e=t>a,i=t<-a,o=0===A,u=A===n.length-1;if(i){if(!r&&u)return;k(),N({eventName:"onLeftSwipe"})}else if(e){if(!r&&o)return;q(),N({eventName:"onRightSwipe"})}}}),{enabled:!b});const M=f(A,{config:o,...function(){const e=H();return"prev"===e&&p?{initial:{...y.initial},from:{...p.from},enter:{...p.enter},leave:{...p.leave}}:"next"===e&&x?{initial:{...y.initial},from:{...x.from},enter:{...x.enter},leave:{...x.leave}}:{initial:{...y.initial},from:{...y.from},enter:{...y.enter},leave:{...y.leave}}}(),onStart:()=>z(!0),keys:null,onRest:e=>{e.finished&&(z(!1),N({eventName:"onSlideChange",slideActionType:H(),currentItem:{index:A,id:n[A].id}}))}})(((t,r)=>e(l.div,Object.assign({style:{...t,flex:"1 0 100%",width:"100%",height:"100%"}},{children:n[r].renderItem}),void 0)));function $(){return W.current}function z(e){W.current=e}function B(e){C.current=e}function H(){return C.current}function k(){const e=A===n.length-1;r?(B("next"),e?(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:0,id:n[0].id}}),E(0)):(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A+1,id:n[A+1].id}}),E(A+1))):e||(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A+1,id:n[A+1].id}}),B("next"),E(A+1))}function q(){const e=0===A;r?(B("prev"),e?(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A-1,id:n[A-1].id}}),E(n.length-1)):(N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A-1,id:n[A-1].id}}),E(A-1))):e||(B("prev"),N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:A-1,id:n[A-1].id}}),E(A-1))}function V(e){return n.findIndex((t=>t.id===e))}const G={activeItem:A,slideToItem:function(e){let t=0;if(t="string"==typeof e?n.findIndex((t=>t.id===e)):e,t>=n.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(t===A)return;const r=V(n[A].id),o=V(n[t].id);N({eventName:"onSlideStartChange",slideActionType:H(),nextItem:{index:o,id:n[t].id}}),B(o>r?"next":"prev"),E(t),s&&i&&P(t)},slideToNextItem:k,slideToPrevItem:q,enterFullscreen:L,exitFullscreen:D,useListenToCustomEvent:F,getIsNextItem:function(e){const t=V(e);return r&&A===n.length-1?0===t:t===A+1},getIsPrevItem:function(e){const t=V(e);return r&&0===A?t===n.length-1:t===A-1},getIsAnimating:$,getIsFullscreen:O,getIsActiveItem:e=>V(e)===A,getCurrentActiveItem:()=>({id:n[A].id,index:A})};return{carouselFragment:e(I.Provider,Object.assign({value:G},{children:e("div",Object.assign({ref:S},j(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:M}),void 0)}),void 0),thumbsFragment:e(I.Provider,Object.assign({value:G},{children:R}),void 0),...G}}export{C as useSpringCarousel,S as useSpringCarouselContext,A as useTransitionCarousel,W as useTransitionCarouselContext};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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 { EventsObservableProps, ObservableCallbackFn, EmitObservableFn } from '../types'\n\nexport function useCustomEventsModule() {\n const eventsObserverRef = useRef(new Subject<EventsObservableProps>())\n\n function useListenToCustomEvent(fn: ObservableCallbackFn) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, 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 = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn\n handleResize?(): void\n}\n\nexport function useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule) {\n const isFullscreen = useRef(false)\n\n 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 { forwardRef, HTMLAttributes, 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 CustomThumbsWrapperComponent?: UseSpringCarouselProps['CustomThumbsWrapperComponent']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\ntype WrapperProps = {\n children: React.ReactNode\n} & HTMLAttributes<HTMLDivElement>\n\nconst InternalWrapper = forwardRef<HTMLDivElement, WrapperProps>(\n ({ children, ...rest }, ref) => {\n return (\n <animated.div {...rest} ref={ref}>\n {children}\n </animated.div>\n )\n },\n)\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n CustomThumbsWrapperComponent,\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 Wrapper = CustomThumbsWrapperComponent\n ? animated(CustomThumbsWrapperComponent)\n : InternalWrapper\n\n const thumbsFragment = withThumbs ? (\n <Wrapper\n ref={internalThumbsWrapperRef}\n className=\"use-spring-carousel-thumbs-wrapper\"\n onWheel={() => {\n thumbListStyles[thumbsSlideAxis].stop()\n }}\n style={{\n display: 'flex',\n flex: 1,\n position: 'relative',\n 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 </Wrapper>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useCallback, useContext, useEffect } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from '../modules'\nimport {\n SlideToItemFnProps,\n SlideActionType,\n UseSpringDafaultTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n} from '../types/useSpringCarousel'\nimport { UseSpringFluidTypeReturnProps } from 'react-spring-carousel'\n\nconst UseSpringCarouselContext = createContext<\n (UseSpringFluidTypeReturnProps | UseSpringDafaultTypeReturnProps) | undefined\n>(undefined)\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition = 'start',\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n CustomThumbsWrapperComponent,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps) {\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')\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\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\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 ])\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxis])\n }\n },\n }))\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n const getMainCarouselWrapperWidth = useCallback(() => {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ]\n }, [carouselSlideAxis])\n const getCarouselItemWidth = useCallback(() => {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }, [carouselSlideAxis])\n const getCurrentSlidedValue = useCallback(() => {\n return carouselStyles[carouselSlideAxis].get()\n }, [carouselSlideAxis, carouselStyles])\n const getIfItemsNotFillTheCarousel = useCallback(() => {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }, [getCarouselItemWidth, getMainCarouselWrapperWidth, items.length])\n const getFluidWrapperScrollValue = useCallback(() => {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }, [carouselSlideAxis])\n const getIsFirstItem = useCallback(() => {\n return getCurrentActiveItem() === 0\n }, [])\n const getSlideValue = useCallback(() => {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (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 }, [getCarouselItemWidth, slideType, slideAmount])\n const adjustCarouselWrapperPosition = (\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) => {\n const positionProperty = carouselSlideAxis === '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 const resize = () => {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: 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 [carouselSlideAxis]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n const handleResize = () => {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n CustomThumbsWrapperComponent,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n 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[carouselSlideAxis === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxis === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxis === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxis]: 0,\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: prevSlidedValue.current,\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: -(getCurrentActiveItem() * getSlideValue()),\n })\n }\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n\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 if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n from: {\n [carouselSlideAxis]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxis]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: movement,\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 [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem()\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem()\n }\n return\n }\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 from: () => {\n if (freeScroll) {\n if (carouselSlideAxis === '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 [carouselSlideAxis]: 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 [carouselSlideAxis]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxis]: -(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 }: 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\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\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() {\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 })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n })\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n })\n }\n }\n }\n function slideToNextItem() {\n setSlideActionType('next')\n\n if (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 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 })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n 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 })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n })\n }\n }\n }\n // 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 ...(carouselSlideAxis === '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 ...(carouselSlideAxis === '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: carouselSlideAxis === 'x' ? percentValue : '100%',\n height: carouselSlideAxis === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxis === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxis].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxis === '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 (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\n useEffect(() => {\n if (\n initialActiveItemRef.current < items.length &&\n initialActiveItemRef.current !== activeItem.current\n ) {\n slideToItem({\n to: initialActiveItemRef.current,\n immediate: true,\n })\n setActiveItem(initialActiveItemRef.current)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n useEffect(() => {\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 useEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxis === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxis === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useEffect(() => {\n 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 slideToNextItem,\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 itemsPerSlideRef.current = itemsPerSlide\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n const carouselFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxis === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </UseSpringCarouselContext.Provider>\n )\n const thumbsFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseSpringCarouselContext.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext() {\n const context = useContext(UseSpringCarouselContext)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context\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 CustomThumbsWrapperComponent,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'relative',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'relative',\n },\n leave: {\n opacity: 0,\n position: 'absolute',\n },\n },\n}: UseTransitionCarouselProps) {\n const slideActionType = useRef<SlideActionType>('next')\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const isAnimating = useRef(false)\n const [activeItem, setActiveItem] = useState(0)\n\n const { emitObservable, useListenToCustomEvent } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items: items as ReactSpringCarouselItemWithThumbs[],\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n CustomThumbsWrapperComponent,\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 keys: null,\n onRest: val => {\n if (val.finished) {\n setIsAnimating(false)\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: activeItem,\n id: items[activeItem].id,\n },\n })\n }\n },\n })\n const itemsFragment = transitions((styles, item) => (\n <animated.div\n style={{\n ...styles,\n flex: '1 0 100%',\n width: '100%',\n height: '100%',\n }}\n >\n {items[item].renderItem}\n </animated.div>\n ))\n\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (itemIndex === activeItem) {\n return\n }\n\n const currentItem = findItemIndex(items[activeItem].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: newActiveItem,\n id: items[itemIndex].id,\n },\n })\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n setActiveItem(itemIndex)\n\n if (enableThumbsWrapperScroll && withThumbs) {\n handleThumbsScroll(itemIndex)\n }\n }\n function slideToNextItem() {\n const isLastItem = activeItem === items.length - 1\n\n if (withLoop) {\n setSlideActionType('next')\n if (isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: 0,\n id: items[0].id,\n },\n })\n setActiveItem(0)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setActiveItem(activeItem + 1)\n }\n } else {\n if (!isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setSlideActionType('next')\n setActiveItem(activeItem + 1)\n }\n }\n }\n function slideToPrevItem() {\n const isFirstItem = activeItem === 0\n\n if (withLoop) {\n setSlideActionType('prev')\n if (isFirstItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(items.length - 1)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n } else {\n if (!isFirstItem) {\n setSlideActionType('prev')\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n }\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n\n return itemIndex === activeItem - 1\n }\n\n const contextProps: UseTransitionCarouselContextProps = {\n activeItem,\n slideToItem,\n slideToNextItem,\n slideToPrevItem,\n enterFullscreen,\n exitFullscreen,\n useListenToCustomEvent,\n getIsNextItem,\n getIsPrevItem,\n getIsAnimating,\n getIsFullscreen,\n getIsActiveItem: id => {\n return findItemIndex(id) === activeItem\n },\n getCurrentActiveItem: () => ({\n id: items[activeItem].id,\n index: activeItem,\n }),\n }\n\n const carouselFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n {...bindSwipe()}\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n }}\n >\n {itemsFragment}\n </div>\n </UseTransitionCarouselContext.Provider>\n )\n\n const thumbsFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseTransitionCarouselContext.Provider>\n )\n\n return {\n carouselFragment,\n thumbsFragment,\n ...contextProps,\n }\n}\n\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","InternalWrapper","forwardRef","children","rest","ref","_jsx","animated","div","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","getFluidWrapperScrollValue","getSlideValue","CustomThumbsWrapperComponent","slideType","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","Wrapper","thumbsFragment","className","onWheel","stop","style","display","flex","position","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","UseSpringCarouselContext","createContext","undefined","useSpringCarousel","withLoop","draggingSlideTreshold","default","shouldResizeOnWindowResize","enableThumbsWrapperScroll","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","floor","resize","carouselStyles","setCarouselStyles","getMainCarouselWrapperWidth","useCallback","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","setEndPosition","innerWidth","immediate","_thumbsFragment","getWrapperScrollDirection","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","resetAnimation","getSlideActionType","getIsDragging","setIsDragging","setSlideActionType","getIsLastItem","slideToNextItem","slideToPrevItem","last","enabled","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","getFromValue","getToValue","customTo","slideToItem","onRest","nextItem","index","finished","currentItem","nextPrevValue","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","Provider","percentValue","getAnimatedWrapperStyles","renderItem","_itemsPerSlide","marginRight","marginBottom","useSpringCarouselContext","context","useContext","UseTransitionCarouselContext","useTransitionCarouselContext","useTransitionCarousel","toPrevItemSpringProps","toNextItemSpringProps","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","keys","transitions","styles","newActiveItem","overflow"],"mappings":"kYAIgBA,IACd,MAAMC,EAAoBC,EAAO,IAAIC,GAarC,MAAO,CACLC,uBAZF,SAAgCC,GAC9BC,GAAU,KACR,MAAMC,EAAYN,EAAkBO,QAAQD,UAAUF,GACtD,MAAO,IAAME,EAAUE,gBACtB,CAACJ,KASJK,eANuCC,IACvCV,EAAkBO,QAAQI,KAAKD,KCXnC,MAAME,EACc,oBAAXC,OAAyBC,EAAkBT,EAEpD,SAASU,EAAmBC,GAC1B,MAAMC,EAAYhB,GAAO,GAEzBW,GAA0B,KACxB,IAAKK,EAAUV,QAAS,CACtB,MAAMW,EAAQF,IAGd,OAFAC,EAAUV,SAAU,EAEb,KACLW,GAASA,QAIZ,aCTWC,GAAoBC,uBAClCA,EAAsBX,eACtBA,EAAcY,aACdA,IAEA,MAAMC,EAAerB,GAAO,GAkC5B,SAASsB,EAAgBC,GACvBF,EAAaf,QAAUiB,EAiBzB,OAlDAT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MoD,GAAYL,IAC9C+L,EAAgB/D,EAAc/K,EAAMgM,GAAWjJ,IAErDtF,EAAe,CACbmB,UAAW,qBACXuH,gBAAiB2D,IACjByB,SAAU,CACRC,MAAOsD,EACP/L,GAAI/C,EAAMgM,GAAWjJ,MAKvBkH,EADE6E,EAAgBpD,EACC,OAEA,QAGrBlB,EAAcwB,GAEV1G,GAA6BrF,GAC/BkD,EAAmB6I,IA8GrB7B,gBAAAA,EACAC,gBAAAA,EACAnL,gBAAAA,EACAG,eAAAA,EACAjC,uBAAAA,EACAuP,cA3BF,SAAuB3J,GACrB,MAAMiJ,EAAYjB,EAAchI,GAEhC,OAAImC,GAAY9B,IAAepD,EAAM0E,OAAS,EACvB,IAAdsH,EAGFA,IAAc5I,EAAa,GAqBlCuJ,cAnBF,SAAuB5J,GACrB,MAAMiJ,EAAYjB,EAAchI,GAEhC,OAAImC,GAA2B,IAAf9B,EACP4I,IAAchM,EAAM0E,OAAS,EAG/BsH,IAAc5I,EAAa,GAalCqJ,eAAAA,EACAnN,gBAAAA,EACAsN,gBAAiB7J,GACRgI,EAAchI,KAAQK,EAE/B6E,qBAAsB,MACpBlF,GAAI/C,EAAMoD,GAAYL,GACtByI,MAAOpI,KA4BX,MAAO,CACLyJ,iBAxBAjN,EAAC4N,EAA6BV,wBAAS7L,MAAOuL,aAC5C5M,uBACED,IAAKvB,GACD+P,KACJlM,MAAO,CACLC,QAAS,OACTE,SAAU,WACVC,MAAO,OACPC,OAAQ,OACRyM,SAAU,qBAGXR,sBAaL1M,eAPAjC,EAAC4N,EAA6BV,wBAAS7L,MAAOuL,aAC3CzD,eAOAyD"}
|
|
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 { EventsObservableProps, ObservableCallbackFn, EmitObservableFn } from '../types'\n\nexport function useCustomEventsModule() {\n const eventsObserverRef = useRef(new Subject<EventsObservableProps>())\n\n function useListenToCustomEvent(fn: ObservableCallbackFn) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, 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 = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn\n handleResize?(): void\n}\n\nexport function useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule) {\n const isFullscreen = useRef(false)\n\n 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 { forwardRef, HTMLAttributes, 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 CustomThumbsWrapperComponent?: UseSpringCarouselProps['CustomThumbsWrapperComponent']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\ntype WrapperProps = {\n children: React.ReactNode\n} & HTMLAttributes<HTMLDivElement>\n\nconst InternalWrapper = forwardRef<HTMLDivElement, WrapperProps>(\n ({ children, ...rest }, ref) => {\n return (\n <animated.div {...rest} ref={ref}>\n {children}\n </animated.div>\n )\n },\n)\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n CustomThumbsWrapperComponent,\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 Wrapper = CustomThumbsWrapperComponent\n ? animated(CustomThumbsWrapperComponent)\n : InternalWrapper\n\n const thumbsFragment = withThumbs ? (\n <Wrapper\n ref={internalThumbsWrapperRef}\n className=\"use-spring-carousel-thumbs-wrapper\"\n onWheel={() => {\n thumbListStyles[thumbsSlideAxis].stop()\n }}\n style={{\n display: 'flex',\n flex: 1,\n position: 'relative',\n 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 </Wrapper>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useCallback, 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 UseSpringDafaultTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n} from '../types/useSpringCarousel'\nimport { UseSpringFluidTypeReturnProps } from 'react-spring-carousel'\n\nconst UseSpringCarouselContext = createContext<\n (UseSpringFluidTypeReturnProps | UseSpringDafaultTypeReturnProps) | undefined\n>(undefined)\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition = 'start',\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n CustomThumbsWrapperComponent,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps) {\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')\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\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\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 ])\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxis])\n }\n },\n }))\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n const getMainCarouselWrapperWidth = useCallback(() => {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ]\n }, [carouselSlideAxis])\n const getCarouselItemWidth = useCallback(() => {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }, [carouselSlideAxis])\n const getCurrentSlidedValue = useCallback(() => {\n return carouselStyles[carouselSlideAxis].get()\n }, [carouselSlideAxis, carouselStyles])\n const getIfItemsNotFillTheCarousel = useCallback(() => {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }, [getCarouselItemWidth, getMainCarouselWrapperWidth, items.length])\n const getFluidWrapperScrollValue = useCallback(() => {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }, [carouselSlideAxis])\n const getIsFirstItem = useCallback(() => {\n return getCurrentActiveItem() === 0\n }, [])\n const getSlideValue = useCallback(() => {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (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 }, [getCarouselItemWidth, slideType, slideAmount])\n const adjustCarouselWrapperPosition = (\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) => {\n const positionProperty = carouselSlideAxis === '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 const resize = () => {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: 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 [carouselSlideAxis]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxis]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n const handleResize = () => {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n CustomThumbsWrapperComponent,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n 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[carouselSlideAxis === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxis === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxis === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxis]: 0,\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: prevSlidedValue.current,\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: -(getCurrentActiveItem() * getSlideValue()),\n })\n }\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n\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 if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n from: {\n [carouselSlideAxis]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxis]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxis]: movement,\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 [carouselSlideAxis]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem()\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem()\n }\n return\n }\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 from: () => {\n if (freeScroll) {\n if (carouselSlideAxis === '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 [carouselSlideAxis]: 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 [carouselSlideAxis]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxis]: -(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 }: 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\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\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() {\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 })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n })\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n })\n }\n }\n }\n function slideToNextItem() {\n setSlideActionType('next')\n\n if (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 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 })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n 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 })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n })\n }\n }\n }\n // 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 ...(carouselSlideAxis === '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 ...(carouselSlideAxis === '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: carouselSlideAxis === 'x' ? percentValue : '100%',\n height: carouselSlideAxis === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxis === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxis].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxis === '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 (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 (\n initialActiveItemRef.current < items.length &&\n initialActiveItemRef.current !== activeItem.current\n ) {\n slideToItem({\n to: initialActiveItemRef.current,\n immediate: true,\n })\n setActiveItem(initialActiveItemRef.current)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\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 (carouselSlideAxis === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxis === '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 slideToNextItem,\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 itemsPerSlideRef.current = itemsPerSlide\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n const carouselFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxis === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </UseSpringCarouselContext.Provider>\n )\n const thumbsFragment = (\n <UseSpringCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseSpringCarouselContext.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext() {\n const context = useContext(UseSpringCarouselContext)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context\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 CustomThumbsWrapperComponent,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'relative',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'relative',\n },\n leave: {\n opacity: 0,\n position: 'absolute',\n },\n },\n}: UseTransitionCarouselProps) {\n const slideActionType = useRef<SlideActionType>('next')\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const isAnimating = useRef(false)\n const [activeItem, setActiveItem] = useState(0)\n\n const { emitObservable, useListenToCustomEvent } = useCustomEventsModule()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items: items as ReactSpringCarouselItemWithThumbs[],\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n CustomThumbsWrapperComponent,\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 keys: null,\n onRest: val => {\n if (val.finished) {\n setIsAnimating(false)\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: activeItem,\n id: items[activeItem].id,\n },\n })\n }\n },\n })\n const itemsFragment = transitions((styles, item) => (\n <animated.div\n style={{\n ...styles,\n flex: '1 0 100%',\n width: '100%',\n height: '100%',\n }}\n >\n {items[item].renderItem}\n </animated.div>\n ))\n\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (itemIndex === activeItem) {\n return\n }\n\n const currentItem = findItemIndex(items[activeItem].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: newActiveItem,\n id: items[itemIndex].id,\n },\n })\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n setActiveItem(itemIndex)\n\n if (enableThumbsWrapperScroll && withThumbs) {\n handleThumbsScroll(itemIndex)\n }\n }\n function slideToNextItem() {\n const isLastItem = activeItem === items.length - 1\n\n if (withLoop) {\n setSlideActionType('next')\n if (isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: 0,\n id: items[0].id,\n },\n })\n setActiveItem(0)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setActiveItem(activeItem + 1)\n }\n } else {\n if (!isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setSlideActionType('next')\n setActiveItem(activeItem + 1)\n }\n }\n }\n function slideToPrevItem() {\n const isFirstItem = activeItem === 0\n\n if (withLoop) {\n setSlideActionType('prev')\n if (isFirstItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(items.length - 1)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n } else {\n if (!isFirstItem) {\n setSlideActionType('prev')\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n }\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n\n return itemIndex === activeItem - 1\n }\n\n const contextProps: UseTransitionCarouselContextProps = {\n activeItem,\n slideToItem,\n slideToNextItem,\n slideToPrevItem,\n enterFullscreen,\n exitFullscreen,\n useListenToCustomEvent,\n getIsNextItem,\n getIsPrevItem,\n getIsAnimating,\n getIsFullscreen,\n getIsActiveItem: id => {\n return findItemIndex(id) === activeItem\n },\n getCurrentActiveItem: () => ({\n id: items[activeItem].id,\n index: activeItem,\n }),\n }\n\n const carouselFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n {...bindSwipe()}\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n }}\n >\n {itemsFragment}\n </div>\n </UseTransitionCarouselContext.Provider>\n )\n\n const thumbsFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseTransitionCarouselContext.Provider>\n )\n\n return {\n carouselFragment,\n thumbsFragment,\n ...contextProps,\n }\n}\n\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","InternalWrapper","forwardRef","children","rest","ref","_jsx","animated","div","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","getFluidWrapperScrollValue","getSlideValue","CustomThumbsWrapperComponent","slideType","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","Wrapper","thumbsFragment","className","onWheel","stop","style","display","flex","position","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","UseSpringCarouselContext","createContext","undefined","useSpringCarousel","withLoop","draggingSlideTreshold","default","shouldResizeOnWindowResize","enableThumbsWrapperScroll","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","floor","resize","carouselStyles","setCarouselStyles","getMainCarouselWrapperWidth","useCallback","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","setEndPosition","innerWidth","immediate","_thumbsFragment","getWrapperScrollDirection","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","resetAnimation","getSlideActionType","getIsDragging","setIsDragging","setSlideActionType","getIsLastItem","slideToNextItem","slideToPrevItem","last","enabled","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","getFromValue","getToValue","customTo","slideToItem","onRest","nextItem","index","finished","currentItem","nextPrevValue","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","Provider","percentValue","getAnimatedWrapperStyles","renderItem","_itemsPerSlide","marginRight","marginBottom","useSpringCarouselContext","context","useContext","UseTransitionCarouselContext","useTransitionCarouselContext","useTransitionCarousel","toPrevItemSpringProps","toNextItemSpringProps","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig","onStart","keys","transitions","styles","newActiveItem","overflow"],"mappings":"kYAIgBA,IACd,MAAMC,EAAoBC,EAAO,IAAIC,GAarC,MAAO,CACLC,uBAZF,SAAgCC,GAC9BC,GAAU,KACR,MAAMC,EAAYN,EAAkBO,QAAQD,UAAUF,GACtD,MAAO,IAAME,EAAUE,gBACtB,CAACJ,KASJK,eANuCC,IACvCV,EAAkBO,QAAQI,KAAKD,KCXnC,MAAME,EACc,oBAAXC,OAAyBC,EAAkBT,EAEpD,SAASU,EAAmBC,GAC1B,MAAMC,EAAYhB,GAAO,GAEzBW,GAA0B,KACxB,IAAKK,EAAUV,QAAS,CACtB,MAAMW,EAAQF,IAGd,OAFAC,EAAUV,SAAU,EAEb,KACLW,GAASA,QAIZ,aCTWC,GAAoBC,uBAClCA,EAAsBX,eACtBA,EAAcY,aACdA,IAEA,MAAMC,EAAerB,GAAO,GAkC5B,SAASsB,EAAgBC,GACvBF,EAAaf,QAAUiB,EAiBzB,OAlDAT,GAAmB,KACjB,SA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YL,IAC9C+L,EAAgB/D,EAAc/K,EAAMgM,GAAWjJ,IAErDtF,EAAe,CACbmB,UAAW,qBACXuH,gBAAiB2D,IACjByB,SAAU,CACRC,MAAOsD,EACP/L,GAAI/C,EAAMgM,GAAWjJ,MAKvBkH,EADE6E,EAAgBpD,EACC,OAEA,QAGrBlB,EAAcwB,GAEV1G,GAA6BrF,GAC/BkD,EAAmB6I,IA8GrB7B,gBAAAA,EACAC,gBAAAA,EACAnL,gBAAAA,EACAG,eAAAA,EACAjC,uBAAAA,EACAuP,cA3BF,SAAuB3J,GACrB,MAAMiJ,EAAYjB,EAAchI,GAEhC,OAAImC,GAAY9B,IAAepD,EAAM0E,OAAS,EACvB,IAAdsH,EAGFA,IAAc5I,EAAa,GAqBlCuJ,cAnBF,SAAuB5J,GACrB,MAAMiJ,EAAYjB,EAAchI,GAEhC,OAAImC,GAA2B,IAAf9B,EACP4I,IAAchM,EAAM0E,OAAS,EAG/BsH,IAAc5I,EAAa,GAalCqJ,eAAAA,EACAnN,gBAAAA,EACAsN,gBAAiB7J,GACRgI,EAAchI,KAAQK,EAE/B6E,qBAAsB,MACpBlF,GAAI/C,EAAMoD,GAAYL,GACtByI,MAAOpI,KA4BX,MAAO,CACLyJ,iBAxBAjN,EAAC4N,EAA6BV,wBAAS7L,MAAOuL,aAC5C5M,uBACED,IAAKvB,GACD+P,KACJlM,MAAO,CACLC,QAAS,OACTE,SAAU,WACVC,MAAO,OACPC,OAAQ,OACRyM,SAAU,qBAGXR,sBAaL1M,eAPAjC,EAAC4N,EAA6BV,wBAAS7L,MAAOuL,aAC3CzD,eAOAyD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-spring-carousel",
|
|
3
|
-
"version": "1.9.29-
|
|
3
|
+
"version": "1.9.29-beta94",
|
|
4
4
|
"description": "A new Carousel experience for the web",
|
|
5
5
|
"homepage": "https://react-spring-carousel-js.emilianobucci.com",
|
|
6
6
|
"repository": "https://github.com/Emiliano-Bucci/react-spring-carousel",
|