react-spring-carousel 2.0.17 → 2.0.19
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/index2.js +1 -1
- package/dist/esm/index2.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index2.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{createContext as t,useRef as r,useContext as n}from"react";import{config as i,useSpring as c,animated as o}from"react-spring";import{useDrag as u}from"@use-gesture/react";import{u as s,a as l,b as a,c as f,d}from"./useThumbsModule-0944decf.js";import"rxjs";import"screenfull";const h=t(void 0),g=Object.assign(Object.assign({},i.default),{mass:1,velocity:0});function m({items:t,withLoop:n=!1,draggingSlideTreshold:m,springConfig:v=i.default,shouldResizeOnWindowResize:p=!0,withThumbs:y=!1,enableThumbsWrapperScroll:b=!0,slideWhenThresholdIsReached:x=!0,carouselSlideAxis:w="x",thumbsSlideAxis:T="x",prepareThumbsData:O,initialActiveItem:j=0,initialStartingPosition:I,disableGestures:S=!1,gutter:E=0,startEndGutter:A=0,touchAction:C,slideAmount:R,freeScroll:$=!1,enableFreeScrollDrag:W,itemsPerSlide:L=1,slideType:M="fixed"}){const F=r(!0),N=r("initial"),P=n?t.length===L?[...t,...t,...t,...t,...t]:[...t,...t,...t]:t,z=r(j),D=r(null),B=r(null),k=r(!1),q=r(!1),G=r(!1),V=r(0),Y=r(!1),H=r(0),X=r(0),J=r(0),K=r(t),Q=r(null!=m?m:0),U=r(L),Z=r(E),_=r(A),ee=r(j),te=r(I),re=r(w);U.current=L,Z.current=E,_.current=A,ee.current=j,te.current=I,re.current=w;const[ne,ie]=c((()=>({y:0,x:0,onChange:({value:e})=>{D.current&&$&&(D.current["x"===re.current?"scrollLeft":"scrollTop"]=Math.abs(e[re.current]))}})));function ce(){const e=null===(t=B.current)||void 0===t?void 0:t.querySelector(".use-spring-carousel-item");var t;if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===re.current?"width":"height"]+Z.current}function oe(){return ne[re.current].get()}function ue(){return ce()*t.length<function(){if(!D.current)throw new Error("mainCarouselWrapperRef is not available");return D.current.getBoundingClientRect()["x"===re.current?"width":"height"]}()}function se(){var e;return Math.round(Number(null===(e=B.current)||void 0===e?void 0:e["x"===re.current?"scrollWidth":"scrollHeight"])-B.current.getBoundingClientRect()["x"===re.current?"width":"height"])}function le(){return 0===Ee()}function ae(){if(!B.current)return 0;const e=ce();if("fluid"===M&&"number"==typeof R){if(R<e)throw new Error("slideAmount must be greater than the width of a single item.");return R}return e}function fe(e,r){const i="x"===re.current?"left":"top";function c(){return ce()*t.length}function o(t){n?(e.style.top="0px",e.style[i]=`-${t-_.current}px`):(e.style.left="0px",e.style.top="0px",r&&F.current&&(e.style[i]=`calc(-${r} * 100%)`))}function u(){o(c())}if("fixed"===M){if(U.current>1)switch(te.current){default:case"start":u();break;case"center":s=U.current,o(c()-ae()*Math.round((s-1)/2));break;case"end":!function(e){o(c()-ae()*Math.round(e-1))}(U.current)}else u()}else u();var s}function de(){if(H.current=window.innerWidth,"fluid"===M){if(ue())return void ie.start({immediate:!0,[re.current]:0});if(V.current=se(),Y.current){const e=-V.current;ie.start({immediate:!0,[re.current]:e})}X.current=window.innerWidth}else ie.start({immediate:!0,[re.current]:-ae()*Ee()});V.current=se(),fe(B.current)}function he(){window.innerWidth===H.current||$||de()}s((()=>{Q.current=m||Math.floor(ae()/2/2),de()}),[m,L,E,A,j,I,w,T]);const{useListenToCustomEvent:ge,emitObservable:me}=l(),{enterFullscreen:ve,exitFullscreen:pe,getIsFullscreen:ye}=a({mainCarouselWrapperRef:D,emitObservable:me,handleResize:he}),{thumbsFragment:be,handleThumbsScroll:xe}=f({withThumbs:y,items:t,thumbsSlideAxis:T,springConfig:v,prepareThumbsData:O,slideType:M,getFluidWrapperScrollValue:se,getSlideValue:ae});function we(){if(!D.current)throw new Error("Missing mainCarouselWrapperRef.current");return D.current["x"===re.current?"scrollLeft":"scrollTop"]}function Te(){return"boolean"==typeof W?W:"function"==typeof W&&W()}const Oe=u((e=>{const t=e.dragging,r=e.offset["x"===re.current?0:1],i=e.movement["x"===re.current?0:1],c=i>Q.current,o=i<-Q.current,u=e.direction["x"===re.current?0:1];function s(){e.cancel()}function l(){je(u>0?"prev":"next")}function a(){me(Object.assign({eventName:"onDrag",slideActionType:Ie()},e))}function f(){"fluid"===M?ue()||le()&&"prev"===Ie()?ie.start({[re.current]:0,config:{velocity:e.velocity}}):Y.current&&"next"===Ie()?ie.start({[re.current]:-V.current,config:{velocity:e.velocity}}):ie.start({[re.current]:J.current,config:{velocity:e.velocity}}):ie.start({[re.current]:-Ee()*ae(),config:{velocity:e.velocity}})}function d(){Math.abs(oe())+100>=V.current&&"next"===Ie()&&(Y.current=!0),"prev"===Ie()&&(Y.current=!1)}if($&&Te())return l(),a(),d(),ie.start({from:{[re.current]:we()},to:{[re.current]:-r},config:{velocity:e.velocity}}),0===we()&&"prev"===Ie()?void s():void 0;if(t){if(Re()||Ce(!0),a(),l(),d(),$){if(Te()){if(0===we()&&"prev"===Ie())return void s();ie.start({config:{velocity:e.velocity,friction:50,tension:1e3},from:{[re.current]:we()},to:{[re.current]:-r}})}return}if(ie.start({[re.current]:r,config:{velocity:e.velocity,friction:50,tension:1e3}}),(c||o)&&ue()&&"fluid"===M)s(),f();else if(Y.current&&"next"===Ie()&&o)Y.current=!1,s(),ie.start({[re.current]:-V.current});else if(x){if(o)return s(),void(!n&&Ne()?f():ze(e.velocity));if(c)return s(),void(!n&&le()?f():Pe(e.velocity))}}!e.last||x||!o&&!c||$?!e.last||o||c||$||(f(),me(Object.assign({eventName:"onDrag",slideActionType:Ie()},e))):o?!n&&Ne()?f():ze(e.velocity):c&&(!n&&le()?f():Pe(e.velocity))}),{enabled:!S,axis:re.current,from:()=>$?"x"===re.current?[-we(),0]:[0,-we()]:[ne.x.get(),ne.y.get()]});function je(e){N.current=e}function Ie(){return N.current}function Se(e){z.current=e}function Ee(){return z.current}function Ae(e){q.current=e}function Ce(e){k.current=e}function Re(){return k.current}function $e(){const e=Ee();return 0===e?t.length-1:e-1}function We(){const e=Ee();return e===t.length-1?0:e+1}function Le(e){return t.findIndex((t=>t.id===e))}function Me(e,t){if("number"==typeof e)return{[re.current]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[re.current]:-ae()*t}}function Fe({from:e,to:r=-1,customTo:n,immediate:i=!1,onRest:c=(()=>{}),velocity:o}){i||(Se(r),Ae(!0),me({eventName:"onSlideStartChange",slideActionType:Ie(),nextItem:{index:"fluid"===M?-1:r,id:"fluid"===M?"":t[r].id}})),J.current=Me(n,r)[w],ie.start(Object.assign(Object.assign(Object.assign(Object.assign({},function(e){return"number"==typeof e?{from:{[re.current]:e}}:{}}(e)),{to:Me(n,r)}),o?{config:Object.assign(Object.assign({},g),{velocity:o,friction:void 0,tension:void 0})}:{config:Object.assign({velocity:0},v)}),{immediate:i,onRest:e=>{e.finished&&(Ce(!1),Ae(!1),c(),i||me({eventName:"onSlideChange",slideActionType:Ie(),currentItem:{index:"fluid"===M?-1:Ee(),id:"fluid"===M?"":t[Ee()].id}}))}})),b&&y&&!i&&xe(r,Ie())}function Ne(){return Ee()===t.length-1}function Pe(e){if(je("prev"),Y.current=!1,"fluid"===M){if(Y.current=!1,ue())return;const r=oe()+ae()+200;if($){const t=D.current.scrollLeft-ae();Fe({customTo:t<0?0:t,from:D.current.scrollLeft,velocity:e})}else Fe(r>=0?n?{from:oe()-ce()*t.length,velocity:e,customTo:oe()-ce()*t.length+ae()}:{customTo:0,velocity:e}:{customTo:oe()+ae(),velocity:e})}else{if(!n&&0===Ee()||G.current)return;le()?Fe({from:oe()-ae()*t.length,to:t.length-1,velocity:e}):Fe({to:$e(),velocity:e})}}function ze(e){if(je("next"),"fluid"===M){if(ue())return;const r=Math.abs(oe()-ae())+100>=V.current;if($){const t=D.current.scrollLeft+ae()>V.current,r=D.current.scrollLeft+ae();Fe({velocity:e,customTo:t?V.current:r,from:D.current.scrollLeft})}else if(n&&Math.abs(oe()-ae())>=t.length*ce()){const r=ce()*t.length;Fe({from:oe()+r,customTo:oe()+r-ae(),velocity:e})}else{if(Y.current)return;r?(Y.current=!0,Fe({customTo:-V.current,velocity:e})):Fe({customTo:oe()-ae(),velocity:e})}}else{if(!n&&Ee()===P.length-1||G.current)return;Math.abs(oe()-ae()+25)>V.current&&!Re()?Y.current=!0:Y.current?Fe({to:t.length-U.current,velocity:e}):Ne()?Fe({from:oe()+ae()*t.length,to:0,velocity:e}):Fe({to:We(),velocity:e})}}function De(e){let r=0;if(r="string"==typeof e?t.findIndex((t=>t.id===e)):e,r>=t.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(r===Ee()||t.length!==K.current.length&&Ee()<t.length)return;const n=Le(K.current[Ee()].id);je(Le(t[r].id)>n?"next":"prev"),Fe({to:r})}d((()=>{if(L%2==0&&te.current)throw new Error("initialStartingPosition can be only used if itemsPerSlide is an even value.");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>t.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>t.length)throw new Error("The initialActiveItem cannot be greater than the total length of the items you provide.");p||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.")})),d((()=>{function e(){document.hidden?G.current=!0:G.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),d((()=>{F.current=!1,V.current=se(),X.current=window.innerWidth,H.current=window.innerWidth,j>0&&(Fe({to:j,immediate:!0}),Se(j),!n&&B.current&&(B.current.style.top="0px",B.current.style.left="0px"))})),s((()=>{j<t.length&&j!==z.current&&(Fe({to:j,immediate:!0}),Se(j))}),[j]),s((()=>{if(p)return window.addEventListener("resize",he),()=>{window.removeEventListener("resize",he)}}),[p]),s((()=>{B.current&&("x"===re.current&&(B.current.style.top="0px"),"y"===re.current&&(B.current.style.left="0px"))}),[w]),s((()=>{V.current=se();!(t.length===K.current.length)&&t.length<K.current.length&&De(t.length-1),K.current=t}),[se,t]);const Be=Object.assign({useListenToCustomEvent:ge,getIsFullscreen:ye,enterFullscreen:ve,exitFullscreen:pe,getIsAnimating:function(){return q.current},getIsDragging:Re,getIsNextItem:function(e){const r=Le(e),i=Ee();return n&&i===t.length-1?0===r:r===i+1},getIsPrevItem:function(e){const r=Le(e),i=Ee();return n&&0===i?r===t.length-1:r===i-1},slideToPrevItem(){Pe()},slideToNextItem(){ze()}},"fixed"===M?{slideToItem:De,getIsActiveItem:e=>Le(e)===Ee(),getCurrentActiveItem:()=>({id:t[Ee()].id,index:Ee()})}:{});const ke=e(h.Provider,Object.assign({value:Be},{children:e("div",Object.assign({ref:D,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},$?{onWheel(){ne[re.current].stop()}}:{},{style:Object.assign({display:"flex",position:"relative",width:"100%",height:"100%"},$?"x"===re.current?{overflowX:"auto"}:{overflowY:"auto"}:{})},{children:e(o.div,Object.assign({},Oe(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{e&&(B.current=e,fe(e,ee.current))},style:Object.assign(Object.assign(Object.assign({display:"flex",position:"relative",touchAction:S?"unset":C||("x"===re.current?"pan-y":"pan-x"),flexDirection:"x"===re.current?"row":"column"},function(){const e=`calc(100% - ${2*_.current}px)`;return{width:"x"===re.current?e:"100%",height:"y"===re.current?e:"100%"}}()),function(){const e=t.length/L*100,r=100/L,n="x"===re.current?"left":"y",i=Math.floor(50/r);if("fixed"===M){if("center"===te.current)return{[n]:`calc(-${e}% + ${r*i}%)`};if("end"===te.current)return{[n]:`calc(-${e}% + ${r*(2*i)}%)`}}return{[n]:"0px"}}()),$?{}:ne)},{children:P.map((({id:t,renderItem:r},n)=>{return e("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:Object.assign({display:"flex",position:"relative"},(i=U.current,"fixed"===M?Object.assign(Object.assign({},"x"===re.current?{marginRight:`${Z.current}px`}:{marginBottom:`${Z.current}px`}),{flex:`1 0 calc(100% / ${i} - ${Z.current*(i-1)/i}px)`}):Object.assign({},"x"===re.current?{marginRight:`${Z.current}px`}:{marginBottom:`${Z.current}px`})))},{children:r}),`${t}-${n}`);var i}))}))}))})),qe=e(h.Provider,Object.assign({value:Be},{children:be}));return Object.assign(Object.assign({},Be),{carouselFragment:ke,thumbsFragment:qe})}function v(){const e=n(h);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e}export{m as useSpringCarousel,v as useSpringCarouselContext};
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{createContext as t,useRef as r,useContext as n}from"react";import{config as i,useSpring as c,animated as o}from"react-spring";import{useDrag as u}from"@use-gesture/react";import{u as s,a as l,b as a,c as f,d}from"./useThumbsModule-0944decf.js";import"rxjs";import"screenfull";const h=t(void 0),g=Object.assign(Object.assign({},i.default),{mass:1,velocity:0});function m({items:t,withLoop:n=!1,draggingSlideTreshold:m,springConfig:v=i.default,shouldResizeOnWindowResize:p=!0,withThumbs:y=!1,enableThumbsWrapperScroll:b=!0,slideWhenThresholdIsReached:x=!0,carouselSlideAxis:w="x",thumbsSlideAxis:T="x",prepareThumbsData:O,initialActiveItem:j=0,initialStartingPosition:I,disableGestures:S=!1,gutter:E=0,startEndGutter:A=0,touchAction:C,slideAmount:R,freeScroll:$=!1,enableFreeScrollDrag:W,itemsPerSlide:L=1,slideType:M="fixed"}){const F=r(!0),N=r("initial"),P=n?t.length===L?[...t,...t,...t,...t,...t]:[...t,...t,...t]:t,z=r(j),D=r(null),B=r(null),k=r(!1),q=r(!1),G=r(!1),V=r(0),Y=r(!1),H=r(0),X=r(0),J=r(0),K=r(t),Q=r(null!=m?m:0),U=r(L),Z=r(E),_=r(A),ee=r(j),te=r(I),re=r(w);U.current=L,Z.current=E,_.current=A,ee.current=j,te.current=I,re.current=w;const[ne,ie]=c((()=>({y:0,x:0,onChange:({value:e})=>{D.current&&$&&(D.current["x"===re.current?"scrollLeft":"scrollTop"]=Math.abs(e[re.current]))}})));function ce(){const e=null===(t=B.current)||void 0===t?void 0:t.querySelector(".use-spring-carousel-item");var t;if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===re.current?"width":"height"]+Z.current}function oe(){return ne[re.current].get()}function ue(){return ce()*t.length<function(){if(!D.current)throw new Error("mainCarouselWrapperRef is not available");return D.current.getBoundingClientRect()["x"===re.current?"width":"height"]}()}function se(){var e;return Math.round(Number(null===(e=B.current)||void 0===e?void 0:e["x"===re.current?"scrollWidth":"scrollHeight"])-B.current.getBoundingClientRect()["x"===re.current?"width":"height"])}function le(){return 0===Ee()}function ae(){if(!B.current)return 0;const e=ce();if("fluid"===M&&"number"==typeof R){if(R<e)throw new Error("slideAmount must be greater than the width of a single item.");return R}return e}function fe(e,r){const i="x"===re.current?"left":"top";function c(){return ce()*t.length}function o(t){n?(e.style.top="0px",e.style[i]=`-${t-_.current}px`):(e.style.left="0px",e.style.top="0px",r&&F.current&&(e.style[i]=`calc(-${r} * 100%)`))}function u(){o(c())}if("fixed"===M){if(U.current>1)switch(te.current){default:case"start":u();break;case"center":s=U.current,o(c()-ae()*Math.round((s-1)/2));break;case"end":!function(e){o(c()-ae()*Math.round(e-1))}(U.current)}else u()}else u();var s}function de(){if(H.current=window.innerWidth,"fluid"===M){if(ue())return void ie.start({immediate:!0,[re.current]:0});if(V.current=se(),Y.current){const e=-V.current;ie.start({immediate:!0,[re.current]:e})}X.current=window.innerWidth}else ie.start({immediate:!0,[re.current]:-ae()*Ee()});V.current=se(),fe(B.current)}function he(){window.innerWidth===H.current||$||de()}s((()=>{Q.current=m||Math.floor(ae()/2/2),de()}),[m,L,E,A,j,I,w,T]);const{useListenToCustomEvent:ge,emitObservable:me}=l(),{enterFullscreen:ve,exitFullscreen:pe,getIsFullscreen:ye}=a({mainCarouselWrapperRef:D,emitObservable:me,handleResize:he}),{thumbsFragment:be,handleThumbsScroll:xe}=f({withThumbs:y,items:t,thumbsSlideAxis:T,springConfig:v,prepareThumbsData:O,slideType:M,getFluidWrapperScrollValue:se,getSlideValue:ae});function we(){if(!D.current)throw new Error("Missing mainCarouselWrapperRef.current");return D.current["x"===re.current?"scrollLeft":"scrollTop"]}function Te(){return"boolean"==typeof W?W:"function"==typeof W&&W()}const Oe=u((e=>{const t=e.dragging,r=e.offset["x"===re.current?0:1],i=e.movement["x"===re.current?0:1],c=i>Q.current,o=i<-Q.current,u=e.direction["x"===re.current?0:1];function s(){e.cancel()}function l(){je(u>0?"prev":"next")}function a(){me(Object.assign({eventName:"onDrag",slideActionType:Ie()},e))}function f(){"fluid"===M?ue()||le()&&"prev"===Ie()?ie.start({[re.current]:0,config:Object.assign({velocity:e.velocity},v)}):Y.current&&"next"===Ie()?ie.start({[re.current]:-V.current,config:Object.assign({velocity:e.velocity},v)}):ie.start({[re.current]:J.current,config:Object.assign({velocity:e.velocity},v)}):ie.start({[re.current]:-Ee()*ae(),config:Object.assign({velocity:e.velocity},v)})}function d(){Math.abs(oe())+100>=V.current&&"next"===Ie()&&(Y.current=!0),"prev"===Ie()&&(Y.current=!1)}if($&&Te())return t&&(Re()||Ce(!0),l(),a(),d()),ie.start({from:{[re.current]:we()},to:{[re.current]:-r},config:{velocity:e.velocity,friction:50,tension:1400}}),0===we()&&"prev"===Ie()?void s():void(e.last&&("prev"===Ie()?Pe(e.velocity):ze(e.velocity),Ce(!1)));if(t){if(Re()||Ce(!0),a(),l(),d(),$){if(Te()){if(0===we()&&"prev"===Ie())return void s();ie.start({config:{velocity:e.velocity,friction:50,tension:1400},from:{[re.current]:we()},to:{[re.current]:-r}})}return}if(ie.start({[re.current]:r,config:{velocity:e.velocity,friction:50,tension:1e3}}),(c||o)&&ue()&&"fluid"===M)s(),f();else if(Y.current&&"next"===Ie()&&o)Y.current=!1,s(),ie.start({[re.current]:-V.current});else if(x){if(o)return s(),void(!n&&Ne()?f():ze(e.velocity));if(c)return s(),void(!n&&le()?f():Pe(e.velocity))}}if(e.last&&!x&&(o||c)&&!$)return Ce(!1),void(o?!n&&Ne()?f():ze(e.velocity):c&&(!n&&le()?f():Pe(e.velocity)));!e.last||o||c||$||(f(),me(Object.assign({eventName:"onDrag",slideActionType:Ie()},e)))}),{enabled:!S,axis:re.current,from:()=>$?"x"===re.current?[-we(),0]:[0,-we()]:[ne.x.get(),ne.y.get()]});function je(e){N.current=e}function Ie(){return N.current}function Se(e){z.current=e}function Ee(){return z.current}function Ae(e){q.current=e}function Ce(e){k.current=e}function Re(){return k.current}function $e(){const e=Ee();return 0===e?t.length-1:e-1}function We(){const e=Ee();return e===t.length-1?0:e+1}function Le(e){return t.findIndex((t=>t.id===e))}function Me(e,t){if("number"==typeof e)return{[re.current]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[re.current]:-ae()*t}}function Fe({from:e,to:r=-1,customTo:n,immediate:i=!1,onRest:c=(()=>{}),velocity:o}){i||(Se(r),Ae(!0),me({eventName:"onSlideStartChange",slideActionType:Ie(),nextItem:{index:"fluid"===M?-1:r,id:"fluid"===M?"":t[r].id}})),J.current=Me(n,r)[w],ie.start(Object.assign(Object.assign(Object.assign(Object.assign({},function(e){return"number"==typeof e?{from:{[re.current]:e}}:{}}(e)),{to:Me(n,r)}),o?{config:Object.assign(Object.assign({},g),{velocity:o,friction:void 0,tension:void 0})}:{config:Object.assign({velocity:0},v)}),{immediate:i,onRest:e=>{e.finished&&(Ce(!1),Ae(!1),c(),i||me({eventName:"onSlideChange",slideActionType:Ie(),currentItem:{index:"fluid"===M?-1:Ee(),id:"fluid"===M?"":t[Ee()].id}}))}})),b&&y&&!i&&xe(r,Ie())}function Ne(){return Ee()===t.length-1}function Pe(e){if(je("prev"),Y.current=!1,"fluid"===M){if(Y.current=!1,ue())return;const r=oe()+ae()+200;if($){const t=D.current.scrollLeft-ae();Fe({customTo:t<0?0:t,from:D.current.scrollLeft,velocity:e})}else Fe(r>=0?n?{from:oe()-ce()*t.length,velocity:e,customTo:oe()-ce()*t.length+ae()}:{customTo:0,velocity:e}:{customTo:oe()+ae(),velocity:e})}else{if(!n&&0===Ee()||G.current)return;le()?Fe({from:oe()-ae()*t.length,to:t.length-1,velocity:e}):Fe({to:$e(),velocity:e})}}function ze(e){if(je("next"),"fluid"===M){if(ue())return;const r=Math.abs(oe()-ae())+100>=V.current;if($){const t=D.current.scrollLeft+ae()>V.current,r=D.current.scrollLeft+ae();Fe({velocity:e,customTo:t?V.current:r,from:D.current.scrollLeft})}else if(n&&Math.abs(oe()-ae())>=t.length*ce()){const r=ce()*t.length;Fe({from:oe()+r,customTo:oe()+r-ae(),velocity:e})}else{if(Y.current)return;r?(Y.current=!0,Fe({customTo:-V.current,velocity:e})):Fe({customTo:oe()-ae(),velocity:e})}}else{if(!n&&Ee()===P.length-1||G.current)return;Math.abs(oe()-ae()+25)>V.current&&!Re()?Y.current=!0:Y.current?Fe({to:t.length-U.current,velocity:e}):Ne()?Fe({from:oe()+ae()*t.length,to:0,velocity:e}):Fe({to:We(),velocity:e})}}function De(e){let r=0;if(r="string"==typeof e?t.findIndex((t=>t.id===e)):e,r>=t.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(r===Ee()||t.length!==K.current.length&&Ee()<t.length)return;const n=Le(K.current[Ee()].id);je(Le(t[r].id)>n?"next":"prev"),Fe({to:r})}d((()=>{if(L%2==0&&te.current)throw new Error("initialStartingPosition can be only used if itemsPerSlide is an even value.");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>t.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>t.length)throw new Error("The initialActiveItem cannot be greater than the total length of the items you provide.");p||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.")})),d((()=>{function e(){document.hidden?G.current=!0:G.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),d((()=>{F.current=!1,V.current=se(),X.current=window.innerWidth,H.current=window.innerWidth,j>0&&(Fe({to:j,immediate:!0}),Se(j),!n&&B.current&&(B.current.style.top="0px",B.current.style.left="0px"))})),s((()=>{j<t.length&&j!==z.current&&(Fe({to:j,immediate:!0}),Se(j))}),[j]),s((()=>{if(p)return window.addEventListener("resize",he),()=>{window.removeEventListener("resize",he)}}),[p]),s((()=>{B.current&&("x"===re.current&&(B.current.style.top="0px"),"y"===re.current&&(B.current.style.left="0px"))}),[w]),s((()=>{V.current=se();!(t.length===K.current.length)&&t.length<K.current.length&&De(t.length-1),K.current=t}),[se,t]);const Be=Object.assign({useListenToCustomEvent:ge,getIsFullscreen:ye,enterFullscreen:ve,exitFullscreen:pe,getIsAnimating:function(){return q.current},getIsDragging:Re,getIsNextItem:function(e){const r=Le(e),i=Ee();return n&&i===t.length-1?0===r:r===i+1},getIsPrevItem:function(e){const r=Le(e),i=Ee();return n&&0===i?r===t.length-1:r===i-1},slideToPrevItem(){Pe()},slideToNextItem(){ze()}},"fixed"===M?{slideToItem:De,getIsActiveItem:e=>Le(e)===Ee(),getCurrentActiveItem:()=>({id:t[Ee()].id,index:Ee()})}:{});const ke=e(h.Provider,Object.assign({value:Be},{children:e("div",Object.assign({ref:D,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},$?{onWheel(){ne[re.current].stop()}}:{},{style:Object.assign({display:"flex",position:"relative",width:"100%",height:"100%"},$?"x"===re.current?{overflowX:"auto"}:{overflowY:"auto"}:{})},{children:e(o.div,Object.assign({},Oe(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{e&&(B.current=e,fe(e,ee.current))},style:Object.assign(Object.assign(Object.assign({display:"flex",position:"relative",touchAction:S?"unset":C||("x"===re.current?"pan-y":"pan-x"),flexDirection:"x"===re.current?"row":"column"},function(){const e=`calc(100% - ${2*_.current}px)`;return{width:"x"===re.current?e:"100%",height:"y"===re.current?e:"100%"}}()),function(){const e=t.length/L*100,r=100/L,n="x"===re.current?"left":"y",i=Math.floor(50/r);if("fixed"===M){if("center"===te.current)return{[n]:`calc(-${e}% + ${r*i}%)`};if("end"===te.current)return{[n]:`calc(-${e}% + ${r*(2*i)}%)`}}return{[n]:"0px"}}()),$?{}:ne)},{children:P.map((({id:t,renderItem:r},n)=>{return e("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:Object.assign({display:"flex",position:"relative"},(i=U.current,"fixed"===M?Object.assign(Object.assign({},"x"===re.current?{marginRight:`${Z.current}px`}:{marginBottom:`${Z.current}px`}),{flex:`1 0 calc(100% / ${i} - ${Z.current*(i-1)/i}px)`}):Object.assign({},"x"===re.current?{marginRight:`${Z.current}px`}:{marginBottom:`${Z.current}px`})))},{children:r}),`${t}-${n}`);var i}))}))}))})),qe=e(h.Provider,Object.assign({value:Be},{children:be}));return Object.assign(Object.assign({},Be),{carouselFragment:ke,thumbsFragment:qe})}function v(){const e=n(h);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e}export{m as useSpringCarousel,v as useSpringCarouselContext};
|
|
2
2
|
//# sourceMappingURL=index2.js.map
|
package/dist/esm/index2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","sources":["../../src/useSpringCarousel/index.tsx"],"sourcesContent":["import { useRef, createContext, useContext } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from '../modules'\nimport {\n SlideToItemFnProps,\n SlideActionType,\n UseSpringFixedSlideTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n UseSpringFluidSlideTypeReturnProps,\n UseSpringCarouselBaseProps,\n UseSpringCarouselWithThumbs,\n UseSpringCarouselFluidType,\n DisableGesturesProps,\n WithLoopProps,\n UseSpringCarouselWithNoThumbs,\n EnableGesturesProps,\n WithNoLoop,\n UseSpringCarouselFixedSlideType,\n} from '../types/useSpringCarousel'\n\ntype ReturnType<T> = T extends 'fixed'\n ? UseSpringFixedSlideTypeReturnProps\n : UseSpringFluidSlideTypeReturnProps\ntype ContextTypes<T> = Omit<ReturnType<T>, 'carouselFragment' | 'thumbsFragment'>\n\nconst Context = createContext<ContextTypes<'fixed' | 'fluid'> | undefined>(undefined)\n\nconst defaultDragSpringConfig = {\n ...config.default,\n mass: 1,\n velocity: 0,\n}\n\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFluidType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fluid'>\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFixedSlideType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fixed'>\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n slideWhenThresholdIsReached = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition,\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps): ReturnType<'fixed' | 'fluid'> {\n function getItems() {\n if (withLoop) {\n if (items.length === itemsPerSlide) {\n return [...items, ...items, ...items, ...items, ...items]\n }\n return [...items, ...items, ...items]\n }\n return items\n }\n\n const isFirstMount = useRef(true)\n const slideActionType = useRef<SlideActionType>('initial' as SlideActionType)\n const internalItems = getItems()\n const activeItem = useRef(initialActiveItem)\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const carouselTrackWrapperRef = useRef<HTMLDivElement | null>(null)\n const isDragging = useRef(false)\n const isAnimating = useRef(false)\n const windowIsHidden = useRef(false)\n const fluidTotalWrapperScrollValue = useRef(0)\n const slideEndReached = useRef(false)\n const currentWindowWidth = useRef(0)\n const initialWindowWidth = useRef(0)\n const prevSlidedValue = useRef(0)\n const prevItems = useRef(items)\n\n /**\n * Instead of raw values, we store it in\n * useRef for performances reasons during external rerenders\n */\n const draggingSlideTresholdRef = useRef<number>(draggingSlideTreshold ?? 0)\n const itemsPerSlideRef = useRef(itemsPerSlide)\n const gutterRef = useRef(gutter)\n const startEndGutterRef = useRef(startEndGutter)\n const initialActiveItemRef = useRef(initialActiveItem)\n const initialStartingPositionRef = useRef(initialStartingPosition)\n const carouselSlideAxisRef = useRef(carouselSlideAxis)\n\n /**\n * Update inner values during external rerenders!\n */\n itemsPerSlideRef.current = itemsPerSlide\n gutterRef.current = gutter\n startEndGutterRef.current = startEndGutter\n initialActiveItemRef.current = initialActiveItem\n initialStartingPositionRef.current = initialStartingPosition\n carouselSlideAxisRef.current = carouselSlideAxis\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxisRef.current])\n }\n },\n }))\n\n useIsomorphicLayoutEffect(() => {\n if (draggingSlideTreshold) {\n draggingSlideTresholdRef.current = draggingSlideTreshold\n } else {\n draggingSlideTresholdRef.current = Math.floor(getSlideValue() / 2 / 2)\n }\n\n resize()\n }, [\n draggingSlideTreshold,\n itemsPerSlide,\n gutter,\n startEndGutter,\n initialActiveItem,\n initialStartingPosition,\n carouselSlideAxis,\n thumbsSlideAxis,\n ])\n\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n function getMainCarouselWrapperWidth() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ]\n }\n function getCarouselItemWidth() {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }\n function getCurrentSlidedValue() {\n return carouselStyles[carouselSlideAxisRef.current].get()\n }\n function getIfItemsNotFillTheCarousel() {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }\n function getFluidWrapperScrollValue() {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxisRef.current === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ],\n )\n }\n function getIsFirstItem() {\n return getCurrentActiveItem() === 0\n }\n function getSlideValue() {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (slideType === 'fluid' && typeof slideAmount === 'number') {\n if (slideAmount < itemVal) {\n throw new Error('slideAmount must be greater than the width of a single item.')\n }\n return slideAmount\n }\n return itemVal\n }\n function adjustCarouselWrapperPosition(\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) {\n const positionProperty = carouselSlideAxisRef.current === 'x' ? 'left' : 'top'\n function getDefaultPositionValue() {\n return getCarouselItemWidth() * items.length\n }\n function setPosition(v: number) {\n if (withLoop) {\n ref.style.top = '0px'\n ref.style[positionProperty] = `-${v - startEndGutterRef.current}px`\n } else {\n ref.style.left = '0px'\n ref.style.top = '0px'\n if (_initialActiveItem && isFirstMount.current) {\n ref.style[positionProperty] = `calc(-${_initialActiveItem} * 100%)`\n }\n }\n }\n function setStartPosition() {\n setPosition(getDefaultPositionValue())\n }\n\n if (slideType === 'fixed') {\n function setCenterPosition(i: number) {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round(((i as number) - 1) / 2),\n )\n }\n function setEndPosition(i: number) {\n setPosition(\n getDefaultPositionValue() - getSlideValue() * Math.round((i as number) - 1),\n )\n }\n\n if (itemsPerSlideRef.current > 1) {\n switch (initialStartingPositionRef.current) {\n default:\n case 'start': {\n setStartPosition()\n break\n }\n case 'center': {\n setCenterPosition(itemsPerSlideRef.current)\n break\n }\n case 'end': {\n setEndPosition(itemsPerSlideRef.current)\n break\n }\n }\n } else {\n setStartPosition()\n }\n } else {\n setStartPosition()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function resize() {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: 0,\n })\n return\n }\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n\n if (slideEndReached.current) {\n const nextValue = -fluidTotalWrapperScrollValue.current\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n function handleResize() {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule<'use-spring'>()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } =\n useFullscreenModule<'use-spring'>({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getIfShouldEnableFluidDrag() {\n if (typeof enableFreeScrollDrag === 'boolean') {\n return enableFreeScrollDrag\n } else if (typeof enableFreeScrollDrag === 'function') {\n return enableFreeScrollDrag()\n }\n return false\n }\n\n const bindDrag = useDrag(\n props => {\n const isDragging = props.dragging\n const movement = props.offset[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function setDragDirection() {\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n }\n function emitDragObservable() {\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: 0,\n config: {\n velocity: props.velocity,\n },\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n config: {\n velocity: props.velocity,\n },\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: prevSlidedValue.current,\n config: {\n velocity: props.velocity,\n },\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -(getCurrentActiveItem() * getSlideValue()),\n config: {\n velocity: props.velocity,\n },\n })\n }\n }\n function checkBounds() {\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue()) + 100 >= fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && getSlideActionType() === 'next') {\n slideEndReached.current = true\n }\n if (getSlideActionType() === 'prev') {\n slideEndReached.current = false\n }\n }\n\n if (freeScroll && getIfShouldEnableFluidDrag()) {\n setDragDirection()\n emitDragObservable()\n checkBounds()\n\n setCarouselStyles.start({\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n config: {\n velocity: props.velocity,\n },\n })\n\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n }\n return\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitDragObservable()\n setDragDirection()\n checkBounds()\n\n if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1000,\n },\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: movement,\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1000,\n },\n })\n }\n\n if (\n (prevItemTreshold || nextItemTreshold) &&\n getIfItemsNotFillTheCarousel() &&\n slideType === 'fluid'\n ) {\n cancelDrag()\n resetAnimation()\n } else if (\n slideEndReached.current &&\n getSlideActionType() === 'next' &&\n nextItemTreshold\n ) {\n slideEndReached.current = false\n cancelDrag()\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (slideWhenThresholdIsReached) {\n if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n return\n }\n }\n }\n\n if (\n props.last &&\n !slideWhenThresholdIsReached &&\n (nextItemTreshold || prevItemTreshold) &&\n !freeScroll\n ) {\n if (nextItemTreshold) {\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n } else if (prevItemTreshold) {\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n }\n return\n }\n\n if (props.last && !nextItemTreshold && !prevItemTreshold) {\n if (!freeScroll) {\n resetAnimation()\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n axis: carouselSlideAxisRef.current,\n from: () => {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === 'x') {\n return [-getWrapperScrollDirection(), 0]\n }\n return [0, -getWrapperScrollDirection()]\n }\n return [carouselStyles.x.get(), carouselStyles.y.get()]\n },\n },\n )\n\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function setActiveItem(newItem: number) {\n activeItem.current = newItem\n }\n function getCurrentActiveItem() {\n return activeItem.current\n }\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setIsDragging(val: boolean) {\n isDragging.current = val\n }\n function getIsDragging() {\n return isDragging.current\n }\n function getPrevItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === 0) {\n return items.length - 1\n }\n return currentActiveItem - 1\n }\n function getNextItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === items.length - 1) {\n return 0\n }\n return currentActiveItem + 1\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n return itemIndex === activeItem - 1\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getFromValue(from: SlideToItemFnProps['from']) {\n if (typeof from === 'number') {\n return {\n from: {\n [carouselSlideAxisRef.current]: from,\n },\n }\n }\n return {}\n }\n function getToValue(\n customTo: SlideToItemFnProps['customTo'],\n to: SlideToItemFnProps['to'],\n ) {\n if (typeof customTo === 'number') {\n return {\n [carouselSlideAxisRef.current]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxisRef.current]: -(getSlideValue() * to!),\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function slideToItem({\n from,\n to = -1,\n customTo,\n immediate = false,\n onRest = () => {},\n velocity,\n }: SlideToItemFnProps) {\n if (!immediate) {\n setActiveItem(to)\n setIsAnimating(true)\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: slideType === 'fluid' ? -1 : to,\n id: slideType === 'fluid' ? '' : items[to].id,\n },\n })\n }\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\n ...(velocity\n ? {\n config: {\n ...defaultDragSpringConfig,\n velocity,\n friction: undefined,\n tension: undefined,\n },\n }\n : {\n config: {\n velocity: 0,\n ...springConfig,\n },\n }),\n immediate,\n onRest: val => {\n if (val.finished) {\n setIsDragging(false)\n setIsAnimating(false)\n onRest()\n if (!immediate) {\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: slideType === 'fluid' ? -1 : getCurrentActiveItem(),\n id: slideType === 'fluid' ? '' : items[getCurrentActiveItem()].id,\n },\n })\n }\n }\n },\n })\n if (enableThumbsWrapperScroll && withThumbs && !immediate) {\n handleThumbsScroll(to, getSlideActionType())\n }\n }\n function getIsLastItem() {\n return getCurrentActiveItem() === items.length - 1\n }\n function slideToPrevItem(velocity?: number[]) {\n setSlideActionType('prev')\n slideEndReached.current = false\n\n if (slideType === 'fluid') {\n slideEndReached.current = false\n\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const nextPrevValue = getCurrentSlidedValue() + getSlideValue() + 200\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft - getSlideValue()\n slideToItem({\n customTo: nextValue < 0 ? 0 : nextValue,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n velocity,\n })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n velocity,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n velocity,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n velocity,\n })\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n velocity,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n velocity,\n })\n }\n }\n }\n function slideToNextItem(velocity?: number[]) {\n setSlideActionType('next')\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue()) + 100 >=\n fluidTotalWrapperScrollValue.current\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n const willExceed = nextValue > fluidTotalWrapperScrollValue.current\n const val = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n\n slideToItem({\n velocity,\n customTo: willExceed ? fluidTotalWrapperScrollValue.current : val,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (\n withLoop &&\n Math.abs(getCurrentSlidedValue() - getSlideValue()) >=\n items.length * getCarouselItemWidth()\n ) {\n const currentWidth = getCarouselItemWidth() * items.length\n slideToItem({\n from: getCurrentSlidedValue() + currentWidth,\n customTo: getCurrentSlidedValue() + currentWidth - getSlideValue(),\n velocity,\n })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n velocity,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n velocity,\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue() + 25) >\n fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && !getIsDragging()) {\n slideEndReached.current = true\n } else if (slideEndReached.current) {\n slideToItem({\n to: items.length - itemsPerSlideRef.current,\n velocity,\n })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n velocity,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n velocity,\n })\n }\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function _slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (\n itemIndex === getCurrentActiveItem() ||\n (items.length !== prevItems.current.length && getCurrentActiveItem() < items.length)\n ) {\n return\n }\n\n const currentItem = findItemIndex(prevItems.current[getCurrentActiveItem()].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n slideToItem({\n to: itemIndex,\n })\n }\n function getItemStyles(_itemsPerSlide: number) {\n if (slideType === 'fixed') {\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n flex: `1 0 calc(100% / ${_itemsPerSlide} - ${\n (gutterRef.current * (_itemsPerSlide - 1)) / _itemsPerSlide\n }px)`,\n }\n }\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n }\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutterRef.current * 2}px)`\n return {\n width: carouselSlideAxisRef.current === 'x' ? percentValue : '100%',\n height: carouselSlideAxisRef.current === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxisRef.current].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxisRef.current === 'x') {\n return 'pan-y'\n }\n return 'pan-x'\n }\n return touchAction\n }\n // Perform some check on first mount\n useIsomorphicMount(() => {\n if (itemsPerSlide % 2 === 0 && initialStartingPositionRef.current) {\n throw new Error(\n `initialStartingPosition can be only used if itemsPerSlide is an even value.`,\n )\n }\n if (draggingSlideTresholdRef.current < 0) {\n throw new Error('draggingSlideTreshold must be greater than 0')\n }\n if (draggingSlideTresholdRef.current > getSlideValue() / 2) {\n throw new Error(\n `draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(\n getSlideValue() / 2,\n )}`,\n )\n }\n if (itemsPerSlideRef.current < 1) {\n throw new Error(`The itemsPerSlide prop can't be less than 1.`)\n }\n if (itemsPerSlideRef.current > items.length) {\n throw new Error(\n `The itemsPerSlide prop can't be greater than the total length of the items you provide.`,\n )\n }\n if (initialActiveItemRef.current < 0) {\n throw new Error('The initialActiveItem cannot be less than 0.')\n }\n if (initialActiveItemRef.current > items.length) {\n throw new Error(\n 'The initialActiveItem cannot be greater than the total length of the items you provide.',\n )\n }\n if (!shouldResizeOnWindowResize) {\n console.warn(\n 'You set shouldResizeOnWindowResize={false}; be aware that the carousel could behave in a strange way if you also use the fullscreen functionality or if you change the mobile orientation.',\n )\n }\n })\n useIsomorphicMount(() => {\n function handleVisibilityChange() {\n if (document.hidden) {\n windowIsHidden.current = true\n } else {\n windowIsHidden.current = false\n }\n }\n document.addEventListener('visibilitychange', handleVisibilityChange)\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange)\n }\n })\n useIsomorphicMount(() => {\n isFirstMount.current = false\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n initialWindowWidth.current = window.innerWidth\n currentWindowWidth.current = window.innerWidth\n\n if (initialActiveItem > 0) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n if (!withLoop && carouselTrackWrapperRef.current) {\n carouselTrackWrapperRef.current.style.top = '0px'\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n })\n useIsomorphicLayoutEffect(() => {\n if (initialActiveItem < items.length && initialActiveItem !== activeItem.current) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n }\n }, [initialActiveItem])\n useIsomorphicLayoutEffect(() => {\n if (shouldResizeOnWindowResize) {\n window.addEventListener('resize', handleResize)\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [shouldResizeOnWindowResize])\n useIsomorphicLayoutEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxisRef.current === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxisRef.current === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useIsomorphicLayoutEffect(() => {\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n const itemsAreEqual = items.length === prevItems.current.length\n\n if (!itemsAreEqual && items.length < prevItems.current.length) {\n _slideToItem(items.length - 1)\n }\n\n prevItems.current = items\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getFluidWrapperScrollValue, items])\n\n const contextProps = {\n useListenToCustomEvent,\n getIsFullscreen,\n enterFullscreen,\n exitFullscreen,\n getIsAnimating,\n getIsDragging,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem() {\n slideToPrevItem()\n },\n slideToNextItem() {\n slideToNextItem()\n },\n ...(slideType === 'fixed'\n ? {\n slideToItem: _slideToItem,\n getIsActiveItem: (id: string) => {\n return findItemIndex(id) === getCurrentActiveItem()\n },\n getCurrentActiveItem: () => ({\n id: items[getCurrentActiveItem()].id,\n index: getCurrentActiveItem(),\n }),\n }\n : {}),\n }\n\n const handleCarouselFragmentRef = (ref: HTMLDivElement | null) => {\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n function getInitialStyles() {\n const totalValue = (items.length / itemsPerSlide) * 100\n const singleItemValue = 100 / itemsPerSlide\n const cssProp = carouselSlideAxisRef.current === 'x' ? 'left' : 'y'\n const quantityToMove = Math.floor(50 / singleItemValue)\n\n if (slideType === 'fixed') {\n if (initialStartingPositionRef.current === 'center') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * quantityToMove}%)`,\n }\n }\n if (initialStartingPositionRef.current === 'end') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * (quantityToMove * 2)}%)`,\n }\n }\n }\n return {\n [cssProp]: `0px`,\n }\n }\n\n const carouselFragment = (\n <Context.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxisRef.current === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...getInitialStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </Context.Provider>\n )\n const thumbsFragment = (\n <Context.Provider value={contextProps}>{_thumbsFragment}</Context.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext<T = 'fixed' | 'fluid'>() {\n const context = useContext(Context)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context as ContextTypes<T>\n}\n\nexport { useSpringCarousel, useSpringCarouselContext }\n"],"names":["Context","createContext","undefined","defaultDragSpringConfig","config","default","mass","velocity","useSpringCarousel","items","withLoop","draggingSlideTreshold","springConfig","shouldResizeOnWindowResize","withThumbs","enableThumbsWrapperScroll","slideWhenThresholdIsReached","carouselSlideAxis","thumbsSlideAxis","prepareThumbsData","initialActiveItem","initialStartingPosition","disableGestures","gutter","startEndGutter","touchAction","slideAmount","freeScroll","enableFreeScrollDrag","itemsPerSlide","slideType","isFirstMount","useRef","slideActionType","internalItems","length","activeItem","mainCarouselWrapperRef","carouselTrackWrapperRef","isDragging","isAnimating","windowIsHidden","fluidTotalWrapperScrollValue","slideEndReached","currentWindowWidth","initialWindowWidth","prevSlidedValue","prevItems","draggingSlideTresholdRef","itemsPerSlideRef","gutterRef","startEndGutterRef","initialActiveItemRef","initialStartingPositionRef","carouselSlideAxisRef","current","carouselStyles","setCarouselStyles","useSpring","y","x","onChange","value","Math","abs","getCarouselItemWidth","carouselItem","querySelector","Error","getBoundingClientRect","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getMainCarouselWrapperWidth","getFluidWrapperScrollValue","round","Number","getIsFirstItem","getCurrentActiveItem","getSlideValue","itemVal","adjustCarouselWrapperPosition","ref","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","style","top","left","setStartPosition","i","setEndPosition","resize","window","innerWidth","start","immediate","[object Object]","nextValue","handleResize","useIsomorphicLayoutEffect","floor","useListenToCustomEvent","emitObservable","useCustomEventsModule","enterFullscreen","exitFullscreen","getIsFullscreen","useFullscreenModule","thumbsFragment","_thumbsFragment","handleThumbsScroll","useThumbsModule","getWrapperScrollDirection","getIfShouldEnableFluidDrag","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","setDragDirection","setSlideActionType","emitDragObservable","eventName","getSlideActionType","resetAnimation","checkBounds","from","to","getIsDragging","setIsDragging","friction","tension","getIsLastItem","slideToNextItem","slideToPrevItem","last","enabled","axis","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","id","findIndex","item","getToValue","customTo","slideToItem","onRest","nextItem","index","getFromValue","finished","currentItem","nextPrevValue","scrollLeft","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","useIsomorphicMount","console","warn","handleVisibilityChange","document","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","_jsx","Provider","className","stop","display","position","width","height","overflowX","overflowY","animated","div","flexDirection","percentValue","getAnimatedWrapperStyles","totalValue","singleItemValue","cssProp","quantityToMove","getInitialStyles","map","renderItem","_itemsPerSlide","marginRight","marginBottom","flex","useSpringCarouselContext","context","useContext"],"mappings":"mUA8BA,MAAMA,EAAUC,OAA2DC,GAErEC,iCACDC,EAAOC,UACVC,KAAM,EACNC,SAAU,IAkBZ,SAASC,GAAkBC,MACzBA,EAAKC,SACLA,GAAW,EAAKC,sBAChBA,EAAqBC,aACrBA,EAAeR,EAAOC,QAAOQ,2BAC7BA,GAA6B,EAAIC,WACjCA,GAAa,EAAKC,0BAClBA,GAA4B,EAAIC,4BAChCA,GAA8B,EAAIC,kBAClCA,EAAoB,IAAGC,gBACvBA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"version":3,"file":"index2.js","sources":["../../src/useSpringCarousel/index.tsx"],"sourcesContent":["import { useRef, createContext, useContext } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from '../modules'\nimport {\n SlideToItemFnProps,\n SlideActionType,\n UseSpringFixedSlideTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n UseSpringFluidSlideTypeReturnProps,\n UseSpringCarouselBaseProps,\n UseSpringCarouselWithThumbs,\n UseSpringCarouselFluidType,\n DisableGesturesProps,\n WithLoopProps,\n UseSpringCarouselWithNoThumbs,\n EnableGesturesProps,\n WithNoLoop,\n UseSpringCarouselFixedSlideType,\n} from '../types/useSpringCarousel'\n\ntype ReturnType<T> = T extends 'fixed'\n ? UseSpringFixedSlideTypeReturnProps\n : UseSpringFluidSlideTypeReturnProps\ntype ContextTypes<T> = Omit<ReturnType<T>, 'carouselFragment' | 'thumbsFragment'>\n\nconst Context = createContext<ContextTypes<'fixed' | 'fluid'> | undefined>(undefined)\n\nconst defaultDragSpringConfig = {\n ...config.default,\n mass: 1,\n velocity: 0,\n}\n\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFluidType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fluid'>\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFixedSlideType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fixed'>\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n slideWhenThresholdIsReached = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition,\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps): ReturnType<'fixed' | 'fluid'> {\n function getItems() {\n if (withLoop) {\n if (items.length === itemsPerSlide) {\n return [...items, ...items, ...items, ...items, ...items]\n }\n return [...items, ...items, ...items]\n }\n return items\n }\n\n const isFirstMount = useRef(true)\n const slideActionType = useRef<SlideActionType>('initial' as SlideActionType)\n const internalItems = getItems()\n const activeItem = useRef(initialActiveItem)\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const carouselTrackWrapperRef = useRef<HTMLDivElement | null>(null)\n const isDragging = useRef(false)\n const isAnimating = useRef(false)\n const windowIsHidden = useRef(false)\n const fluidTotalWrapperScrollValue = useRef(0)\n const slideEndReached = useRef(false)\n const currentWindowWidth = useRef(0)\n const initialWindowWidth = useRef(0)\n const prevSlidedValue = useRef(0)\n const prevItems = useRef(items)\n\n /**\n * Instead of raw values, we store it in\n * useRef for performances reasons during external rerenders\n */\n const draggingSlideTresholdRef = useRef<number>(draggingSlideTreshold ?? 0)\n const itemsPerSlideRef = useRef(itemsPerSlide)\n const gutterRef = useRef(gutter)\n const startEndGutterRef = useRef(startEndGutter)\n const initialActiveItemRef = useRef(initialActiveItem)\n const initialStartingPositionRef = useRef(initialStartingPosition)\n const carouselSlideAxisRef = useRef(carouselSlideAxis)\n\n /**\n * Update inner values during external rerenders!\n */\n itemsPerSlideRef.current = itemsPerSlide\n gutterRef.current = gutter\n startEndGutterRef.current = startEndGutter\n initialActiveItemRef.current = initialActiveItem\n initialStartingPositionRef.current = initialStartingPosition\n carouselSlideAxisRef.current = carouselSlideAxis\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxisRef.current])\n }\n },\n }))\n\n useIsomorphicLayoutEffect(() => {\n if (draggingSlideTreshold) {\n draggingSlideTresholdRef.current = draggingSlideTreshold\n } else {\n draggingSlideTresholdRef.current = Math.floor(getSlideValue() / 2 / 2)\n }\n\n resize()\n }, [\n draggingSlideTreshold,\n itemsPerSlide,\n gutter,\n startEndGutter,\n initialActiveItem,\n initialStartingPosition,\n carouselSlideAxis,\n thumbsSlideAxis,\n ])\n\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n function getMainCarouselWrapperWidth() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ]\n }\n function getCarouselItemWidth() {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }\n function getCurrentSlidedValue() {\n return carouselStyles[carouselSlideAxisRef.current].get()\n }\n function getIfItemsNotFillTheCarousel() {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }\n function getFluidWrapperScrollValue() {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxisRef.current === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ],\n )\n }\n function getIsFirstItem() {\n return getCurrentActiveItem() === 0\n }\n function getSlideValue() {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (slideType === 'fluid' && typeof slideAmount === 'number') {\n if (slideAmount < itemVal) {\n throw new Error('slideAmount must be greater than the width of a single item.')\n }\n return slideAmount\n }\n return itemVal\n }\n function adjustCarouselWrapperPosition(\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) {\n const positionProperty = carouselSlideAxisRef.current === 'x' ? 'left' : 'top'\n function getDefaultPositionValue() {\n return getCarouselItemWidth() * items.length\n }\n function setPosition(v: number) {\n if (withLoop) {\n ref.style.top = '0px'\n ref.style[positionProperty] = `-${v - startEndGutterRef.current}px`\n } else {\n ref.style.left = '0px'\n ref.style.top = '0px'\n if (_initialActiveItem && isFirstMount.current) {\n ref.style[positionProperty] = `calc(-${_initialActiveItem} * 100%)`\n }\n }\n }\n function setStartPosition() {\n setPosition(getDefaultPositionValue())\n }\n\n if (slideType === 'fixed') {\n function setCenterPosition(i: number) {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round(((i as number) - 1) / 2),\n )\n }\n function setEndPosition(i: number) {\n setPosition(\n getDefaultPositionValue() - getSlideValue() * Math.round((i as number) - 1),\n )\n }\n\n if (itemsPerSlideRef.current > 1) {\n switch (initialStartingPositionRef.current) {\n default:\n case 'start': {\n setStartPosition()\n break\n }\n case 'center': {\n setCenterPosition(itemsPerSlideRef.current)\n break\n }\n case 'end': {\n setEndPosition(itemsPerSlideRef.current)\n break\n }\n }\n } else {\n setStartPosition()\n }\n } else {\n setStartPosition()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function resize() {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: 0,\n })\n return\n }\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n\n if (slideEndReached.current) {\n const nextValue = -fluidTotalWrapperScrollValue.current\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n function handleResize() {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule<'use-spring'>()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } =\n useFullscreenModule<'use-spring'>({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getIfShouldEnableFluidDrag() {\n if (typeof enableFreeScrollDrag === 'boolean') {\n return enableFreeScrollDrag\n } else if (typeof enableFreeScrollDrag === 'function') {\n return enableFreeScrollDrag()\n }\n return false\n }\n\n const bindDrag = useDrag(\n props => {\n const isDragging = props.dragging\n const movement = props.offset[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function setDragDirection() {\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n }\n function emitDragObservable() {\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: 0,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: prevSlidedValue.current,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -(getCurrentActiveItem() * getSlideValue()),\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n }\n }\n function checkBounds() {\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue()) + 100 >= fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && getSlideActionType() === 'next') {\n slideEndReached.current = true\n }\n if (getSlideActionType() === 'prev') {\n slideEndReached.current = false\n }\n }\n\n if (freeScroll && getIfShouldEnableFluidDrag()) {\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n setDragDirection()\n emitDragObservable()\n checkBounds()\n }\n\n setCarouselStyles.start({\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1400,\n },\n })\n\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n }\n if (props.last) {\n if (getSlideActionType() === 'prev') {\n slideToPrevItem(props.velocity)\n } else {\n slideToNextItem(props.velocity)\n }\n setIsDragging(false)\n }\n return\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitDragObservable()\n setDragDirection()\n checkBounds()\n\n if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1400,\n },\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: movement,\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1000,\n },\n })\n }\n\n if (\n (prevItemTreshold || nextItemTreshold) &&\n getIfItemsNotFillTheCarousel() &&\n slideType === 'fluid'\n ) {\n cancelDrag()\n resetAnimation()\n } else if (\n slideEndReached.current &&\n getSlideActionType() === 'next' &&\n nextItemTreshold\n ) {\n slideEndReached.current = false\n cancelDrag()\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (slideWhenThresholdIsReached) {\n if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n return\n }\n }\n }\n\n if (\n props.last &&\n !slideWhenThresholdIsReached &&\n (nextItemTreshold || prevItemTreshold) &&\n !freeScroll\n ) {\n setIsDragging(false)\n if (nextItemTreshold) {\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n } else if (prevItemTreshold) {\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n }\n return\n }\n\n if (props.last && !nextItemTreshold && !prevItemTreshold) {\n if (!freeScroll) {\n resetAnimation()\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n axis: carouselSlideAxisRef.current,\n from: () => {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === 'x') {\n return [-getWrapperScrollDirection(), 0]\n }\n return [0, -getWrapperScrollDirection()]\n }\n return [carouselStyles.x.get(), carouselStyles.y.get()]\n },\n },\n )\n\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function setActiveItem(newItem: number) {\n activeItem.current = newItem\n }\n function getCurrentActiveItem() {\n return activeItem.current\n }\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setIsDragging(val: boolean) {\n isDragging.current = val\n }\n function getIsDragging() {\n return isDragging.current\n }\n function getPrevItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === 0) {\n return items.length - 1\n }\n return currentActiveItem - 1\n }\n function getNextItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === items.length - 1) {\n return 0\n }\n return currentActiveItem + 1\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n return itemIndex === activeItem - 1\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getFromValue(from: SlideToItemFnProps['from']) {\n if (typeof from === 'number') {\n return {\n from: {\n [carouselSlideAxisRef.current]: from,\n },\n }\n }\n return {}\n }\n function getToValue(\n customTo: SlideToItemFnProps['customTo'],\n to: SlideToItemFnProps['to'],\n ) {\n if (typeof customTo === 'number') {\n return {\n [carouselSlideAxisRef.current]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxisRef.current]: -(getSlideValue() * to!),\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function slideToItem({\n from,\n to = -1,\n customTo,\n immediate = false,\n onRest = () => {},\n velocity,\n }: SlideToItemFnProps) {\n if (!immediate) {\n setActiveItem(to)\n setIsAnimating(true)\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: slideType === 'fluid' ? -1 : to,\n id: slideType === 'fluid' ? '' : items[to].id,\n },\n })\n }\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\n ...(velocity\n ? {\n config: {\n ...defaultDragSpringConfig,\n velocity,\n friction: undefined,\n tension: undefined,\n },\n }\n : {\n config: {\n velocity: 0,\n ...springConfig,\n },\n }),\n immediate,\n onRest: val => {\n if (val.finished) {\n setIsDragging(false)\n setIsAnimating(false)\n onRest()\n if (!immediate) {\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: slideType === 'fluid' ? -1 : getCurrentActiveItem(),\n id: slideType === 'fluid' ? '' : items[getCurrentActiveItem()].id,\n },\n })\n }\n }\n },\n })\n if (enableThumbsWrapperScroll && withThumbs && !immediate) {\n handleThumbsScroll(to, getSlideActionType())\n }\n }\n function getIsLastItem() {\n return getCurrentActiveItem() === items.length - 1\n }\n function slideToPrevItem(velocity?: number[]) {\n setSlideActionType('prev')\n slideEndReached.current = false\n\n if (slideType === 'fluid') {\n slideEndReached.current = false\n\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const nextPrevValue = getCurrentSlidedValue() + getSlideValue() + 200\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft - getSlideValue()\n slideToItem({\n customTo: nextValue < 0 ? 0 : nextValue,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n velocity,\n })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n velocity,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n velocity,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n velocity,\n })\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n velocity,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n velocity,\n })\n }\n }\n }\n function slideToNextItem(velocity?: number[]) {\n setSlideActionType('next')\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue()) + 100 >=\n fluidTotalWrapperScrollValue.current\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n const willExceed = nextValue > fluidTotalWrapperScrollValue.current\n const val = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n\n slideToItem({\n velocity,\n customTo: willExceed ? fluidTotalWrapperScrollValue.current : val,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (\n withLoop &&\n Math.abs(getCurrentSlidedValue() - getSlideValue()) >=\n items.length * getCarouselItemWidth()\n ) {\n const currentWidth = getCarouselItemWidth() * items.length\n slideToItem({\n from: getCurrentSlidedValue() + currentWidth,\n customTo: getCurrentSlidedValue() + currentWidth - getSlideValue(),\n velocity,\n })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n velocity,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n velocity,\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue() + 25) >\n fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && !getIsDragging()) {\n slideEndReached.current = true\n } else if (slideEndReached.current) {\n slideToItem({\n to: items.length - itemsPerSlideRef.current,\n velocity,\n })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n velocity,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n velocity,\n })\n }\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function _slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (\n itemIndex === getCurrentActiveItem() ||\n (items.length !== prevItems.current.length && getCurrentActiveItem() < items.length)\n ) {\n return\n }\n\n const currentItem = findItemIndex(prevItems.current[getCurrentActiveItem()].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n slideToItem({\n to: itemIndex,\n })\n }\n function getItemStyles(_itemsPerSlide: number) {\n if (slideType === 'fixed') {\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n flex: `1 0 calc(100% / ${_itemsPerSlide} - ${\n (gutterRef.current * (_itemsPerSlide - 1)) / _itemsPerSlide\n }px)`,\n }\n }\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n }\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutterRef.current * 2}px)`\n return {\n width: carouselSlideAxisRef.current === 'x' ? percentValue : '100%',\n height: carouselSlideAxisRef.current === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxisRef.current].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxisRef.current === 'x') {\n return 'pan-y'\n }\n return 'pan-x'\n }\n return touchAction\n }\n // Perform some check on first mount\n useIsomorphicMount(() => {\n if (itemsPerSlide % 2 === 0 && initialStartingPositionRef.current) {\n throw new Error(\n `initialStartingPosition can be only used if itemsPerSlide is an even value.`,\n )\n }\n if (draggingSlideTresholdRef.current < 0) {\n throw new Error('draggingSlideTreshold must be greater than 0')\n }\n if (draggingSlideTresholdRef.current > getSlideValue() / 2) {\n throw new Error(\n `draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(\n getSlideValue() / 2,\n )}`,\n )\n }\n if (itemsPerSlideRef.current < 1) {\n throw new Error(`The itemsPerSlide prop can't be less than 1.`)\n }\n if (itemsPerSlideRef.current > items.length) {\n throw new Error(\n `The itemsPerSlide prop can't be greater than the total length of the items you provide.`,\n )\n }\n if (initialActiveItemRef.current < 0) {\n throw new Error('The initialActiveItem cannot be less than 0.')\n }\n if (initialActiveItemRef.current > items.length) {\n throw new Error(\n 'The initialActiveItem cannot be greater than the total length of the items you provide.',\n )\n }\n if (!shouldResizeOnWindowResize) {\n console.warn(\n 'You set shouldResizeOnWindowResize={false}; be aware that the carousel could behave in a strange way if you also use the fullscreen functionality or if you change the mobile orientation.',\n )\n }\n })\n useIsomorphicMount(() => {\n function handleVisibilityChange() {\n if (document.hidden) {\n windowIsHidden.current = true\n } else {\n windowIsHidden.current = false\n }\n }\n document.addEventListener('visibilitychange', handleVisibilityChange)\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange)\n }\n })\n useIsomorphicMount(() => {\n isFirstMount.current = false\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n initialWindowWidth.current = window.innerWidth\n currentWindowWidth.current = window.innerWidth\n\n if (initialActiveItem > 0) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n if (!withLoop && carouselTrackWrapperRef.current) {\n carouselTrackWrapperRef.current.style.top = '0px'\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n })\n useIsomorphicLayoutEffect(() => {\n if (initialActiveItem < items.length && initialActiveItem !== activeItem.current) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n }\n }, [initialActiveItem])\n useIsomorphicLayoutEffect(() => {\n if (shouldResizeOnWindowResize) {\n window.addEventListener('resize', handleResize)\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [shouldResizeOnWindowResize])\n useIsomorphicLayoutEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxisRef.current === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxisRef.current === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useIsomorphicLayoutEffect(() => {\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n const itemsAreEqual = items.length === prevItems.current.length\n\n if (!itemsAreEqual && items.length < prevItems.current.length) {\n _slideToItem(items.length - 1)\n }\n\n prevItems.current = items\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getFluidWrapperScrollValue, items])\n\n const contextProps = {\n useListenToCustomEvent,\n getIsFullscreen,\n enterFullscreen,\n exitFullscreen,\n getIsAnimating,\n getIsDragging,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem() {\n slideToPrevItem()\n },\n slideToNextItem() {\n slideToNextItem()\n },\n ...(slideType === 'fixed'\n ? {\n slideToItem: _slideToItem,\n getIsActiveItem: (id: string) => {\n return findItemIndex(id) === getCurrentActiveItem()\n },\n getCurrentActiveItem: () => ({\n id: items[getCurrentActiveItem()].id,\n index: getCurrentActiveItem(),\n }),\n }\n : {}),\n }\n\n const handleCarouselFragmentRef = (ref: HTMLDivElement | null) => {\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n function getInitialStyles() {\n const totalValue = (items.length / itemsPerSlide) * 100\n const singleItemValue = 100 / itemsPerSlide\n const cssProp = carouselSlideAxisRef.current === 'x' ? 'left' : 'y'\n const quantityToMove = Math.floor(50 / singleItemValue)\n\n if (slideType === 'fixed') {\n if (initialStartingPositionRef.current === 'center') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * quantityToMove}%)`,\n }\n }\n if (initialStartingPositionRef.current === 'end') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * (quantityToMove * 2)}%)`,\n }\n }\n }\n return {\n [cssProp]: `0px`,\n }\n }\n\n const carouselFragment = (\n <Context.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxisRef.current === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...getInitialStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </Context.Provider>\n )\n const thumbsFragment = (\n <Context.Provider value={contextProps}>{_thumbsFragment}</Context.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext<T = 'fixed' | 'fluid'>() {\n const context = useContext(Context)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context as ContextTypes<T>\n}\n\nexport { useSpringCarousel, useSpringCarouselContext }\n"],"names":["Context","createContext","undefined","defaultDragSpringConfig","config","default","mass","velocity","useSpringCarousel","items","withLoop","draggingSlideTreshold","springConfig","shouldResizeOnWindowResize","withThumbs","enableThumbsWrapperScroll","slideWhenThresholdIsReached","carouselSlideAxis","thumbsSlideAxis","prepareThumbsData","initialActiveItem","initialStartingPosition","disableGestures","gutter","startEndGutter","touchAction","slideAmount","freeScroll","enableFreeScrollDrag","itemsPerSlide","slideType","isFirstMount","useRef","slideActionType","internalItems","length","activeItem","mainCarouselWrapperRef","carouselTrackWrapperRef","isDragging","isAnimating","windowIsHidden","fluidTotalWrapperScrollValue","slideEndReached","currentWindowWidth","initialWindowWidth","prevSlidedValue","prevItems","draggingSlideTresholdRef","itemsPerSlideRef","gutterRef","startEndGutterRef","initialActiveItemRef","initialStartingPositionRef","carouselSlideAxisRef","current","carouselStyles","setCarouselStyles","useSpring","y","x","onChange","value","Math","abs","getCarouselItemWidth","carouselItem","querySelector","Error","getBoundingClientRect","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getMainCarouselWrapperWidth","getFluidWrapperScrollValue","round","Number","getIsFirstItem","getCurrentActiveItem","getSlideValue","itemVal","adjustCarouselWrapperPosition","ref","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","style","top","left","setStartPosition","i","setEndPosition","resize","window","innerWidth","start","immediate","[object Object]","nextValue","handleResize","useIsomorphicLayoutEffect","floor","useListenToCustomEvent","emitObservable","useCustomEventsModule","enterFullscreen","exitFullscreen","getIsFullscreen","useFullscreenModule","thumbsFragment","_thumbsFragment","handleThumbsScroll","useThumbsModule","getWrapperScrollDirection","getIfShouldEnableFluidDrag","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","setDragDirection","setSlideActionType","emitDragObservable","eventName","getSlideActionType","resetAnimation","checkBounds","getIsDragging","setIsDragging","from","to","friction","tension","last","slideToPrevItem","slideToNextItem","getIsLastItem","enabled","axis","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","id","findIndex","item","getToValue","customTo","slideToItem","onRest","nextItem","index","getFromValue","finished","currentItem","nextPrevValue","scrollLeft","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","useIsomorphicMount","console","warn","handleVisibilityChange","document","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","_jsx","Provider","className","stop","display","position","width","height","overflowX","overflowY","animated","div","flexDirection","percentValue","getAnimatedWrapperStyles","totalValue","singleItemValue","cssProp","quantityToMove","getInitialStyles","map","renderItem","_itemsPerSlide","marginRight","marginBottom","flex","useSpringCarouselContext","context","useContext"],"mappings":"mUA8BA,MAAMA,EAAUC,OAA2DC,GAErEC,iCACDC,EAAOC,UACVC,KAAM,EACNC,SAAU,IAkBZ,SAASC,GAAk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,MAAjC/J,GAAqBC,QACrB,CAAE+J,YAAa,GAAGpK,EAAUK,aAC5B,CAAEgK,aAAc,GAAGrK,EAAUK,2BAgQtB6J,IATI,GAAGvD,KAAMQ,KArQ5B,IAAuBgD,cAsRjBtG,GACJgF,EAAC/L,EAAQgM,wBAASlI,MAAO2H,cAAezE,MAG1C,sCACKyE,KACHK,iBAAAA,GACA/E,eAAAA,KAIJ,SAAS0G,IACP,MAAMC,EAAUC,EAAW3N,GAC3B,IAAK0N,EACH,MAAM,IAAItJ,MACR,uGAGJ,OAAOsJ"}
|
package/dist/umd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("react-spring"),require("@use-gesture/react"),require("rxjs"),require("screenfull")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","react-spring","@use-gesture/react","rxjs","screenfull"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactSpringCarousel={},e.ReactJSXRuntime,e.React,e.ReactSpring,e.UseGestureReact,e.rxjs,e.Screenfull)}(this,(function(e,t,n,r,i,o,s){"use strict";function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(s);function l(){const e=n.useRef(new o.Subject);return{useListenToCustomEvent:function(t){n.useEffect((()=>{const n=e.current.subscribe(t);return()=>n.unsubscribe()}),[t])},emitObservable:t=>{e.current.next(t)}}}const a="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function f(e){const t=n.useRef(!1);a((()=>{if(!t.current){const n=e();return t.current=!0,()=>{n&&n()}}}),[])}function d({mainCarouselWrapperRef:e,emitObservable:t,handleResize:r}){const i=n.useRef(!1);function o(e){i.current=e}return f((()=>{function e(){document.fullscreenElement&&(o(!0),t({eventName:"onFullscreenChange",isFullscreen:!0}),r&&r()),document.fullscreenElement||(o(!1),t({eventName:"onFullscreenChange",isFullscreen:!1}),r&&r())}if(c.default.isEnabled)return c.default.on("change",e),()=>{c.default.isEnabled&&c.default.off("change",e)}})),{enterFullscreen:function(t){c.default.isEnabled&&c.default.request(t||e.current)},exitFullscreen:function(){c.default.isEnabled&&c.default.exit()},getIsFullscreen:function(){return i.current}}}function h({items:e,withThumbs:i,thumbsSlideAxis:o="x",springConfig:s,prepareThumbsData:u,getFluidWrapperScrollValue:c=(()=>0),getSlideValue:l=(()=>0),slideType:a}){const d=n.useRef(null),[h,g]=r.useSpring((()=>({x:0,y:0,config:s,onChange:({value:e})=>{d.current&&"fluid"===a&&(d.current["x"===o?"scrollLeft":"scrollTop"]=Math.abs(e[o]))}})));function m(){return d.current["x"===o?"scrollLeft":"scrollTop"]}function p(){var e;return Math.round(Number(null===(e=d.current)||void 0===e?void 0:e["x"===o?"scrollWidth":"scrollHeight"])-d.current.getBoundingClientRect()["x"===o?"width":"height"])}function b(){const e=Math.round(c()/l());return p()/e}f((()=>{if(i&&!d.current)throw new Error("The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.")}));return{thumbsFragment:i?t.jsx(r.animated.div,Object.assign({ref:d,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{h[o].stop()},style:Object.assign({display:"flex",flex:1,position:"relative",width:"100%",height:"100%",flexDirection:"x"===o?"row":"column"},"x"===o?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"})},{children:function(){function t(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return u?u(t(e)):t(e)}().map((({id:e,renderThumb:n})=>{const r=`thumb-${e}`;return t.jsx("div",Object.assign({id:r,className:"thumb-item"},{children:n}),r)}))})):null,handleThumbsScroll:function(t,n){if("fluid"===a){const e=p();if("next"===n){const t=m()+b();g.start({from:{[o]:m()},to:{[o]:t>e?e:t}})}if("prev"===n){const e=m()-b();g.start({from:{[o]:m()},to:{[o]:e<0?0:e}})}}else{const r=d.current.querySelector(`#thumb-${e[t].id}`);if(r){const i=d.current,s="x"===o?"offsetWidth":"offsetHeight",u="x"===o?"scrollLeft":"scrollTop",c=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:r,offsetDimension:s,offsetDirection:"x"===o?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:i,offsetDimension:s}),a=function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:i,scrollDirection:u}),f=function({thumbWrapper:n,thumbOffsetPosition:r,thumbScrollDimension:i,offsetDimension:s}){const u="x"===o?"scrollWidth":"scrollHeight";return t===e.length-1||r-i>n[u]-n[s]?n[u]-n[s]:0===t?0:r-i}({thumbWrapper:i,thumbOffsetPosition:c,thumbScrollDimension:l,offsetDimension:s});g.start({from:{[o]:a},to:{[o]:"prev"===n&&f<0?0:f},onChange:({value:e})=>{"x"===o?d.current.scrollLeft=e.x:d.current.scrollTop=e.y}})}}}}}const g=n.createContext(void 0),m=Object.assign(Object.assign({},r.config.default),{mass:1,velocity:0});const p=n.createContext(void 0);e.useSpringCarousel=function({items:e,withLoop:o=!1,draggingSlideTreshold:s,springConfig:u=r.config.default,shouldResizeOnWindowResize:c=!0,withThumbs:p=!1,enableThumbsWrapperScroll:b=!0,slideWhenThresholdIsReached:v=!0,carouselSlideAxis:x="x",thumbsSlideAxis:y="x",prepareThumbsData:w,initialActiveItem:T=0,initialStartingPosition:j,disableGestures:S=!1,gutter:O=0,startEndGutter:R=0,touchAction:C,slideAmount:I,freeScroll:E=!1,enableFreeScrollDrag:A,itemsPerSlide:N=1,slideType:F="fixed"}){const W=n.useRef(!0),D=n.useRef("initial"),L=o?e.length===N?[...e,...e,...e,...e,...e]:[...e,...e,...e]:e,P=n.useRef(T),$=n.useRef(null),M=n.useRef(null),q=n.useRef(!1),z=n.useRef(!1),B=n.useRef(!1),H=n.useRef(0),k=n.useRef(!1),G=n.useRef(0),V=n.useRef(0),X=n.useRef(0),Y=n.useRef(e),_=n.useRef(null!=s?s:0),J=n.useRef(N),U=n.useRef(O),K=n.useRef(R),Q=n.useRef(T),Z=n.useRef(j),ee=n.useRef(x);J.current=N,U.current=O,K.current=R,Q.current=T,Z.current=j,ee.current=x;const[te,ne]=r.useSpring((()=>({y:0,x:0,onChange:({value:e})=>{$.current&&E&&($.current["x"===ee.current?"scrollLeft":"scrollTop"]=Math.abs(e[ee.current]))}})));function re(){const e=null===(t=M.current)||void 0===t?void 0:t.querySelector(".use-spring-carousel-item");var t;if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===ee.current?"width":"height"]+U.current}function ie(){return te[ee.current].get()}function oe(){return re()*e.length<function(){if(!$.current)throw new Error("mainCarouselWrapperRef is not available");return $.current.getBoundingClientRect()["x"===ee.current?"width":"height"]}()}function se(){var e;return Math.round(Number(null===(e=M.current)||void 0===e?void 0:e["x"===ee.current?"scrollWidth":"scrollHeight"])-M.current.getBoundingClientRect()["x"===ee.current?"width":"height"])}function ue(){return 0===Oe()}function ce(){if(!M.current)return 0;const e=re();if("fluid"===F&&"number"==typeof I){if(I<e)throw new Error("slideAmount must be greater than the width of a single item.");return I}return e}function le(t,n){const r="x"===ee.current?"left":"top";function i(){return re()*e.length}function s(e){o?(t.style.top="0px",t.style[r]=`-${e-K.current}px`):(t.style.left="0px",t.style.top="0px",n&&W.current&&(t.style[r]=`calc(-${n} * 100%)`))}function u(){s(i())}if("fixed"===F){if(J.current>1)switch(Z.current){default:case"start":u();break;case"center":c=J.current,s(i()-ce()*Math.round((c-1)/2));break;case"end":!function(e){s(i()-ce()*Math.round(e-1))}(J.current)}else u()}else u();var c}function ae(){if(G.current=window.innerWidth,"fluid"===F){if(oe())return void ne.start({immediate:!0,[ee.current]:0});if(H.current=se(),k.current){const e=-H.current;ne.start({immediate:!0,[ee.current]:e})}V.current=window.innerWidth}else ne.start({immediate:!0,[ee.current]:-ce()*Oe()});H.current=se(),le(M.current)}function fe(){window.innerWidth===G.current||E||ae()}a((()=>{_.current=s||Math.floor(ce()/2/2),ae()}),[s,N,O,R,T,j,x,y]);const{useListenToCustomEvent:de,emitObservable:he}=l(),{enterFullscreen:ge,exitFullscreen:me,getIsFullscreen:pe}=d({mainCarouselWrapperRef:$,emitObservable:he,handleResize:fe}),{thumbsFragment:be,handleThumbsScroll:ve}=h({withThumbs:p,items:e,thumbsSlideAxis:y,springConfig:u,prepareThumbsData:w,slideType:F,getFluidWrapperScrollValue:se,getSlideValue:ce});function xe(){if(!$.current)throw new Error("Missing mainCarouselWrapperRef.current");return $.current["x"===ee.current?"scrollLeft":"scrollTop"]}function ye(){return"boolean"==typeof A?A:"function"==typeof A&&A()}const we=i.useDrag((e=>{const t=e.dragging,n=e.offset["x"===ee.current?0:1],r=e.movement["x"===ee.current?0:1],i=r>_.current,s=r<-_.current,u=e.direction["x"===ee.current?0:1];function c(){e.cancel()}function l(){Te(u>0?"prev":"next")}function a(){he(Object.assign({eventName:"onDrag",slideActionType:je()},e))}function f(){"fluid"===F?oe()||ue()&&"prev"===je()?ne.start({[ee.current]:0,config:{velocity:e.velocity}}):k.current&&"next"===je()?ne.start({[ee.current]:-H.current,config:{velocity:e.velocity}}):ne.start({[ee.current]:X.current,config:{velocity:e.velocity}}):ne.start({[ee.current]:-Oe()*ce(),config:{velocity:e.velocity}})}function d(){Math.abs(ie())+100>=H.current&&"next"===je()&&(k.current=!0),"prev"===je()&&(k.current=!1)}if(E&&ye())return l(),a(),d(),ne.start({from:{[ee.current]:xe()},to:{[ee.current]:-n},config:{velocity:e.velocity}}),0===xe()&&"prev"===je()?void c():void 0;if(t){if(Ie()||Ce(!0),a(),l(),d(),E){if(ye()){if(0===xe()&&"prev"===je())return void c();ne.start({config:{velocity:e.velocity,friction:50,tension:1e3},from:{[ee.current]:xe()},to:{[ee.current]:-n}})}return}if(ne.start({[ee.current]:n,config:{velocity:e.velocity,friction:50,tension:1e3}}),(i||s)&&oe()&&"fluid"===F)c(),f();else if(k.current&&"next"===je()&&s)k.current=!1,c(),ne.start({[ee.current]:-H.current});else if(v){if(s)return c(),void(!o&&De()?f():Pe(e.velocity));if(i)return c(),void(!o&&ue()?f():Le(e.velocity))}}!e.last||v||!s&&!i||E?!e.last||s||i||E||(f(),he(Object.assign({eventName:"onDrag",slideActionType:je()},e))):s?!o&&De()?f():Pe(e.velocity):i&&(!o&&ue()?f():Le(e.velocity))}),{enabled:!S,axis:ee.current,from:()=>E?"x"===ee.current?[-xe(),0]:[0,-xe()]:[te.x.get(),te.y.get()]});function Te(e){D.current=e}function je(){return D.current}function Se(e){P.current=e}function Oe(){return P.current}function Re(e){z.current=e}function Ce(e){q.current=e}function Ie(){return q.current}function Ee(){const t=Oe();return 0===t?e.length-1:t-1}function Ae(){const t=Oe();return t===e.length-1?0:t+1}function Ne(t){return e.findIndex((e=>e.id===t))}function Fe(e,t){if("number"==typeof e)return{[ee.current]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[ee.current]:-ce()*t}}function We({from:t,to:n=-1,customTo:r,immediate:i=!1,onRest:o=(()=>{}),velocity:s}){i||(Se(n),Re(!0),he({eventName:"onSlideStartChange",slideActionType:je(),nextItem:{index:"fluid"===F?-1:n,id:"fluid"===F?"":e[n].id}})),X.current=Fe(r,n)[x],ne.start(Object.assign(Object.assign(Object.assign(Object.assign({},function(e){return"number"==typeof e?{from:{[ee.current]:e}}:{}}(t)),{to:Fe(r,n)}),s?{config:Object.assign(Object.assign({},m),{velocity:s,friction:void 0,tension:void 0})}:{config:Object.assign({velocity:0},u)}),{immediate:i,onRest:t=>{t.finished&&(Ce(!1),Re(!1),o(),i||he({eventName:"onSlideChange",slideActionType:je(),currentItem:{index:"fluid"===F?-1:Oe(),id:"fluid"===F?"":e[Oe()].id}}))}})),b&&p&&!i&&ve(n,je())}function De(){return Oe()===e.length-1}function Le(t){if(Te("prev"),k.current=!1,"fluid"===F){if(k.current=!1,oe())return;const n=ie()+ce()+200;if(E){const e=$.current.scrollLeft-ce();We({customTo:e<0?0:e,from:$.current.scrollLeft,velocity:t})}else We(n>=0?o?{from:ie()-re()*e.length,velocity:t,customTo:ie()-re()*e.length+ce()}:{customTo:0,velocity:t}:{customTo:ie()+ce(),velocity:t})}else{if(!o&&0===Oe()||B.current)return;ue()?We({from:ie()-ce()*e.length,to:e.length-1,velocity:t}):We({to:Ee(),velocity:t})}}function Pe(t){if(Te("next"),"fluid"===F){if(oe())return;const n=Math.abs(ie()-ce())+100>=H.current;if(E){const e=$.current.scrollLeft+ce()>H.current,n=$.current.scrollLeft+ce();We({velocity:t,customTo:e?H.current:n,from:$.current.scrollLeft})}else if(o&&Math.abs(ie()-ce())>=e.length*re()){const n=re()*e.length;We({from:ie()+n,customTo:ie()+n-ce(),velocity:t})}else{if(k.current)return;n?(k.current=!0,We({customTo:-H.current,velocity:t})):We({customTo:ie()-ce(),velocity:t})}}else{if(!o&&Oe()===L.length-1||B.current)return;Math.abs(ie()-ce()+25)>H.current&&!Ie()?k.current=!0:k.current?We({to:e.length-J.current,velocity:t}):De()?We({from:ie()+ce()*e.length,to:0,velocity:t}):We({to:Ae(),velocity:t})}}function $e(t){let n=0;if(n="string"==typeof t?e.findIndex((e=>e.id===t)):t,n>=e.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(n===Oe()||e.length!==Y.current.length&&Oe()<e.length)return;const r=Ne(Y.current[Oe()].id);Te(Ne(e[n].id)>r?"next":"prev"),We({to:n})}f((()=>{if(N%2==0&&Z.current)throw new Error("initialStartingPosition can be only used if itemsPerSlide is an even value.");if(_.current<0)throw new Error("draggingSlideTreshold must be greater than 0");if(_.current>ce()/2)throw new Error(`draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(ce()/2)}`);if(J.current<1)throw new Error("The itemsPerSlide prop can't be less than 1.");if(J.current>e.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>e.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.")})),f((()=>{function e(){document.hidden?B.current=!0:B.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),f((()=>{W.current=!1,H.current=se(),V.current=window.innerWidth,G.current=window.innerWidth,T>0&&(We({to:T,immediate:!0}),Se(T),!o&&M.current&&(M.current.style.top="0px",M.current.style.left="0px"))})),a((()=>{T<e.length&&T!==P.current&&(We({to:T,immediate:!0}),Se(T))}),[T]),a((()=>{if(c)return window.addEventListener("resize",fe),()=>{window.removeEventListener("resize",fe)}}),[c]),a((()=>{M.current&&("x"===ee.current&&(M.current.style.top="0px"),"y"===ee.current&&(M.current.style.left="0px"))}),[x]),a((()=>{H.current=se();!(e.length===Y.current.length)&&e.length<Y.current.length&&$e(e.length-1),Y.current=e}),[se,e]);const Me=Object.assign({useListenToCustomEvent:de,getIsFullscreen:pe,enterFullscreen:ge,exitFullscreen:me,getIsAnimating:function(){return z.current},getIsDragging:Ie,getIsNextItem:function(t){const n=Ne(t),r=Oe();return o&&r===e.length-1?0===n:n===r+1},getIsPrevItem:function(t){const n=Ne(t),r=Oe();return o&&0===r?n===e.length-1:n===r-1},slideToPrevItem(){Le()},slideToNextItem(){Pe()}},"fixed"===F?{slideToItem:$e,getIsActiveItem:e=>Ne(e)===Oe(),getCurrentActiveItem:()=>({id:e[Oe()].id,index:Oe()})}:{}),qe=t.jsx(g.Provider,Object.assign({value:Me},{children:t.jsx("div",Object.assign({ref:$,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},E?{onWheel(){te[ee.current].stop()}}:{},{style:Object.assign({display:"flex",position:"relative",width:"100%",height:"100%"},E?"x"===ee.current?{overflowX:"auto"}:{overflowY:"auto"}:{})},{children:t.jsx(r.animated.div,Object.assign({},we(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{e&&(M.current=e,le(e,Q.current))},style:Object.assign(Object.assign(Object.assign({display:"flex",position:"relative",touchAction:S?"unset":C||("x"===ee.current?"pan-y":"pan-x"),flexDirection:"x"===ee.current?"row":"column"},function(){const e=`calc(100% - ${2*K.current}px)`;return{width:"x"===ee.current?e:"100%",height:"y"===ee.current?e:"100%"}}()),function(){const t=e.length/N*100,n=100/N,r="x"===ee.current?"left":"y",i=Math.floor(50/n);if("fixed"===F){if("center"===Z.current)return{[r]:`calc(-${t}% + ${n*i}%)`};if("end"===Z.current)return{[r]:`calc(-${t}% + ${n*(2*i)}%)`}}return{[r]:"0px"}}()),E?{}:te)},{children:L.map((({id:e,renderItem:n},r)=>{return t.jsx("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:Object.assign({display:"flex",position:"relative"},(i=J.current,"fixed"===F?Object.assign(Object.assign({},"x"===ee.current?{marginRight:`${U.current}px`}:{marginBottom:`${U.current}px`}),{flex:`1 0 calc(100% / ${i} - ${U.current*(i-1)/i}px)`}):Object.assign({},"x"===ee.current?{marginRight:`${U.current}px`}:{marginBottom:`${U.current}px`})))},{children:n}),`${e}-${r}`);var i}))}))}))})),ze=t.jsx(g.Provider,Object.assign({value:Me},{children:be}));return Object.assign(Object.assign({},Me),{carouselFragment:qe,thumbsFragment:ze})},e.useSpringCarouselContext=function(){const e=n.useContext(g);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e},e.useTransitionCarousel=function({items:e,withLoop:o=!1,withThumbs:s=!1,springConfig:u=r.config.default,thumbsSlideAxis:c="x",enableThumbsWrapperScroll:a=!0,draggingSlideTreshold:f=50,prepareThumbsData:g,toPrevItemSpringProps:m,toNextItemSpringProps:b,disableGestures:v=!1,trail:x,exitBeforeEnter:y=!1,springAnimationProps:w={initial:{opacity:1,position:"absolute"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"absolute"},leave:{opacity:0,position:"absolute"}}}){const T=n.useRef("next"),j=n.useRef(null),S=n.useRef(!1),[O,R]=n.useState(0),{emitObservable:C,useListenToCustomEvent:I}=l(),{enterFullscreen:E,exitFullscreen:A,getIsFullscreen:N}=d({emitObservable:C,mainCarouselWrapperRef:j}),{thumbsFragment:F,handleThumbsScroll:W}=h({items:e,withThumbs:s,thumbsSlideAxis:c,springConfig:u,prepareThumbsData:g,slideType:"fixed"}),D=i.useDrag((({last:t,movement:[n]})=>{if(!P()&&t){const t=n>f,r=n<-f,i=0===O,s=O===e.length-1;if(r){if(!o&&s)return;z(),C({eventName:"onLeftSwipe"})}else if(t){if(!o&&i)return;B(),C({eventName:"onRightSwipe"})}}}),{enabled:!v}),L=r.useTransition(O,Object.assign(Object.assign({config:u},function(){const e=q();return"prev"===e&&m?{initial:Object.assign({},w.initial),from:Object.assign({},m.from),enter:Object.assign({},m.enter),leave:Object.assign({},m.leave)}:"next"===e&&b?{initial:Object.assign({},w.initial),from:Object.assign({},b.from),enter:Object.assign({},b.enter),leave:Object.assign({},b.leave)}:{initial:Object.assign({},w.initial),from:Object.assign({},w.from),enter:Object.assign({},w.enter),leave:Object.assign({},w.leave)}}()),{onStart:()=>$(!0),trail:x,exitBeforeEnter:y,key:e[O].id,onRest:t=>{t.finished&&($(!1),C({eventName:"onSlideChange",slideActionType:q(),currentItem:{index:O,id:e[O].id}}))}}))(((n,i)=>t.jsx(r.animated.div,Object.assign({style:Object.assign(Object.assign({},n),{flex:"1 0 100%",width:"100%",height:"100%"})},{children:e[i].renderItem}))));function P(){return S.current}function $(e){S.current=e}function M(e){T.current=e}function q(){return T.current}function z(){const t=O===e.length-1;o?(M("next"),t?(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:0,id:e[0].id}}),R(0)):(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:O+1,id:e[O+1].id}}),R(O+1))):t||(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:O+1,id:e[O+1].id}}),M("next"),R(O+1))}function B(){const t=0===O;o?(M("prev"),t?(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:e.length-1,id:e[e.length-1].id}}),R(e.length-1)):(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:O-1,id:e[O-1].id}}),R(O-1))):t||(M("prev"),C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:O-1,id:e[O-1].id}}),R(O-1))}function H(t){return e.findIndex((e=>e.id===t))}const k={activeItem:O,slideToItem:function(t){let n=0;if(n="string"==typeof t?e.findIndex((e=>e.id===t)):t,n>=e.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(n===O)return;const r=H(e[O].id),i=H(e[n].id);C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:i,id:e[n].id}}),M(i>r?"next":"prev"),R(n),a&&s&&W(n)},slideToNextItem:z,slideToPrevItem:B,enterFullscreen:E,exitFullscreen:A,useListenToCustomEvent:I,getIsNextItem:function(t){const n=H(t);return o&&O===e.length-1?0===n:n===O+1},getIsPrevItem:function(t){const n=H(t);return o&&0===O?n===e.length-1:n===O-1},getIsAnimating:P,getIsFullscreen:N,getIsActiveItem:e=>H(e)===O,getCurrentActiveItem:()=>({id:e[O].id,index:O})},G=t.jsx(p.Provider,Object.assign({value:k},{children:t.jsx("div",Object.assign({ref:j},D(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:L}))})),V=t.jsx(p.Provider,Object.assign({value:k},{children:F}));return Object.assign({carouselFragment:G,thumbsFragment:V},k)},e.useTransitionCarouselContext=function(){const e=n.useContext(p);if(!e)throw new Error("useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.");return e},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("react-spring"),require("@use-gesture/react"),require("rxjs"),require("screenfull")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","react-spring","@use-gesture/react","rxjs","screenfull"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactSpringCarousel={},e.ReactJSXRuntime,e.React,e.ReactSpring,e.UseGestureReact,e.rxjs,e.Screenfull)}(this,(function(e,t,n,r,i,o,s){"use strict";function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(s);function l(){const e=n.useRef(new o.Subject);return{useListenToCustomEvent:function(t){n.useEffect((()=>{const n=e.current.subscribe(t);return()=>n.unsubscribe()}),[t])},emitObservable:t=>{e.current.next(t)}}}const a="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function f(e){const t=n.useRef(!1);a((()=>{if(!t.current){const n=e();return t.current=!0,()=>{n&&n()}}}),[])}function d({mainCarouselWrapperRef:e,emitObservable:t,handleResize:r}){const i=n.useRef(!1);function o(e){i.current=e}return f((()=>{function e(){document.fullscreenElement&&(o(!0),t({eventName:"onFullscreenChange",isFullscreen:!0}),r&&r()),document.fullscreenElement||(o(!1),t({eventName:"onFullscreenChange",isFullscreen:!1}),r&&r())}if(c.default.isEnabled)return c.default.on("change",e),()=>{c.default.isEnabled&&c.default.off("change",e)}})),{enterFullscreen:function(t){c.default.isEnabled&&c.default.request(t||e.current)},exitFullscreen:function(){c.default.isEnabled&&c.default.exit()},getIsFullscreen:function(){return i.current}}}function h({items:e,withThumbs:i,thumbsSlideAxis:o="x",springConfig:s,prepareThumbsData:u,getFluidWrapperScrollValue:c=(()=>0),getSlideValue:l=(()=>0),slideType:a}){const d=n.useRef(null),[h,g]=r.useSpring((()=>({x:0,y:0,config:s,onChange:({value:e})=>{d.current&&"fluid"===a&&(d.current["x"===o?"scrollLeft":"scrollTop"]=Math.abs(e[o]))}})));function m(){return d.current["x"===o?"scrollLeft":"scrollTop"]}function p(){var e;return Math.round(Number(null===(e=d.current)||void 0===e?void 0:e["x"===o?"scrollWidth":"scrollHeight"])-d.current.getBoundingClientRect()["x"===o?"width":"height"])}function b(){const e=Math.round(c()/l());return p()/e}f((()=>{if(i&&!d.current)throw new Error("The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.")}));return{thumbsFragment:i?t.jsx(r.animated.div,Object.assign({ref:d,className:"use-spring-carousel-thumbs-wrapper",onWheel:()=>{h[o].stop()},style:Object.assign({display:"flex",flex:1,position:"relative",width:"100%",height:"100%",flexDirection:"x"===o?"row":"column"},"x"===o?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"})},{children:function(){function t(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return u?u(t(e)):t(e)}().map((({id:e,renderThumb:n})=>{const r=`thumb-${e}`;return t.jsx("div",Object.assign({id:r,className:"thumb-item"},{children:n}),r)}))})):null,handleThumbsScroll:function(t,n){if("fluid"===a){const e=p();if("next"===n){const t=m()+b();g.start({from:{[o]:m()},to:{[o]:t>e?e:t}})}if("prev"===n){const e=m()-b();g.start({from:{[o]:m()},to:{[o]:e<0?0:e}})}}else{const r=d.current.querySelector(`#thumb-${e[t].id}`);if(r){const i=d.current,s="x"===o?"offsetWidth":"offsetHeight",u="x"===o?"scrollLeft":"scrollTop",c=function({thumbNode:e,offsetDirection:t,offsetDimension:n}){return e[t]+e[n]/2}({thumbNode:r,offsetDimension:s,offsetDirection:"x"===o?"offsetLeft":"offsetTop"}),l=function({thumbWrapper:e,offsetDimension:t}){return e[t]/2}({thumbWrapper:i,offsetDimension:s}),a=function({thumbWrapper:e,scrollDirection:t}){return e[t]}({thumbWrapper:i,scrollDirection:u}),f=function({thumbWrapper:n,thumbOffsetPosition:r,thumbScrollDimension:i,offsetDimension:s}){const u="x"===o?"scrollWidth":"scrollHeight";return t===e.length-1||r-i>n[u]-n[s]?n[u]-n[s]:0===t?0:r-i}({thumbWrapper:i,thumbOffsetPosition:c,thumbScrollDimension:l,offsetDimension:s});g.start({from:{[o]:a},to:{[o]:"prev"===n&&f<0?0:f},onChange:({value:e})=>{"x"===o?d.current.scrollLeft=e.x:d.current.scrollTop=e.y}})}}}}}const g=n.createContext(void 0),m=Object.assign(Object.assign({},r.config.default),{mass:1,velocity:0});const p=n.createContext(void 0);e.useSpringCarousel=function({items:e,withLoop:o=!1,draggingSlideTreshold:s,springConfig:u=r.config.default,shouldResizeOnWindowResize:c=!0,withThumbs:p=!1,enableThumbsWrapperScroll:b=!0,slideWhenThresholdIsReached:v=!0,carouselSlideAxis:x="x",thumbsSlideAxis:y="x",prepareThumbsData:w,initialActiveItem:T=0,initialStartingPosition:j,disableGestures:O=!1,gutter:S=0,startEndGutter:R=0,touchAction:C,slideAmount:I,freeScroll:E=!1,enableFreeScrollDrag:A,itemsPerSlide:N=1,slideType:F="fixed"}){const W=n.useRef(!0),D=n.useRef("initial"),L=o?e.length===N?[...e,...e,...e,...e,...e]:[...e,...e,...e]:e,P=n.useRef(T),$=n.useRef(null),M=n.useRef(null),q=n.useRef(!1),z=n.useRef(!1),B=n.useRef(!1),H=n.useRef(0),k=n.useRef(!1),G=n.useRef(0),V=n.useRef(0),X=n.useRef(0),Y=n.useRef(e),_=n.useRef(null!=s?s:0),J=n.useRef(N),U=n.useRef(S),K=n.useRef(R),Q=n.useRef(T),Z=n.useRef(j),ee=n.useRef(x);J.current=N,U.current=S,K.current=R,Q.current=T,Z.current=j,ee.current=x;const[te,ne]=r.useSpring((()=>({y:0,x:0,onChange:({value:e})=>{$.current&&E&&($.current["x"===ee.current?"scrollLeft":"scrollTop"]=Math.abs(e[ee.current]))}})));function re(){const e=null===(t=M.current)||void 0===t?void 0:t.querySelector(".use-spring-carousel-item");var t;if(!e)throw Error("No carousel items available!");return e.getBoundingClientRect()["x"===ee.current?"width":"height"]+U.current}function ie(){return te[ee.current].get()}function oe(){return re()*e.length<function(){if(!$.current)throw new Error("mainCarouselWrapperRef is not available");return $.current.getBoundingClientRect()["x"===ee.current?"width":"height"]}()}function se(){var e;return Math.round(Number(null===(e=M.current)||void 0===e?void 0:e["x"===ee.current?"scrollWidth":"scrollHeight"])-M.current.getBoundingClientRect()["x"===ee.current?"width":"height"])}function ue(){return 0===Se()}function ce(){if(!M.current)return 0;const e=re();if("fluid"===F&&"number"==typeof I){if(I<e)throw new Error("slideAmount must be greater than the width of a single item.");return I}return e}function le(t,n){const r="x"===ee.current?"left":"top";function i(){return re()*e.length}function s(e){o?(t.style.top="0px",t.style[r]=`-${e-K.current}px`):(t.style.left="0px",t.style.top="0px",n&&W.current&&(t.style[r]=`calc(-${n} * 100%)`))}function u(){s(i())}if("fixed"===F){if(J.current>1)switch(Z.current){default:case"start":u();break;case"center":c=J.current,s(i()-ce()*Math.round((c-1)/2));break;case"end":!function(e){s(i()-ce()*Math.round(e-1))}(J.current)}else u()}else u();var c}function ae(){if(G.current=window.innerWidth,"fluid"===F){if(oe())return void ne.start({immediate:!0,[ee.current]:0});if(H.current=se(),k.current){const e=-H.current;ne.start({immediate:!0,[ee.current]:e})}V.current=window.innerWidth}else ne.start({immediate:!0,[ee.current]:-ce()*Se()});H.current=se(),le(M.current)}function fe(){window.innerWidth===G.current||E||ae()}a((()=>{_.current=s||Math.floor(ce()/2/2),ae()}),[s,N,S,R,T,j,x,y]);const{useListenToCustomEvent:de,emitObservable:he}=l(),{enterFullscreen:ge,exitFullscreen:me,getIsFullscreen:pe}=d({mainCarouselWrapperRef:$,emitObservable:he,handleResize:fe}),{thumbsFragment:be,handleThumbsScroll:ve}=h({withThumbs:p,items:e,thumbsSlideAxis:y,springConfig:u,prepareThumbsData:w,slideType:F,getFluidWrapperScrollValue:se,getSlideValue:ce});function xe(){if(!$.current)throw new Error("Missing mainCarouselWrapperRef.current");return $.current["x"===ee.current?"scrollLeft":"scrollTop"]}function ye(){return"boolean"==typeof A?A:"function"==typeof A&&A()}const we=i.useDrag((e=>{const t=e.dragging,n=e.offset["x"===ee.current?0:1],r=e.movement["x"===ee.current?0:1],i=r>_.current,s=r<-_.current,c=e.direction["x"===ee.current?0:1];function l(){e.cancel()}function a(){Te(c>0?"prev":"next")}function f(){he(Object.assign({eventName:"onDrag",slideActionType:je()},e))}function d(){"fluid"===F?oe()||ue()&&"prev"===je()?ne.start({[ee.current]:0,config:Object.assign({velocity:e.velocity},u)}):k.current&&"next"===je()?ne.start({[ee.current]:-H.current,config:Object.assign({velocity:e.velocity},u)}):ne.start({[ee.current]:X.current,config:Object.assign({velocity:e.velocity},u)}):ne.start({[ee.current]:-Se()*ce(),config:Object.assign({velocity:e.velocity},u)})}function h(){Math.abs(ie())+100>=H.current&&"next"===je()&&(k.current=!0),"prev"===je()&&(k.current=!1)}if(E&&ye())return t&&(Ie()||Ce(!0),a(),f(),h()),ne.start({from:{[ee.current]:xe()},to:{[ee.current]:-n},config:{velocity:e.velocity,friction:50,tension:1400}}),0===xe()&&"prev"===je()?void l():void(e.last&&("prev"===je()?Le(e.velocity):Pe(e.velocity),Ce(!1)));if(t){if(Ie()||Ce(!0),f(),a(),h(),E){if(ye()){if(0===xe()&&"prev"===je())return void l();ne.start({config:{velocity:e.velocity,friction:50,tension:1400},from:{[ee.current]:xe()},to:{[ee.current]:-n}})}return}if(ne.start({[ee.current]:n,config:{velocity:e.velocity,friction:50,tension:1e3}}),(i||s)&&oe()&&"fluid"===F)l(),d();else if(k.current&&"next"===je()&&s)k.current=!1,l(),ne.start({[ee.current]:-H.current});else if(v){if(s)return l(),void(!o&&De()?d():Pe(e.velocity));if(i)return l(),void(!o&&ue()?d():Le(e.velocity))}}if(e.last&&!v&&(s||i)&&!E)return Ce(!1),void(s?!o&&De()?d():Pe(e.velocity):i&&(!o&&ue()?d():Le(e.velocity)));!e.last||s||i||E||(d(),he(Object.assign({eventName:"onDrag",slideActionType:je()},e)))}),{enabled:!O,axis:ee.current,from:()=>E?"x"===ee.current?[-xe(),0]:[0,-xe()]:[te.x.get(),te.y.get()]});function Te(e){D.current=e}function je(){return D.current}function Oe(e){P.current=e}function Se(){return P.current}function Re(e){z.current=e}function Ce(e){q.current=e}function Ie(){return q.current}function Ee(){const t=Se();return 0===t?e.length-1:t-1}function Ae(){const t=Se();return t===e.length-1?0:t+1}function Ne(t){return e.findIndex((e=>e.id===t))}function Fe(e,t){if("number"==typeof e)return{[ee.current]:e};if("number"!=typeof t)throw new Error("to values is not a number!");return{[ee.current]:-ce()*t}}function We({from:t,to:n=-1,customTo:r,immediate:i=!1,onRest:o=(()=>{}),velocity:s}){i||(Oe(n),Re(!0),he({eventName:"onSlideStartChange",slideActionType:je(),nextItem:{index:"fluid"===F?-1:n,id:"fluid"===F?"":e[n].id}})),X.current=Fe(r,n)[x],ne.start(Object.assign(Object.assign(Object.assign(Object.assign({},function(e){return"number"==typeof e?{from:{[ee.current]:e}}:{}}(t)),{to:Fe(r,n)}),s?{config:Object.assign(Object.assign({},m),{velocity:s,friction:void 0,tension:void 0})}:{config:Object.assign({velocity:0},u)}),{immediate:i,onRest:t=>{t.finished&&(Ce(!1),Re(!1),o(),i||he({eventName:"onSlideChange",slideActionType:je(),currentItem:{index:"fluid"===F?-1:Se(),id:"fluid"===F?"":e[Se()].id}}))}})),b&&p&&!i&&ve(n,je())}function De(){return Se()===e.length-1}function Le(t){if(Te("prev"),k.current=!1,"fluid"===F){if(k.current=!1,oe())return;const n=ie()+ce()+200;if(E){const e=$.current.scrollLeft-ce();We({customTo:e<0?0:e,from:$.current.scrollLeft,velocity:t})}else We(n>=0?o?{from:ie()-re()*e.length,velocity:t,customTo:ie()-re()*e.length+ce()}:{customTo:0,velocity:t}:{customTo:ie()+ce(),velocity:t})}else{if(!o&&0===Se()||B.current)return;ue()?We({from:ie()-ce()*e.length,to:e.length-1,velocity:t}):We({to:Ee(),velocity:t})}}function Pe(t){if(Te("next"),"fluid"===F){if(oe())return;const n=Math.abs(ie()-ce())+100>=H.current;if(E){const e=$.current.scrollLeft+ce()>H.current,n=$.current.scrollLeft+ce();We({velocity:t,customTo:e?H.current:n,from:$.current.scrollLeft})}else if(o&&Math.abs(ie()-ce())>=e.length*re()){const n=re()*e.length;We({from:ie()+n,customTo:ie()+n-ce(),velocity:t})}else{if(k.current)return;n?(k.current=!0,We({customTo:-H.current,velocity:t})):We({customTo:ie()-ce(),velocity:t})}}else{if(!o&&Se()===L.length-1||B.current)return;Math.abs(ie()-ce()+25)>H.current&&!Ie()?k.current=!0:k.current?We({to:e.length-J.current,velocity:t}):De()?We({from:ie()+ce()*e.length,to:0,velocity:t}):We({to:Ae(),velocity:t})}}function $e(t){let n=0;if(n="string"==typeof t?e.findIndex((e=>e.id===t)):t,n>=e.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(n===Se()||e.length!==Y.current.length&&Se()<e.length)return;const r=Ne(Y.current[Se()].id);Te(Ne(e[n].id)>r?"next":"prev"),We({to:n})}f((()=>{if(N%2==0&&Z.current)throw new Error("initialStartingPosition can be only used if itemsPerSlide is an even value.");if(_.current<0)throw new Error("draggingSlideTreshold must be greater than 0");if(_.current>ce()/2)throw new Error(`draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(ce()/2)}`);if(J.current<1)throw new Error("The itemsPerSlide prop can't be less than 1.");if(J.current>e.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>e.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.")})),f((()=>{function e(){document.hidden?B.current=!0:B.current=!1}return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}})),f((()=>{W.current=!1,H.current=se(),V.current=window.innerWidth,G.current=window.innerWidth,T>0&&(We({to:T,immediate:!0}),Oe(T),!o&&M.current&&(M.current.style.top="0px",M.current.style.left="0px"))})),a((()=>{T<e.length&&T!==P.current&&(We({to:T,immediate:!0}),Oe(T))}),[T]),a((()=>{if(c)return window.addEventListener("resize",fe),()=>{window.removeEventListener("resize",fe)}}),[c]),a((()=>{M.current&&("x"===ee.current&&(M.current.style.top="0px"),"y"===ee.current&&(M.current.style.left="0px"))}),[x]),a((()=>{H.current=se();!(e.length===Y.current.length)&&e.length<Y.current.length&&$e(e.length-1),Y.current=e}),[se,e]);const Me=Object.assign({useListenToCustomEvent:de,getIsFullscreen:pe,enterFullscreen:ge,exitFullscreen:me,getIsAnimating:function(){return z.current},getIsDragging:Ie,getIsNextItem:function(t){const n=Ne(t),r=Se();return o&&r===e.length-1?0===n:n===r+1},getIsPrevItem:function(t){const n=Ne(t),r=Se();return o&&0===r?n===e.length-1:n===r-1},slideToPrevItem(){Le()},slideToNextItem(){Pe()}},"fixed"===F?{slideToItem:$e,getIsActiveItem:e=>Ne(e)===Se(),getCurrentActiveItem:()=>({id:e[Se()].id,index:Se()})}:{}),qe=t.jsx(g.Provider,Object.assign({value:Me},{children:t.jsx("div",Object.assign({ref:$,className:"use-spring-carousel-main-wrapper","data-testid":"use-spring-carousel-wrapper"},E?{onWheel(){te[ee.current].stop()}}:{},{style:Object.assign({display:"flex",position:"relative",width:"100%",height:"100%"},E?"x"===ee.current?{overflowX:"auto"}:{overflowY:"auto"}:{})},{children:t.jsx(r.animated.div,Object.assign({},we(),{className:"use-spring-carousel-track-wrapper","data-testid":"use-spring-carousel-animated-wrapper",ref:e=>{e&&(M.current=e,le(e,Q.current))},style:Object.assign(Object.assign(Object.assign({display:"flex",position:"relative",touchAction:O?"unset":C||("x"===ee.current?"pan-y":"pan-x"),flexDirection:"x"===ee.current?"row":"column"},function(){const e=`calc(100% - ${2*K.current}px)`;return{width:"x"===ee.current?e:"100%",height:"y"===ee.current?e:"100%"}}()),function(){const t=e.length/N*100,n=100/N,r="x"===ee.current?"left":"y",i=Math.floor(50/n);if("fixed"===F){if("center"===Z.current)return{[r]:`calc(-${t}% + ${n*i}%)`};if("end"===Z.current)return{[r]:`calc(-${t}% + ${n*(2*i)}%)`}}return{[r]:"0px"}}()),E?{}:te)},{children:L.map((({id:e,renderItem:n},r)=>{return t.jsx("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:Object.assign({display:"flex",position:"relative"},(i=J.current,"fixed"===F?Object.assign(Object.assign({},"x"===ee.current?{marginRight:`${U.current}px`}:{marginBottom:`${U.current}px`}),{flex:`1 0 calc(100% / ${i} - ${U.current*(i-1)/i}px)`}):Object.assign({},"x"===ee.current?{marginRight:`${U.current}px`}:{marginBottom:`${U.current}px`})))},{children:n}),`${e}-${r}`);var i}))}))}))})),ze=t.jsx(g.Provider,Object.assign({value:Me},{children:be}));return Object.assign(Object.assign({},Me),{carouselFragment:qe,thumbsFragment:ze})},e.useSpringCarouselContext=function(){const e=n.useContext(g);if(!e)throw new Error("useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.");return e},e.useTransitionCarousel=function({items:e,withLoop:o=!1,withThumbs:s=!1,springConfig:u=r.config.default,thumbsSlideAxis:c="x",enableThumbsWrapperScroll:a=!0,draggingSlideTreshold:f=50,prepareThumbsData:g,toPrevItemSpringProps:m,toNextItemSpringProps:b,disableGestures:v=!1,trail:x,exitBeforeEnter:y=!1,springAnimationProps:w={initial:{opacity:1,position:"absolute"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"absolute"},leave:{opacity:0,position:"absolute"}}}){const T=n.useRef("next"),j=n.useRef(null),O=n.useRef(!1),[S,R]=n.useState(0),{emitObservable:C,useListenToCustomEvent:I}=l(),{enterFullscreen:E,exitFullscreen:A,getIsFullscreen:N}=d({emitObservable:C,mainCarouselWrapperRef:j}),{thumbsFragment:F,handleThumbsScroll:W}=h({items:e,withThumbs:s,thumbsSlideAxis:c,springConfig:u,prepareThumbsData:g,slideType:"fixed"}),D=i.useDrag((({last:t,movement:[n]})=>{if(!P()&&t){const t=n>f,r=n<-f,i=0===S,s=S===e.length-1;if(r){if(!o&&s)return;z(),C({eventName:"onLeftSwipe"})}else if(t){if(!o&&i)return;B(),C({eventName:"onRightSwipe"})}}}),{enabled:!v}),L=r.useTransition(S,Object.assign(Object.assign({config:u},function(){const e=q();return"prev"===e&&m?{initial:Object.assign({},w.initial),from:Object.assign({},m.from),enter:Object.assign({},m.enter),leave:Object.assign({},m.leave)}:"next"===e&&b?{initial:Object.assign({},w.initial),from:Object.assign({},b.from),enter:Object.assign({},b.enter),leave:Object.assign({},b.leave)}:{initial:Object.assign({},w.initial),from:Object.assign({},w.from),enter:Object.assign({},w.enter),leave:Object.assign({},w.leave)}}()),{onStart:()=>$(!0),trail:x,exitBeforeEnter:y,key:e[S].id,onRest:t=>{t.finished&&($(!1),C({eventName:"onSlideChange",slideActionType:q(),currentItem:{index:S,id:e[S].id}}))}}))(((n,i)=>t.jsx(r.animated.div,Object.assign({style:Object.assign(Object.assign({},n),{flex:"1 0 100%",width:"100%",height:"100%"})},{children:e[i].renderItem}))));function P(){return O.current}function $(e){O.current=e}function M(e){T.current=e}function q(){return T.current}function z(){const t=S===e.length-1;o?(M("next"),t?(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:0,id:e[0].id}}),R(0)):(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S+1,id:e[S+1].id}}),R(S+1))):t||(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S+1,id:e[S+1].id}}),M("next"),R(S+1))}function B(){const t=0===S;o?(M("prev"),t?(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:e.length-1,id:e[e.length-1].id}}),R(e.length-1)):(C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S-1,id:e[S-1].id}}),R(S-1))):t||(M("prev"),C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:S-1,id:e[S-1].id}}),R(S-1))}function H(t){return e.findIndex((e=>e.id===t))}const k={activeItem:S,slideToItem:function(t){let n=0;if(n="string"==typeof t?e.findIndex((e=>e.id===t)):t,n>=e.length)throw Error("The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.");if(n===S)return;const r=H(e[S].id),i=H(e[n].id);C({eventName:"onSlideStartChange",slideActionType:q(),nextItem:{index:i,id:e[n].id}}),M(i>r?"next":"prev"),R(n),a&&s&&W(n)},slideToNextItem:z,slideToPrevItem:B,enterFullscreen:E,exitFullscreen:A,useListenToCustomEvent:I,getIsNextItem:function(t){const n=H(t);return o&&S===e.length-1?0===n:n===S+1},getIsPrevItem:function(t){const n=H(t);return o&&0===S?n===e.length-1:n===S-1},getIsAnimating:P,getIsFullscreen:N,getIsActiveItem:e=>H(e)===S,getCurrentActiveItem:()=>({id:e[S].id,index:S})},G=t.jsx(p.Provider,Object.assign({value:k},{children:t.jsx("div",Object.assign({ref:j},D(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:L}))})),V=t.jsx(p.Provider,Object.assign({value:k},{children:F}));return Object.assign({carouselFragment:G,thumbsFragment:V},k)},e.useTransitionCarouselContext=function(){const e=n.useContext(p);if(!e)throw new Error("useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.");return e},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|