react-spring-carousel 2.0.19 → 3.0.0-beta001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index2.js +1 -1
- package/dist/esm/index2.js.map +1 -1
- package/dist/esm/useSpringCarousel.js +2 -0
- package/dist/esm/useSpringCarousel.js.map +1 -0
- package/dist/esm/useThumbsModule-ce69c348.js +2 -0
- package/dist/esm/useThumbsModule-ce69c348.js.map +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/mockedItems.d.ts +10 -0
- package/dist/types/modules/index.d.ts +1 -1
- package/dist/types/modules/useEventsModule.d.ts +44 -0
- package/dist/types/modules/useFullscreenModule.d.ts +6 -6
- package/dist/types/modules/useThumbsModule.d.ts +7 -13
- package/dist/types/types/common.d.ts +2 -0
- package/dist/types/types/index.d.ts +8 -49
- package/dist/types/types/internals.d.ts +82 -0
- package/dist/types/useSpringCarousel.d.ts +7 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +48 -75
- package/dist/esm/index3.js +0 -2
- package/dist/esm/index3.js.map +0 -1
- package/dist/esm/index4.js +0 -2
- package/dist/esm/index4.js.map +0 -1
- package/dist/esm/useThumbsModule-0944decf.js +0 -2
- package/dist/esm/useThumbsModule-0944decf.js.map +0 -1
- package/dist/types/modules/useCustomEventsModule.d.ts +0 -5
- package/dist/types/types/useSpringCarousel.d.ts +0 -124
- package/dist/types/types/useTransitionCarousel.d.ts +0 -39
- package/dist/types/useSpringCarousel/index.d.ts +0 -8
- package/dist/types/useTransitionCarousel/index.d.ts +0 -24
- package/dist/types/utils.d.ts +0 -5
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: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})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react"),require("@use-gesture/react"),require("screenfull")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react","@use-gesture/react","screenfull"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactSpringCarousel={},e.ReactJSXRuntime,e.web,e.React,e.UseGestureReact,e.Screenfull)}(this,(function(e,t,r,n,i,c){"use strict";const u="RSC::Event";function o({thumbsSlideAxis:e="x",withThumbs:i=!1,prepareThumbsData:c,items:u}){const o=n.useRef(null),[s,l]=r.useSpring((()=>({val:0})));function a(){var t;return Math.round(Number(null===(t=o.current)||void 0===t?void 0:t["x"===e?"scrollWidth":"scrollHeight"])-o.current.getBoundingClientRect()["x"===e?"width":"height"])}return{thumbsFragment:i?t.jsx("div",Object.assign({className:"use-spring-carousel-thumbs-wrapper",ref:o,onWheel:()=>s.val.stop(),style:Object.assign({display:"flex",flex:"1",position:"relative",width:"100%",height:"100%",flexDirection:"x"===e?"row":"column"},"x"===e?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"})},{children:function(){function e(e){return e.map((e=>({id:e.id,renderThumb:e.renderThumb})))}return c?c(e(u)):e(u)}().map((({id:e,renderThumb:r})=>{const n=`thumb-item-${e}`;return t.jsx("div",Object.assign({id:n,className:"thumb-item"},{children:r}),n)}))})):null,handleScroll:function(t){var r,n;const i=o.current?o.current.querySelector(`#thumb-item-${u[t].id}`):null;if(i&&o.current&&!function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}(i)){const t=i.offsetLeft,c=t>a()?a():t;l.start({from:{val:null!==(n=null===(r=o.current)||void 0===r?void 0:r["x"===e?"scrollLeft":"scrollTop"])&&void 0!==n?n:0},to:{val:c},onChange:({value:t})=>{o.current&&(o.current["x"===e?"scrollLeft":"scrollTop"]=Math.abs(t.val))}})}}}}const s=n.createContext(void 0);e.useSpringCarousel=function({items:e,init:s=!0,withThumbs:l,thumbsSlideAxis:a="x",itemsPerSlide:d=1,slideType:f="fixed",gutter:m=0,withLoop:g=!1,startEndGutter:h=0,carouselSlideAxis:v="x",disableGestures:x=!1,draggingSlideTreshold:p,slideWhenThresholdIsReached:b=!1,freeScroll:w,enableFreeScrollDrag:y,initialStartingPosition:E,prepareThumbsData:R,initialActiveItem:T=0}){const j=n.useRef(0),C=n.useRef(null!=p?p:0),I=n.useRef("initial"),S=n.useRef("initial"),O=n.useRef(0),[L,M]=r.useSpring((()=>({val:0,pause:!s,onChange({value:e}){w&&$.current?(te(),"x"===v?$.current.scrollLeft=Math.abs(e.val):$.current.scrollTop=Math.abs(e.val)):W.current&&(W.current.style.transform="x"===v?`translate3d(${e.val}px, 0px,0px)`:`translate3d(0px,${e.val}px,0px)`)}}))),F=n.useRef(T),A=n.useRef(0===T),N=n.useRef(!1),$=n.useRef(null),W=n.useRef(null),q=n.useCallback((()=>g?[...e.map((e=>Object.assign(Object.assign({},e),{id:`prev-repeated-item-${e.id}`}))),...e,...e.map((e=>Object.assign(Object.assign({},e),{id:`next-repeated-item-${e.id}`})))]:[...e]),[e,g])(),{emitEvent:D,useListenToCustomEvent:k}=function(){const e=n.useRef(null);return n.useEffect((()=>{e.current=document.createElement("div")}),[]),{useListenToCustomEvent:function(t){n.useEffect((()=>{function r(e){t(e.detail)}if(e.current)return e.current.addEventListener(u,r,!1),()=>{var t;null===(t=e.current)||void 0===t||t.removeEventListener(u,r,!1)}}),[])},emitEvent:function(t){if(e.current){const r=new CustomEvent(u,{detail:t});e.current.dispatchEvent(r)}}}}(),{thumbsFragment:B,handleScroll:H}=o({withThumbs:!!l,thumbsSlideAxis:a,prepareThumbsData:R,items:e}),{enterFullscreen:z,exitFullscreen:P,getIsFullscreen:G}=function({mainCarouselWrapperRef:e,emitEvent:t,handleResize:r}){const i=n.useRef(!1);function u(e){i.current=e}return n.useEffect((()=>{function e(){document.fullscreenElement&&(u(!0),t({eventName:"onFullscreenChange",isFullscreen:!0}),r&&r()),document.fullscreenElement||(u(!1),t({eventName:"onFullscreenChange",isFullscreen:!1}),r&&r())}if(c.isEnabled)return c.on("change",e),()=>{c.isEnabled&&c.off("change",e)}}),[]),{enterFullscreen:function(t){c.isEnabled&&c.request(t||e.current)},exitFullscreen:function(){c.isEnabled&&c.exit()},getIsFullscreen:function(){return i.current}}}({mainCarouselWrapperRef:$,emitEvent:D,handleResize:()=>K()});function X(){var e;const t=null===(e=$.current)||void 0===e?void 0:e.querySelector(".use-spring-carousel-item");if(!t)throw Error("No carousel items available!");return t.getBoundingClientRect()["x"===v?"width":"height"]+m}function Y({from:t,to:n,nextActiveItem:i,immediate:c=!1,slideMode:u}){S.current=u,"number"==typeof i&&(w||(F.current=i),D({eventName:"onSlideStartChange",slideActionType:I.current,slideMode:S.current,nextItem:{startReached:A.current,endReached:N.current,index:w?-1:F.current,id:w?"":e[F.current].id}})),O.current=n,M.start({immediate:c,from:{val:t},to:{val:n},config:Object.assign(Object.assign({},r.config.default),{velocity:L.val.velocity}),onRest(t){!c&&t.finished&&D({eventName:"onSlideChange",slideActionType:I.current,slideMode:S.current,currentItem:{startReached:A.current,endReached:N.current,index:w?-1:F.current,id:w?"":e[F.current].id}})}}),l&&!c&&H(F.current)}function J(){var t;return g?X()*e.length:Math.round(Number(null===(t=W.current)||void 0===t?void 0:t["x"===v?"scrollWidth":"scrollHeight"])-W.current.getBoundingClientRect()["x"===v?"width":"height"])}function U(){var e;const t=null===(e=W.current)||void 0===e?void 0:e.querySelector(".use-spring-carousel-item");if(!t)throw Error("No carousel items available!");return t.getBoundingClientRect()["x"===v?"width":"height"]+m}function K(){const t="x"===v?"left":"top";function r(e){const r=W.current;r&&(g?(r.style.top="0px",r.style.left="0px",r.style[t]=`-${e-h}px`):(r.style.left="0px",r.style.top="0px"))}const n=Math.abs(Q());if(n<J()&&N.current&&(N.current=!1),n>J()){const e=-J();return N.current=!0,O.current=e,void M.start({immediate:!0,val:e})}if(r("center"===E?U()*e.length-X()*Math.round((d-1)/2):"end"===E?U()*e.length-X()*Math.round(d-1):U()*e.length),!w&&"fixed"===f){const e=-X()*F.current;O.current=e,M.start({immediate:!0,val:e})}}function Q(){return w&&$.current?$.current["x"===v?"scrollLeft":"scrollTop"]:L.val.get()}function V(e,t){if(w&&"next"===e){const e=O.current+X();return e>J()?J():e}if(w&&"prev"===e){const e=O.current-X();return e<0?0:e}return"next"===e?t?-t*X():O.current-X():t?-t*X():O.current+X()}function Z(t="click",r){if(!s||A.current&&!g)return;I.current="prev",N.current=!1;const n=r||F.current-1;if(!g){const e=V("prev",r)+X()/3>0;if(A.current)return;if(e)return A.current=!0,N.current=!1,void Y({slideMode:t,from:Q(),to:0,nextActiveItem:0})}if(g&&A.current)return A.current=!1,N.current=!0,void Y({slideMode:t,from:Q()-X()*e.length,to:-X()*e.length+X(),nextActiveItem:e.length-1});0===n&&(A.current=!0),n!==e.length-1&&-1!==n||(N.current=!0),Y({slideMode:t,from:Q(),to:V("prev",r),nextActiveItem:n})}function _(t="click",r){if(!s||N.current&&!g)return;I.current="next",A.current=!1;const n=r||F.current+1;if(!g){const e=Math.abs(V("next",r))>J()-X()/3;if(N.current)return;if(e)return A.current=!1,N.current=!0,void Y({slideMode:t,from:Q(),to:-J(),nextActiveItem:n})}if(g&&N.current)return N.current=!1,A.current=!0,void Y({slideMode:t,from:Q()+X()*e.length,to:0,nextActiveItem:0});0===n&&(A.current=!0),n===e.length-1&&(N.current=!0),Y({slideMode:t,from:Q(),to:V("next",r),nextActiveItem:n})}n.useEffect((()=>{j.current=window.innerWidth}),[]),n.useEffect((()=>{K()}),[E,d,g,h,m,w,f,s]),n.useLayoutEffect((()=>{W.current&&K()}),[]),n.useEffect((()=>{C.current=p||Math.floor(X()/2/2)}),[p]),n.useEffect((()=>{function e(){window.innerWidth!==j.current&&(j.current=window.innerWidth,K())}return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]);const ee=i.useDrag((e=>{const t=e.dragging,n=e.offset["x"===v?0:1],i=e.movement["x"===v?0:1],c=e.direction["x"===v?0:1],u=i>C.current,o=i<-C.current;if(t)return I.current=c>0?"prev":"next",D(Object.assign(Object.assign({},e),{eventName:"onDrag",slideActionType:I.current})),w?"prev"===I.current&&n>0?(e.cancel(),void M.start({from:{val:Q()},to:{val:0},config:{velocity:e.velocity,friction:50,tension:1e3}})):void M.start({from:{val:Q()},to:{val:-n},config:{velocity:e.velocity,friction:50,tension:1e3}}):(M.start({val:n,config:{velocity:e.velocity,friction:50,tension:1e3}}),void(b&&o?(_("drag"),e.cancel()):b&&u&&(Z("drag"),e.cancel())));e.last&&!e.canceled&&w&&("prev"===I.current&&Z("drag"),"next"===I.current&&_("drag")),!e.last||e.canceled||w||(o?!g&&N.current?M.start({val:-J(),config:Object.assign(Object.assign({},r.config.default),{velocity:e.velocity})}):_("drag"):u?!g&&A.current?M.start({val:0,config:Object.assign(Object.assign({},r.config.default),{velocity:e.velocity})}):Z("drag"):M.start({val:O.current,config:Object.assign(Object.assign({},r.config.default),{velocity:e.velocity})}))}),{enabled:s&&!x&&!w||!!w&&!!y,axis:v,from:()=>w&&$.current?[-$.current.scrollLeft,-$.current.scrollTop]:[L.val.get(),L.val.get()]});function te(){$.current&&(O.current=$.current["x"===v?"scrollLeft":"scrollTop"],0===$.current["x"===v?"scrollLeft":"scrollTop"]&&(A.current=!0,N.current=!1),$.current["x"===v?"scrollLeft":"scrollTop"]>0&&$.current["x"===v?"scrollLeft":"scrollTop"]<J()&&(A.current=!1,N.current=!1),$.current["x"===v?"scrollLeft":"scrollTop"]===J()&&(A.current=!1,N.current=!0))}function re(t){return e.findIndex((e=>e.id===t))}function ne(t,r){let n=0;if(n="string"==typeof t?e.findIndex((e=>e.id===t)):t,n<0||n>=e.length)throw new Error(r);return n}return{useListenToCustomEvent:k,carouselFragment:t.jsx("div",Object.assign({ref:$},w?{onWheel(){L.val.stop(),te()}}:{},{style:Object.assign({display:"flex",position:"relative",width:"100%",height:"100%"},w?"x"===v?{overflowX:"auto"}:{overflowY:"auto"}:{})},{children:t.jsx("div",Object.assign({ref:W},ee(),{style:Object.assign({position:"relative",display:"flex",flexDirection:"x"===v?"row":"column",touchAction:"none"},function(){const e=`calc(100% - ${2*h}px)`;return{width:"x"===v?e:"100%",height:"y"===v?e:"100%"}}())},{children:q.map(((e,r)=>t.jsx("div",Object.assign({className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:Object.assign({display:"flex",position:"relative",flex:"1"},"fixed"!==f||w?Object.assign({marginRight:`${m}px`}):{marginRight:`${m}px`,flex:`1 0 calc(100% / ${d} - ${m*(d-1)/d}px)`})},{children:e.renderItem}),`${e.id}-${r}`)))}))})),enterFullscreen:z,exitFullscreen:P,getIsFullscreen:G,thumbsFragment:B,slideToItem:function(t){if(!s)return;A.current=!1,N.current=!1;const r=ne(t,"The item you want to slide to doesn't exist; please check che item id or the index you're passing to.");if(r===F.current)return;const n=re(e[F.current].id),i=re(e[r].id);i>n?_("click",i):Z("click",i)},getIsNextItem:function(t){const r=re(t),n=F.current;return g&&n===e.length-1?0===r:r===n+1},getIsPrevItem:function(t){const r=re(t),n=F.current;return g&&0===n?r===e.length-1:r===n-1},slideToPrevItem:()=>Z(),slideToNextItem:()=>_(),getIsActiveItem:e=>ne(e,"The item you want to check doesn't exist")===F.current}},e.useSpringCarouselContext=function(){const e=n.useContext(s);if(!e)throw new Error("useSpringCarouselContext must be used within the carousel.");return e}}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/umd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/modules/useCustomEventsModule.tsx","../../src/utils.ts","../../src/modules/useFullscreenModule.tsx","../../src/modules/useThumbsModule.tsx","../../src/useSpringCarousel/index.tsx","../../src/useTransitionCarousel/index.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { Subject } from 'rxjs'\nimport {\n UseSpringCarouselEventsObservableProps,\n UseTransitionCarouselEventsObservableProps,\n ObservableCallbackFn,\n EmitObservableFn,\n} from '../types'\n\nexport function useCustomEventsModule<T>() {\n const eventsObserverRef = useRef(\n new Subject<\n T extends 'use-spring'\n ? UseSpringCarouselEventsObservableProps\n : UseTransitionCarouselEventsObservableProps\n >(),\n )\n\n function useListenToCustomEvent(fn: ObservableCallbackFn<T>) {\n useEffect(() => {\n const subscribe = eventsObserverRef.current.subscribe(fn)\n return () => subscribe.unsubscribe()\n }, [fn])\n }\n\n const emitObservable: EmitObservableFn<T> = data => {\n eventsObserverRef.current.next(data)\n }\n\n return {\n useListenToCustomEvent,\n emitObservable,\n }\n}\n","import { useRef, useLayoutEffect, useEffect } from 'react'\n\ntype Callback = () => void | (() => void)\n\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nfunction useIsomorphicMount(callback: Callback) {\n const isMounted = useRef(false)\n\n useIsomorphicLayoutEffect(() => {\n if (!isMounted.current) {\n const clean = callback()\n isMounted.current = true\n\n return () => {\n clean && clean()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\nexport { useIsomorphicLayoutEffect, useIsomorphicMount }\n","import { useRef, MutableRefObject } from 'react'\nimport screenfull from 'screenfull'\nimport { EmitObservableFn } from '../types'\nimport { useIsomorphicMount } from '../utils'\n\ntype FullscreenModule<T> = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>\n emitObservable: EmitObservableFn<T>\n handleResize?(): void\n}\n\nexport function useFullscreenModule<T>({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n}: FullscreenModule<T>) {\n const isFullscreen = useRef(false)\n\n useIsomorphicMount(() => {\n function handleFullscreenChange() {\n if (document.fullscreenElement) {\n setIsFullscreen(true)\n emitObservable({\n eventName: 'onFullscreenChange',\n isFullscreen: true,\n })\n\n handleResize && handleResize()\n }\n\n if (!document.fullscreenElement) {\n setIsFullscreen(false)\n emitObservable({\n eventName: 'onFullscreenChange',\n isFullscreen: false,\n })\n handleResize && handleResize()\n }\n }\n\n if (screenfull.isEnabled) {\n screenfull.on('change', handleFullscreenChange)\n return () => {\n if (screenfull.isEnabled) {\n screenfull.off('change', handleFullscreenChange)\n }\n }\n }\n })\n\n function setIsFullscreen(_isFullscreen: boolean) {\n isFullscreen.current = _isFullscreen\n }\n\n function getIsFullscreen() {\n return isFullscreen.current\n }\n\n function enterFullscreen(elementRef?: HTMLElement) {\n if (screenfull.isEnabled) {\n screenfull.request((elementRef || mainCarouselWrapperRef.current) as Element)\n }\n }\n\n function exitFullscreen() {\n screenfull.isEnabled && screenfull.exit()\n }\n\n return {\n enterFullscreen,\n exitFullscreen,\n getIsFullscreen,\n }\n}\n","import { useRef } from 'react'\nimport { useSpring, SpringConfig, animated } from 'react-spring'\nimport { useIsomorphicMount } from 'src/utils'\nimport { UseSpringCarouselProps, SlideActionType } from '../types'\nimport { ReactSpringCarouselItemWithThumbs } from '../types/useSpringCarousel'\nimport { PrepareThumbsData } from '../types/index'\n\ntype OffsetDimension = 'offsetWidth' | 'offsetHeight'\ntype OffsetDirection = 'offsetLeft' | 'offsetTop'\ntype ScrollDirection = 'scrollLeft' | 'scrollTop'\n\ntype Props = {\n items: ReactSpringCarouselItemWithThumbs[]\n withThumbs: boolean\n slideType: UseSpringCarouselProps['slideType']\n thumbsSlideAxis: UseSpringCarouselProps['thumbsSlideAxis']\n springConfig: SpringConfig\n prepareThumbsData?: UseSpringCarouselProps['prepareThumbsData']\n getFluidWrapperScrollValue?(): number\n getSlideValue?(): number\n}\n\nexport function useThumbsModule({\n items,\n withThumbs,\n thumbsSlideAxis = 'x',\n springConfig,\n prepareThumbsData,\n getFluidWrapperScrollValue = () => 0,\n getSlideValue = () => 0,\n slideType,\n}: Props) {\n const internalThumbsWrapperRef = useRef<HTMLDivElement | null>(null)\n const [thumbListStyles, setThumbListStyles] = useSpring(() => ({\n x: 0,\n y: 0,\n config: springConfig,\n onChange: ({ value }) => {\n if (internalThumbsWrapperRef.current && slideType === 'fluid') {\n internalThumbsWrapperRef.current[\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[thumbsSlideAxis])\n }\n },\n }))\n\n useIsomorphicMount(() => {\n if (withThumbs && !internalThumbsWrapperRef.current) {\n throw new Error(\n \"The thumbs wrapper is not defined. If you've passed a Functional component, be sure to wrap your component in forwardRef.\",\n )\n }\n })\n\n function getCurrentThumbScrollValue() {\n return internalThumbsWrapperRef.current![\n thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getThumbsTotalScrollableValue() {\n return Math.round(\n Number(\n internalThumbsWrapperRef.current?.[\n thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n internalThumbsWrapperRef.current!.getBoundingClientRect()[\n thumbsSlideAxis === 'x' ? 'width' : 'height'\n ],\n )\n }\n\n function getThumbSlideValue() {\n const thumbSlideTotal = Math.round(getFluidWrapperScrollValue() / getSlideValue())\n const totalScrollableValue = getThumbsTotalScrollableValue()\n return totalScrollableValue / thumbSlideTotal\n }\n\n function handleThumbsScroll(activeItem: number, actionType?: SlideActionType) {\n if (slideType === 'fluid') {\n const totalScrollableValue = getThumbsTotalScrollableValue()\n\n if (actionType === 'next') {\n const nextValue = getCurrentThumbScrollValue() + getThumbSlideValue()\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getCurrentThumbScrollValue(),\n },\n to: {\n [thumbsSlideAxis]:\n nextValue > totalScrollableValue ? totalScrollableValue : nextValue,\n },\n })\n }\n if (actionType === 'prev') {\n const nextValue = getCurrentThumbScrollValue() - getThumbSlideValue()\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: getCurrentThumbScrollValue(),\n },\n to: {\n [thumbsSlideAxis]: nextValue < 0 ? 0 : nextValue,\n },\n })\n }\n } else {\n function getOffsetDirection() {\n return thumbsSlideAxis === 'x' ? 'offsetLeft' : 'offsetTop'\n }\n function getOffsetDimension() {\n return thumbsSlideAxis === 'x' ? 'offsetWidth' : 'offsetHeight'\n }\n function getScrollDirecton() {\n return thumbsSlideAxis === 'x' ? 'scrollLeft' : 'scrollTop'\n }\n function getThumbNode() {\n return internalThumbsWrapperRef.current!.querySelector(\n `#thumb-${items[activeItem].id}`,\n ) as HTMLElement\n }\n function getThumbOffsetPosition({\n thumbNode,\n offsetDirection,\n offsetDimension,\n }: {\n thumbNode: HTMLElement\n offsetDirection: OffsetDirection\n offsetDimension: OffsetDimension\n }) {\n return thumbNode[offsetDirection] + thumbNode[offsetDimension] / 2\n }\n function getThumbScrollDimension({\n thumbWrapper,\n offsetDimension,\n }: {\n thumbWrapper: HTMLDivElement\n offsetDimension: OffsetDimension\n }) {\n return thumbWrapper[offsetDimension] / 2\n }\n function getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n }: {\n thumbWrapper: HTMLDivElement\n scrollDirection: ScrollDirection\n }) {\n return thumbWrapper[scrollDirection]\n }\n function getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n }: {\n thumbWrapper: HTMLDivElement\n thumbOffsetPosition: number\n thumbScrollDimension: number\n offsetDimension: OffsetDimension\n }) {\n const scrollDimensionProperty =\n thumbsSlideAxis === 'x' ? 'scrollWidth' : 'scrollHeight'\n\n if (\n activeItem === items.length - 1 ||\n thumbOffsetPosition - thumbScrollDimension >\n thumbWrapper[scrollDimensionProperty] - thumbWrapper[offsetDimension]\n ) {\n return thumbWrapper[scrollDimensionProperty] - thumbWrapper[offsetDimension]\n }\n if (activeItem === 0) {\n return 0\n }\n\n return thumbOffsetPosition - thumbScrollDimension\n }\n\n const thumbNode = getThumbNode()\n\n if (thumbNode) {\n const thumbWrapper = internalThumbsWrapperRef.current!\n const offsetDirection = getOffsetDirection()\n const offsetDimension = getOffsetDimension()\n const scrollDirection = getScrollDirecton()\n const thumbOffsetPosition = getThumbOffsetPosition({\n thumbNode,\n offsetDimension,\n offsetDirection,\n })\n const thumbScrollDimension = getThumbScrollDimension({\n thumbWrapper,\n offsetDimension,\n })\n\n const fromValue = getScrollFromValue({\n thumbWrapper,\n scrollDirection,\n })\n const toValue = getScrollToValue({\n thumbWrapper,\n thumbOffsetPosition,\n thumbScrollDimension,\n offsetDimension,\n })\n\n setThumbListStyles.start({\n from: {\n [thumbsSlideAxis]: fromValue,\n },\n to: {\n [thumbsSlideAxis]: actionType === 'prev' && toValue < 0 ? 0 : toValue,\n },\n onChange: ({ value }) => {\n if (thumbsSlideAxis === 'x') {\n internalThumbsWrapperRef!.current!.scrollLeft = value.x\n } else {\n internalThumbsWrapperRef!.current!.scrollTop = value.y\n }\n },\n })\n }\n }\n }\n function handlePrepareThumbsData() {\n function getPreparedItems(\n _items: ReturnType<PrepareThumbsData>,\n ): ReturnType<PrepareThumbsData> {\n return _items.map(i => ({\n id: i.id,\n renderThumb: i.renderThumb,\n }))\n }\n\n if (prepareThumbsData) {\n return prepareThumbsData(getPreparedItems(items))\n }\n return getPreparedItems(items)\n }\n\n const thumbsFragment = withThumbs ? (\n <animated.div\n ref={internalThumbsWrapperRef}\n className=\"use-spring-carousel-thumbs-wrapper\"\n onWheel={() => {\n thumbListStyles[thumbsSlideAxis].stop()\n }}\n style={{\n display: 'flex',\n flex: 1,\n position: 'relative',\n width: '100%',\n height: '100%',\n flexDirection: thumbsSlideAxis === 'x' ? 'row' : 'column',\n ...(thumbsSlideAxis === 'x'\n ? { overflowX: 'auto' }\n : {\n overflowY: 'auto',\n maxHeight: '100%',\n }),\n }}\n >\n {handlePrepareThumbsData().map(({ id, renderThumb }) => {\n const thumbId = `thumb-${id}`\n return (\n <div key={thumbId} id={thumbId} className=\"thumb-item\">\n {renderThumb}\n </div>\n )\n })}\n </animated.div>\n ) : null\n\n return {\n thumbsFragment,\n handleThumbsScroll,\n }\n}\n","import { useRef, createContext, useContext } from 'react'\nimport { useSpring, config, animated } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useFullscreenModule, useThumbsModule } from '../modules'\nimport {\n SlideToItemFnProps,\n SlideActionType,\n UseSpringFixedSlideTypeReturnProps,\n} from '../types'\nimport { useIsomorphicLayoutEffect, useIsomorphicMount } from '../utils'\nimport {\n UseSpringCarouselProps,\n ReactSpringCarouselItemWithThumbs,\n UseSpringFluidSlideTypeReturnProps,\n UseSpringCarouselBaseProps,\n UseSpringCarouselWithThumbs,\n UseSpringCarouselFluidType,\n DisableGesturesProps,\n WithLoopProps,\n UseSpringCarouselWithNoThumbs,\n EnableGesturesProps,\n WithNoLoop,\n UseSpringCarouselFixedSlideType,\n} from '../types/useSpringCarousel'\n\ntype ReturnType<T> = T extends 'fixed'\n ? UseSpringFixedSlideTypeReturnProps\n : UseSpringFluidSlideTypeReturnProps\ntype ContextTypes<T> = Omit<ReturnType<T>, 'carouselFragment' | 'thumbsFragment'>\n\nconst Context = createContext<ContextTypes<'fixed' | 'fluid'> | undefined>(undefined)\n\nconst defaultDragSpringConfig = {\n ...config.default,\n mass: 1,\n velocity: 0,\n}\n\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFluidType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fluid'>\nfunction useSpringCarousel(\n props: UseSpringCarouselBaseProps &\n UseSpringCarouselFixedSlideType &\n (UseSpringCarouselWithThumbs | UseSpringCarouselWithNoThumbs) &\n (DisableGesturesProps | EnableGesturesProps) &\n (WithLoopProps | WithNoLoop),\n): ReturnType<'fixed'>\n\nfunction useSpringCarousel({\n items,\n withLoop = false,\n draggingSlideTreshold,\n springConfig = config.default,\n shouldResizeOnWindowResize = true,\n withThumbs = false,\n enableThumbsWrapperScroll = true,\n slideWhenThresholdIsReached = true,\n carouselSlideAxis = 'x',\n thumbsSlideAxis = 'x',\n prepareThumbsData,\n initialActiveItem = 0,\n initialStartingPosition,\n disableGestures = false,\n gutter = 0,\n startEndGutter = 0,\n touchAction,\n slideAmount,\n freeScroll = false,\n enableFreeScrollDrag,\n itemsPerSlide = 1,\n slideType = 'fixed',\n}: UseSpringCarouselProps): ReturnType<'fixed' | 'fluid'> {\n function getItems() {\n if (withLoop) {\n if (items.length === itemsPerSlide) {\n return [...items, ...items, ...items, ...items, ...items]\n }\n return [...items, ...items, ...items]\n }\n return items\n }\n\n const isFirstMount = useRef(true)\n const slideActionType = useRef<SlideActionType>('initial' as SlideActionType)\n const internalItems = getItems()\n const activeItem = useRef(initialActiveItem)\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const carouselTrackWrapperRef = useRef<HTMLDivElement | null>(null)\n const isDragging = useRef(false)\n const isAnimating = useRef(false)\n const windowIsHidden = useRef(false)\n const fluidTotalWrapperScrollValue = useRef(0)\n const slideEndReached = useRef(false)\n const currentWindowWidth = useRef(0)\n const initialWindowWidth = useRef(0)\n const prevSlidedValue = useRef(0)\n const prevItems = useRef(items)\n\n /**\n * Instead of raw values, we store it in\n * useRef for performances reasons during external rerenders\n */\n const draggingSlideTresholdRef = useRef<number>(draggingSlideTreshold ?? 0)\n const itemsPerSlideRef = useRef(itemsPerSlide)\n const gutterRef = useRef(gutter)\n const startEndGutterRef = useRef(startEndGutter)\n const initialActiveItemRef = useRef(initialActiveItem)\n const initialStartingPositionRef = useRef(initialStartingPosition)\n const carouselSlideAxisRef = useRef(carouselSlideAxis)\n\n /**\n * Update inner values during external rerenders!\n */\n itemsPerSlideRef.current = itemsPerSlide\n gutterRef.current = gutter\n startEndGutterRef.current = startEndGutter\n initialActiveItemRef.current = initialActiveItem\n initialStartingPositionRef.current = initialStartingPosition\n carouselSlideAxisRef.current = carouselSlideAxis\n\n const [carouselStyles, setCarouselStyles] = useSpring(() => ({\n y: 0,\n x: 0,\n onChange: ({ value }) => {\n if (mainCarouselWrapperRef.current && freeScroll) {\n mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ] = Math.abs(value[carouselSlideAxisRef.current])\n }\n },\n }))\n\n useIsomorphicLayoutEffect(() => {\n if (draggingSlideTreshold) {\n draggingSlideTresholdRef.current = draggingSlideTreshold\n } else {\n draggingSlideTresholdRef.current = Math.floor(getSlideValue() / 2 / 2)\n }\n\n resize()\n }, [\n draggingSlideTreshold,\n itemsPerSlide,\n gutter,\n startEndGutter,\n initialActiveItem,\n initialStartingPosition,\n carouselSlideAxis,\n thumbsSlideAxis,\n ])\n\n function getCarouselItem() {\n return carouselTrackWrapperRef.current?.querySelector('.use-spring-carousel-item')\n }\n function getMainCarouselWrapperWidth() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('mainCarouselWrapperRef is not available')\n }\n return mainCarouselWrapperRef.current.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ]\n }\n function getCarouselItemWidth() {\n const carouselItem = getCarouselItem()\n if (!carouselItem) {\n throw Error('No carousel items available!')\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ] + gutterRef.current\n )\n }\n function getCurrentSlidedValue() {\n return carouselStyles[carouselSlideAxisRef.current].get()\n }\n function getIfItemsNotFillTheCarousel() {\n return getCarouselItemWidth() * items.length < getMainCarouselWrapperWidth()\n }\n function getFluidWrapperScrollValue() {\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxisRef.current === 'x' ? 'scrollWidth' : 'scrollHeight'\n ],\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxisRef.current === 'x' ? 'width' : 'height'\n ],\n )\n }\n function getIsFirstItem() {\n return getCurrentActiveItem() === 0\n }\n function getSlideValue() {\n if (!carouselTrackWrapperRef.current) {\n return 0\n }\n const itemVal = getCarouselItemWidth()\n\n if (slideType === 'fluid' && typeof slideAmount === 'number') {\n if (slideAmount < itemVal) {\n throw new Error('slideAmount must be greater than the width of a single item.')\n }\n return slideAmount\n }\n return itemVal\n }\n function adjustCarouselWrapperPosition(\n ref: HTMLDivElement,\n _initialActiveItem?: number,\n ) {\n const positionProperty = carouselSlideAxisRef.current === 'x' ? 'left' : 'top'\n function getDefaultPositionValue() {\n return getCarouselItemWidth() * items.length\n }\n function setPosition(v: number) {\n if (withLoop) {\n ref.style.top = '0px'\n ref.style[positionProperty] = `-${v - startEndGutterRef.current}px`\n } else {\n ref.style.left = '0px'\n ref.style.top = '0px'\n if (_initialActiveItem && isFirstMount.current) {\n ref.style[positionProperty] = `calc(-${_initialActiveItem} * 100%)`\n }\n }\n }\n function setStartPosition() {\n setPosition(getDefaultPositionValue())\n }\n\n if (slideType === 'fixed') {\n function setCenterPosition(i: number) {\n setPosition(\n getDefaultPositionValue() -\n getSlideValue() * Math.round(((i as number) - 1) / 2),\n )\n }\n function setEndPosition(i: number) {\n setPosition(\n getDefaultPositionValue() - getSlideValue() * Math.round((i as number) - 1),\n )\n }\n\n if (itemsPerSlideRef.current > 1) {\n switch (initialStartingPositionRef.current) {\n default:\n case 'start': {\n setStartPosition()\n break\n }\n case 'center': {\n setCenterPosition(itemsPerSlideRef.current)\n break\n }\n case 'end': {\n setEndPosition(itemsPerSlideRef.current)\n break\n }\n }\n } else {\n setStartPosition()\n }\n } else {\n setStartPosition()\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function resize() {\n currentWindowWidth.current = window.innerWidth\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: 0,\n })\n return\n }\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n\n if (slideEndReached.current) {\n const nextValue = -fluidTotalWrapperScrollValue.current\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: nextValue,\n })\n }\n\n initialWindowWidth.current = window.innerWidth\n } else {\n setCarouselStyles.start({\n immediate: true,\n [carouselSlideAxisRef.current]: -(getSlideValue() * getCurrentActiveItem()),\n })\n }\n\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n adjustCarouselWrapperPosition(carouselTrackWrapperRef.current!)\n }\n function handleResize() {\n if (window.innerWidth === currentWindowWidth.current || freeScroll) {\n return\n }\n resize()\n }\n // Custom modules\n const { useListenToCustomEvent, emitObservable } = useCustomEventsModule<'use-spring'>()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } =\n useFullscreenModule<'use-spring'>({\n mainCarouselWrapperRef,\n emitObservable,\n handleResize,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n withThumbs,\n items: items as ReactSpringCarouselItemWithThumbs[],\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType,\n getFluidWrapperScrollValue,\n getSlideValue,\n })\n\n function getWrapperScrollDirection() {\n if (!mainCarouselWrapperRef.current) {\n throw new Error('Missing mainCarouselWrapperRef.current')\n }\n return mainCarouselWrapperRef.current[\n carouselSlideAxisRef.current === 'x' ? 'scrollLeft' : 'scrollTop'\n ]\n }\n function getIfShouldEnableFluidDrag() {\n if (typeof enableFreeScrollDrag === 'boolean') {\n return enableFreeScrollDrag\n } else if (typeof enableFreeScrollDrag === 'function') {\n return enableFreeScrollDrag()\n }\n return false\n }\n\n const bindDrag = useDrag(\n props => {\n const isDragging = props.dragging\n const movement = props.offset[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const currentMovement = props.movement[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n const prevItemTreshold = currentMovement > draggingSlideTresholdRef.current\n const nextItemTreshold = currentMovement < -draggingSlideTresholdRef.current\n const direction = props.direction[carouselSlideAxisRef.current === 'x' ? 0 : 1]\n function cancelDrag() {\n props.cancel()\n }\n function setDragDirection() {\n if (direction > 0) {\n setSlideActionType('prev')\n } else {\n setSlideActionType('next')\n }\n }\n function emitDragObservable() {\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n function resetAnimation() {\n if (slideType === 'fluid') {\n if (\n getIfItemsNotFillTheCarousel() ||\n (getIsFirstItem() && getSlideActionType() === 'prev')\n ) {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: 0,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n } else if (slideEndReached.current && getSlideActionType() === 'next') {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: prevSlidedValue.current,\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n }\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -(getCurrentActiveItem() * getSlideValue()),\n config: {\n velocity: props.velocity,\n ...springConfig,\n },\n })\n }\n }\n function checkBounds() {\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue()) + 100 >= fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && getSlideActionType() === 'next') {\n slideEndReached.current = true\n }\n if (getSlideActionType() === 'prev') {\n slideEndReached.current = false\n }\n }\n\n if (freeScroll && getIfShouldEnableFluidDrag()) {\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n setDragDirection()\n emitDragObservable()\n checkBounds()\n }\n\n setCarouselStyles.start({\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1400,\n },\n })\n\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n }\n if (props.last) {\n if (getSlideActionType() === 'prev') {\n slideToPrevItem(props.velocity)\n } else {\n slideToNextItem(props.velocity)\n }\n setIsDragging(false)\n }\n return\n }\n\n if (isDragging) {\n if (!getIsDragging()) {\n setIsDragging(true)\n }\n\n emitDragObservable()\n setDragDirection()\n checkBounds()\n\n if (freeScroll) {\n if (getIfShouldEnableFluidDrag()) {\n if (getWrapperScrollDirection() === 0 && getSlideActionType() === 'prev') {\n cancelDrag()\n return\n } else {\n setCarouselStyles.start({\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1400,\n },\n from: {\n [carouselSlideAxisRef.current]: getWrapperScrollDirection(),\n },\n to: {\n [carouselSlideAxisRef.current]: -movement,\n },\n })\n }\n }\n return\n } else {\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: movement,\n config: {\n velocity: props.velocity,\n friction: 50,\n tension: 1000,\n },\n })\n }\n\n if (\n (prevItemTreshold || nextItemTreshold) &&\n getIfItemsNotFillTheCarousel() &&\n slideType === 'fluid'\n ) {\n cancelDrag()\n resetAnimation()\n } else if (\n slideEndReached.current &&\n getSlideActionType() === 'next' &&\n nextItemTreshold\n ) {\n slideEndReached.current = false\n cancelDrag()\n setCarouselStyles.start({\n [carouselSlideAxisRef.current]: -fluidTotalWrapperScrollValue.current,\n })\n } else if (slideWhenThresholdIsReached) {\n if (nextItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n return\n } else if (prevItemTreshold) {\n cancelDrag()\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n return\n }\n }\n }\n\n if (\n props.last &&\n !slideWhenThresholdIsReached &&\n (nextItemTreshold || prevItemTreshold) &&\n !freeScroll\n ) {\n setIsDragging(false)\n if (nextItemTreshold) {\n if (!withLoop && getIsLastItem()) {\n resetAnimation()\n } else {\n slideToNextItem(props.velocity)\n }\n } else if (prevItemTreshold) {\n if (!withLoop && getIsFirstItem()) {\n resetAnimation()\n } else {\n slideToPrevItem(props.velocity)\n }\n }\n return\n }\n\n if (props.last && !nextItemTreshold && !prevItemTreshold) {\n if (!freeScroll) {\n resetAnimation()\n emitObservable({\n eventName: 'onDrag',\n slideActionType: getSlideActionType(),\n ...props,\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n axis: carouselSlideAxisRef.current,\n from: () => {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === 'x') {\n return [-getWrapperScrollDirection(), 0]\n }\n return [0, -getWrapperScrollDirection()]\n }\n return [carouselStyles.x.get(), carouselStyles.y.get()]\n },\n },\n )\n\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function setActiveItem(newItem: number) {\n activeItem.current = newItem\n }\n function getCurrentActiveItem() {\n return activeItem.current\n }\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setIsDragging(val: boolean) {\n isDragging.current = val\n }\n function getIsDragging() {\n return isDragging.current\n }\n function getPrevItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === 0) {\n return items.length - 1\n }\n return currentActiveItem - 1\n }\n function getNextItem() {\n const currentActiveItem = getCurrentActiveItem()\n if (currentActiveItem === items.length - 1) {\n return 0\n }\n return currentActiveItem + 1\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n const activeItem = getCurrentActiveItem()\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n return itemIndex === activeItem - 1\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getFromValue(from: SlideToItemFnProps['from']) {\n if (typeof from === 'number') {\n return {\n from: {\n [carouselSlideAxisRef.current]: from,\n },\n }\n }\n return {}\n }\n function getToValue(\n customTo: SlideToItemFnProps['customTo'],\n to: SlideToItemFnProps['to'],\n ) {\n if (typeof customTo === 'number') {\n return {\n [carouselSlideAxisRef.current]: customTo,\n }\n }\n if (typeof to !== 'number') {\n throw new Error(`to values is not a number!`)\n }\n return {\n [carouselSlideAxisRef.current]: -(getSlideValue() * to!),\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function slideToItem({\n from,\n to = -1,\n customTo,\n immediate = false,\n onRest = () => {},\n velocity,\n }: SlideToItemFnProps) {\n if (!immediate) {\n setActiveItem(to)\n setIsAnimating(true)\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: slideType === 'fluid' ? -1 : to,\n id: slideType === 'fluid' ? '' : items[to].id,\n },\n })\n }\n prevSlidedValue.current = getToValue(customTo, to)[carouselSlideAxis]\n setCarouselStyles.start({\n ...getFromValue(from),\n to: getToValue(customTo, to),\n ...(velocity\n ? {\n config: {\n ...defaultDragSpringConfig,\n velocity,\n friction: undefined,\n tension: undefined,\n },\n }\n : {\n config: {\n velocity: 0,\n ...springConfig,\n },\n }),\n immediate,\n onRest: val => {\n if (val.finished) {\n setIsDragging(false)\n setIsAnimating(false)\n onRest()\n if (!immediate) {\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: slideType === 'fluid' ? -1 : getCurrentActiveItem(),\n id: slideType === 'fluid' ? '' : items[getCurrentActiveItem()].id,\n },\n })\n }\n }\n },\n })\n if (enableThumbsWrapperScroll && withThumbs && !immediate) {\n handleThumbsScroll(to, getSlideActionType())\n }\n }\n function getIsLastItem() {\n return getCurrentActiveItem() === items.length - 1\n }\n function slideToPrevItem(velocity?: number[]) {\n setSlideActionType('prev')\n slideEndReached.current = false\n\n if (slideType === 'fluid') {\n slideEndReached.current = false\n\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n const nextPrevValue = getCurrentSlidedValue() + getSlideValue() + 200\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft - getSlideValue()\n slideToItem({\n customTo: nextValue < 0 ? 0 : nextValue,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n velocity,\n })\n } else if (nextPrevValue >= 0) {\n if (withLoop) {\n slideToItem({\n from: getCurrentSlidedValue() - getCarouselItemWidth() * items.length,\n velocity,\n customTo:\n getCurrentSlidedValue() -\n getCarouselItemWidth() * items.length +\n getSlideValue(),\n })\n } else {\n slideToItem({\n customTo: 0,\n velocity,\n })\n }\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() + getSlideValue(),\n velocity,\n })\n }\n } else {\n if ((!withLoop && getCurrentActiveItem() === 0) || windowIsHidden.current) {\n return\n }\n\n if (getIsFirstItem()) {\n slideToItem({\n from: getCurrentSlidedValue() - getSlideValue() * items.length,\n to: items.length - 1,\n velocity,\n })\n } else {\n slideToItem({\n to: getPrevItem(),\n velocity,\n })\n }\n }\n }\n function slideToNextItem(velocity?: number[]) {\n setSlideActionType('next')\n\n if (slideType === 'fluid') {\n if (getIfItemsNotFillTheCarousel()) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue()) + 100 >=\n fluidTotalWrapperScrollValue.current\n\n if (freeScroll) {\n const nextValue = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n const willExceed = nextValue > fluidTotalWrapperScrollValue.current\n const val = mainCarouselWrapperRef.current!.scrollLeft + getSlideValue()\n\n slideToItem({\n velocity,\n customTo: willExceed ? fluidTotalWrapperScrollValue.current : val,\n from: mainCarouselWrapperRef.current!.scrollLeft,\n })\n } else if (\n withLoop &&\n Math.abs(getCurrentSlidedValue() - getSlideValue()) >=\n items.length * getCarouselItemWidth()\n ) {\n const currentWidth = getCarouselItemWidth() * items.length\n slideToItem({\n from: getCurrentSlidedValue() + currentWidth,\n customTo: getCurrentSlidedValue() + currentWidth - getSlideValue(),\n velocity,\n })\n } else if (slideEndReached.current) {\n return\n } else if (nextItemWillExceed) {\n slideEndReached.current = true\n slideToItem({\n customTo: -fluidTotalWrapperScrollValue.current,\n velocity,\n })\n } else {\n slideToItem({\n customTo: getCurrentSlidedValue() - getSlideValue(),\n velocity,\n })\n }\n } else {\n if (\n (!withLoop && getCurrentActiveItem() === internalItems.length - 1) ||\n windowIsHidden.current\n ) {\n return\n }\n\n const nextItemWillExceed =\n Math.abs(getCurrentSlidedValue() - getSlideValue() + 25) >\n fluidTotalWrapperScrollValue.current\n\n if (nextItemWillExceed && !getIsDragging()) {\n slideEndReached.current = true\n } else if (slideEndReached.current) {\n slideToItem({\n to: items.length - itemsPerSlideRef.current,\n velocity,\n })\n } else if (getIsLastItem()) {\n slideToItem({\n from: getCurrentSlidedValue() + getSlideValue() * items.length,\n to: 0,\n velocity,\n })\n } else {\n slideToItem({\n to: getNextItem(),\n velocity,\n })\n }\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n function _slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (\n itemIndex === getCurrentActiveItem() ||\n (items.length !== prevItems.current.length && getCurrentActiveItem() < items.length)\n ) {\n return\n }\n\n const currentItem = findItemIndex(prevItems.current[getCurrentActiveItem()].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n slideToItem({\n to: itemIndex,\n })\n }\n function getItemStyles(_itemsPerSlide: number) {\n if (slideType === 'fixed') {\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n flex: `1 0 calc(100% / ${_itemsPerSlide} - ${\n (gutterRef.current * (_itemsPerSlide - 1)) / _itemsPerSlide\n }px)`,\n }\n }\n return {\n ...(carouselSlideAxisRef.current === 'x'\n ? { marginRight: `${gutterRef.current}px` }\n : { marginBottom: `${gutterRef.current}px` }),\n }\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutterRef.current * 2}px)`\n return {\n width: carouselSlideAxisRef.current === 'x' ? percentValue : '100%',\n height: carouselSlideAxisRef.current === 'y' ? percentValue : '100%',\n }\n }\n function getOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxisRef.current === 'x') {\n return {\n overflowX: 'auto',\n }\n }\n return {\n overflowY: 'auto',\n }\n }\n return {}\n }\n function getWheelEvent() {\n if (freeScroll) {\n return {\n onWheel() {\n carouselStyles[carouselSlideAxisRef.current].stop()\n },\n }\n }\n return {}\n }\n function getTouchAction() {\n if (disableGestures) {\n return 'unset'\n } else if (!touchAction) {\n if (carouselSlideAxisRef.current === 'x') {\n return 'pan-y'\n }\n return 'pan-x'\n }\n return touchAction\n }\n // Perform some check on first mount\n useIsomorphicMount(() => {\n if (itemsPerSlide % 2 === 0 && initialStartingPositionRef.current) {\n throw new Error(\n `initialStartingPosition can be only used if itemsPerSlide is an even value.`,\n )\n }\n if (draggingSlideTresholdRef.current < 0) {\n throw new Error('draggingSlideTreshold must be greater than 0')\n }\n if (draggingSlideTresholdRef.current > getSlideValue() / 2) {\n throw new Error(\n `draggingSlideTreshold must be equal or less than the half of the width of an item, which is ${Math.floor(\n getSlideValue() / 2,\n )}`,\n )\n }\n if (itemsPerSlideRef.current < 1) {\n throw new Error(`The itemsPerSlide prop can't be less than 1.`)\n }\n if (itemsPerSlideRef.current > items.length) {\n throw new Error(\n `The itemsPerSlide prop can't be greater than the total length of the items you provide.`,\n )\n }\n if (initialActiveItemRef.current < 0) {\n throw new Error('The initialActiveItem cannot be less than 0.')\n }\n if (initialActiveItemRef.current > items.length) {\n throw new Error(\n 'The initialActiveItem cannot be greater than the total length of the items you provide.',\n )\n }\n if (!shouldResizeOnWindowResize) {\n console.warn(\n 'You set shouldResizeOnWindowResize={false}; be aware that the carousel could behave in a strange way if you also use the fullscreen functionality or if you change the mobile orientation.',\n )\n }\n })\n useIsomorphicMount(() => {\n function handleVisibilityChange() {\n if (document.hidden) {\n windowIsHidden.current = true\n } else {\n windowIsHidden.current = false\n }\n }\n document.addEventListener('visibilitychange', handleVisibilityChange)\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange)\n }\n })\n useIsomorphicMount(() => {\n isFirstMount.current = false\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n initialWindowWidth.current = window.innerWidth\n currentWindowWidth.current = window.innerWidth\n\n if (initialActiveItem > 0) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n if (!withLoop && carouselTrackWrapperRef.current) {\n carouselTrackWrapperRef.current.style.top = '0px'\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n })\n useIsomorphicLayoutEffect(() => {\n if (initialActiveItem < items.length && initialActiveItem !== activeItem.current) {\n slideToItem({\n to: initialActiveItem,\n immediate: true,\n })\n setActiveItem(initialActiveItem)\n }\n }, [initialActiveItem])\n useIsomorphicLayoutEffect(() => {\n if (shouldResizeOnWindowResize) {\n window.addEventListener('resize', handleResize)\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [shouldResizeOnWindowResize])\n useIsomorphicLayoutEffect(() => {\n if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxisRef.current === 'x') {\n carouselTrackWrapperRef.current.style.top = '0px'\n }\n if (carouselSlideAxisRef.current === 'y') {\n carouselTrackWrapperRef.current.style.left = '0px'\n }\n }\n }, [carouselSlideAxis])\n useIsomorphicLayoutEffect(() => {\n fluidTotalWrapperScrollValue.current = getFluidWrapperScrollValue()\n const itemsAreEqual = items.length === prevItems.current.length\n\n if (!itemsAreEqual && items.length < prevItems.current.length) {\n _slideToItem(items.length - 1)\n }\n\n prevItems.current = items\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [getFluidWrapperScrollValue, items])\n\n const contextProps = {\n useListenToCustomEvent,\n getIsFullscreen,\n enterFullscreen,\n exitFullscreen,\n getIsAnimating,\n getIsDragging,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem() {\n slideToPrevItem()\n },\n slideToNextItem() {\n slideToNextItem()\n },\n ...(slideType === 'fixed'\n ? {\n slideToItem: _slideToItem,\n getIsActiveItem: (id: string) => {\n return findItemIndex(id) === getCurrentActiveItem()\n },\n getCurrentActiveItem: () => ({\n id: items[getCurrentActiveItem()].id,\n index: getCurrentActiveItem(),\n }),\n }\n : {}),\n }\n\n const handleCarouselFragmentRef = (ref: HTMLDivElement | null) => {\n if (ref) {\n carouselTrackWrapperRef.current = ref\n adjustCarouselWrapperPosition(ref, initialActiveItemRef.current)\n }\n }\n\n function getInitialStyles() {\n const totalValue = (items.length / itemsPerSlide) * 100\n const singleItemValue = 100 / itemsPerSlide\n const cssProp = carouselSlideAxisRef.current === 'x' ? 'left' : 'y'\n const quantityToMove = Math.floor(50 / singleItemValue)\n\n if (slideType === 'fixed') {\n if (initialStartingPositionRef.current === 'center') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * quantityToMove}%)`,\n }\n }\n if (initialStartingPositionRef.current === 'end') {\n return {\n [cssProp]: `calc(-${totalValue}% + ${singleItemValue * (quantityToMove * 2)}%)`,\n }\n }\n }\n return {\n [cssProp]: `0px`,\n }\n }\n\n const carouselFragment = (\n <Context.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n className=\"use-spring-carousel-main-wrapper\"\n data-testid=\"use-spring-carousel-wrapper\"\n {...getWheelEvent()}\n // @ts-ignore\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n ...getOverflowStyles(),\n }}\n >\n <animated.div\n {...bindDrag()}\n className=\"use-spring-carousel-track-wrapper\"\n data-testid=\"use-spring-carousel-animated-wrapper\"\n ref={handleCarouselFragmentRef}\n style={{\n display: 'flex',\n position: 'relative',\n touchAction: getTouchAction(),\n flexDirection: carouselSlideAxisRef.current === 'x' ? 'row' : 'column',\n ...getAnimatedWrapperStyles(),\n ...getInitialStyles(),\n ...(freeScroll ? {} : carouselStyles),\n }}\n >\n {internalItems.map(({ id, renderItem }, index) => {\n return (\n <div\n key={`${id}-${index}`}\n className=\"use-spring-carousel-item\"\n data-testid=\"use-spring-carousel-item-wrapper\"\n style={{\n display: 'flex',\n position: 'relative',\n ...getItemStyles(itemsPerSlideRef.current),\n }}\n >\n {renderItem}\n </div>\n )\n })}\n </animated.div>\n </div>\n </Context.Provider>\n )\n const thumbsFragment = (\n <Context.Provider value={contextProps}>{_thumbsFragment}</Context.Provider>\n )\n\n return {\n ...contextProps,\n carouselFragment,\n thumbsFragment,\n }\n}\n\nfunction useSpringCarouselContext<T = 'fixed' | 'fluid'>() {\n const context = useContext(Context)\n if (!context) {\n throw new Error(\n 'useSpringCarouselContext must be used only inside a component that is rendered inside the Carousel.',\n )\n }\n return context as ContextTypes<T>\n}\n\nexport { useSpringCarousel, useSpringCarouselContext }\n","import { createContext, useRef, useState, useContext } from 'react'\nimport { useTransition, animated, config } from 'react-spring'\nimport { useDrag } from '@use-gesture/react'\nimport { useCustomEventsModule, useThumbsModule, useFullscreenModule } from '../modules'\nimport { SlideActionType } from '../types'\nimport {\n UseTransitionCarouselContextProps,\n UseTransitionCarouselProps,\n} from '../types/useTransitionCarousel'\nimport { ReactSpringCarouselItemWithThumbs } from '../types/useSpringCarousel'\n\nconst UseTransitionCarouselContext = createContext<\n UseTransitionCarouselContextProps | undefined\n>(undefined)\n\nfunction useTransitionCarouselContext() {\n const context = useContext(UseTransitionCarouselContext)\n\n if (!context) {\n throw new Error(`useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.`)\n }\n\n return context\n}\n\nfunction useTransitionCarousel({\n items,\n withLoop = false,\n withThumbs = false,\n springConfig = config.default,\n thumbsSlideAxis = 'x',\n enableThumbsWrapperScroll = true,\n draggingSlideTreshold = 50,\n prepareThumbsData,\n toPrevItemSpringProps,\n toNextItemSpringProps,\n disableGestures = false,\n trail,\n exitBeforeEnter = false,\n springAnimationProps = {\n initial: {\n opacity: 1,\n position: 'absolute',\n },\n from: {\n opacity: 0,\n position: 'absolute',\n },\n enter: {\n opacity: 1,\n position: 'absolute',\n },\n leave: {\n opacity: 0,\n position: 'absolute',\n },\n },\n}: UseTransitionCarouselProps) {\n const slideActionType = useRef<SlideActionType>('next')\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null)\n const isAnimating = useRef(false)\n const [activeItem, setActiveItem] = useState(0)\n\n const { emitObservable, useListenToCustomEvent } =\n useCustomEventsModule<'use-transition'>()\n const { enterFullscreen, exitFullscreen, getIsFullscreen } = useFullscreenModule({\n emitObservable,\n mainCarouselWrapperRef,\n })\n const { thumbsFragment: _thumbsFragment, handleThumbsScroll } = useThumbsModule({\n items: items as ReactSpringCarouselItemWithThumbs[],\n withThumbs,\n thumbsSlideAxis,\n springConfig,\n prepareThumbsData,\n slideType: 'fixed',\n })\n\n const bindSwipe = useDrag(\n ({ last, movement: [mx] }) => {\n if (getIsAnimating()) {\n return\n }\n\n if (last) {\n const prevItemTreshold = mx > draggingSlideTreshold\n const nextItemTreshold = mx < -draggingSlideTreshold\n const isFirstItem = activeItem === 0\n const isLastItem = activeItem === items.length - 1\n\n if (nextItemTreshold) {\n if (!withLoop && isLastItem) {\n return\n }\n\n slideToNextItem()\n emitObservable({\n eventName: 'onLeftSwipe',\n })\n } else if (prevItemTreshold) {\n if (!withLoop && isFirstItem) {\n return\n }\n\n slideToPrevItem()\n emitObservable({\n eventName: 'onRightSwipe',\n })\n }\n }\n },\n {\n enabled: !disableGestures,\n },\n )\n\n function getTransitionConfig() {\n const slideActionType = getSlideActionType()\n\n if (slideActionType === 'prev' && toPrevItemSpringProps) {\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...toPrevItemSpringProps.from,\n },\n enter: {\n ...toPrevItemSpringProps.enter,\n },\n leave: {\n ...toPrevItemSpringProps.leave,\n },\n }\n }\n\n if (slideActionType === 'next' && toNextItemSpringProps) {\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...toNextItemSpringProps.from,\n },\n enter: {\n ...toNextItemSpringProps.enter,\n },\n leave: {\n ...toNextItemSpringProps.leave,\n },\n }\n }\n\n return {\n initial: {\n ...springAnimationProps.initial,\n },\n from: {\n ...springAnimationProps.from,\n },\n enter: {\n ...springAnimationProps.enter,\n },\n leave: {\n ...springAnimationProps.leave,\n },\n }\n }\n\n const transitions = useTransition(activeItem, {\n config: springConfig,\n ...getTransitionConfig(),\n onStart: () => setIsAnimating(true),\n trail,\n exitBeforeEnter,\n key: items[activeItem].id,\n onRest: val => {\n if (val.finished) {\n setIsAnimating(false)\n emitObservable({\n eventName: 'onSlideChange',\n slideActionType: getSlideActionType(),\n currentItem: {\n index: activeItem,\n id: items[activeItem].id,\n },\n })\n }\n },\n })\n const itemsFragment = transitions((styles, item) => (\n <animated.div\n style={{\n ...styles,\n flex: '1 0 100%',\n width: '100%',\n height: '100%',\n }}\n >\n {items[item].renderItem}\n </animated.div>\n ))\n\n function getIsAnimating() {\n return isAnimating.current\n }\n function setIsAnimating(val: boolean) {\n isAnimating.current = val\n }\n function setSlideActionType(type: SlideActionType) {\n slideActionType.current = type\n }\n function getSlideActionType() {\n return slideActionType.current\n }\n function slideToItem(item: string | number) {\n let itemIndex = 0\n\n if (typeof item === 'string') {\n itemIndex = items.findIndex(_item => _item.id === item)\n } else {\n itemIndex = item\n }\n\n if (itemIndex >= items.length) {\n throw Error(\n `The item you want to slide to doesn't exist. This could be due to the fact that \n you provide a wrong id or a higher numeric index.`,\n )\n }\n\n if (itemIndex === activeItem) {\n return\n }\n\n const currentItem = findItemIndex(items[activeItem].id)\n const newActiveItem = findItemIndex(items[itemIndex].id)\n\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: newActiveItem,\n id: items[itemIndex].id,\n },\n })\n\n if (newActiveItem > currentItem) {\n setSlideActionType('next')\n } else {\n setSlideActionType('prev')\n }\n\n setActiveItem(itemIndex)\n\n if (enableThumbsWrapperScroll && withThumbs) {\n handleThumbsScroll(itemIndex)\n }\n }\n function slideToNextItem() {\n const isLastItem = activeItem === items.length - 1\n\n if (withLoop) {\n setSlideActionType('next')\n if (isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: 0,\n id: items[0].id,\n },\n })\n setActiveItem(0)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setActiveItem(activeItem + 1)\n }\n } else {\n if (!isLastItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem + 1,\n id: items[activeItem + 1].id,\n },\n })\n setSlideActionType('next')\n setActiveItem(activeItem + 1)\n }\n }\n }\n function slideToPrevItem() {\n const isFirstItem = activeItem === 0\n\n if (withLoop) {\n setSlideActionType('prev')\n if (isFirstItem) {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: items.length - 1,\n id: items[items.length - 1].id,\n },\n })\n\n setActiveItem(items.length - 1)\n } else {\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n } else {\n if (!isFirstItem) {\n setSlideActionType('prev')\n emitObservable({\n eventName: 'onSlideStartChange',\n slideActionType: getSlideActionType(),\n nextItem: {\n index: activeItem - 1,\n id: items[activeItem - 1].id,\n },\n })\n setActiveItem(activeItem - 1)\n }\n }\n }\n function findItemIndex(id: string) {\n return items.findIndex(item => item.id === id)\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === items.length - 1) {\n return itemIndex === 0\n }\n\n return itemIndex === activeItem + 1\n }\n function getIsPrevItem(id: string) {\n const itemIndex = findItemIndex(id)\n\n if (withLoop && activeItem === 0) {\n return itemIndex === items.length - 1\n }\n\n return itemIndex === activeItem - 1\n }\n\n const contextProps: UseTransitionCarouselContextProps = {\n activeItem,\n slideToItem,\n slideToNextItem,\n slideToPrevItem,\n enterFullscreen,\n exitFullscreen,\n useListenToCustomEvent,\n getIsNextItem,\n getIsPrevItem,\n getIsAnimating,\n getIsFullscreen,\n getIsActiveItem: id => {\n return findItemIndex(id) === activeItem\n },\n getCurrentActiveItem: () => ({\n id: items[activeItem].id,\n index: activeItem,\n }),\n }\n\n const carouselFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n <div\n ref={mainCarouselWrapperRef}\n {...bindSwipe()}\n style={{\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n }}\n >\n {itemsFragment}\n </div>\n </UseTransitionCarouselContext.Provider>\n )\n\n const thumbsFragment = (\n <UseTransitionCarouselContext.Provider value={contextProps}>\n {_thumbsFragment}\n </UseTransitionCarouselContext.Provider>\n )\n\n return {\n carouselFragment,\n thumbsFragment,\n ...contextProps,\n }\n}\n\nexport { useTransitionCarouselContext, useTransitionCarousel }\n"],"names":["useCustomEventsModule","eventsObserverRef","useRef","Subject","useListenToCustomEvent","fn","useEffect","subscribe","current","unsubscribe","emitObservable","data","next","useIsomorphicLayoutEffect","window","useLayoutEffect","useIsomorphicMount","callback","isMounted","clean","useFullscreenModule","mainCarouselWrapperRef","handleResize","isFullscreen","setIsFullscreen","_isFullscreen","handleFullscreenChange","document","fullscreenElement","eventName","screenfull","isEnabled","on","off","enterFullscreen","elementRef","request","exitFullscreen","exit","getIsFullscreen","useThumbsModule","items","withThumbs","thumbsSlideAxis","springConfig","prepareThumbsData","getFluidWrapperScrollValue","getSlideValue","slideType","internalThumbsWrapperRef","thumbListStyles","setThumbListStyles","useSpring","x","y","config","onChange","value","Math","abs","getCurrentThumbScrollValue","getThumbsTotalScrollableValue","round","Number","getBoundingClientRect","getThumbSlideValue","thumbSlideTotal","Error","thumbsFragment","_jsx","animated","div","ref","className","onWheel","stop","style","display","flex","position","width","height","flexDirection","overflowX","overflowY","maxHeight","getPreparedItems","_items","map","i","id","renderThumb","handlePrepareThumbsData","thumbId","handleThumbsScroll","activeItem","actionType","totalScrollableValue","nextValue","start","from","[object Object]","to","thumbNode","querySelector","thumbWrapper","offsetDimension","scrollDirection","thumbOffsetPosition","offsetDirection","getThumbOffsetPosition","thumbScrollDimension","getThumbScrollDimension","fromValue","getScrollFromValue","toValue","scrollDimensionProperty","length","getScrollToValue","scrollLeft","scrollTop","Context","createContext","undefined","defaultDragSpringConfig","default","mass","velocity","UseTransitionCarouselContext","withLoop","draggingSlideTreshold","shouldResizeOnWindowResize","enableThumbsWrapperScroll","slideWhenThresholdIsReached","carouselSlideAxis","initialActiveItem","initialStartingPosition","disableGestures","gutter","startEndGutter","touchAction","slideAmount","freeScroll","enableFreeScrollDrag","itemsPerSlide","isFirstMount","slideActionType","internalItems","carouselTrackWrapperRef","isDragging","isAnimating","windowIsHidden","fluidTotalWrapperScrollValue","slideEndReached","currentWindowWidth","initialWindowWidth","prevSlidedValue","prevItems","draggingSlideTresholdRef","itemsPerSlideRef","gutterRef","startEndGutterRef","initialActiveItemRef","initialStartingPositionRef","carouselSlideAxisRef","carouselStyles","setCarouselStyles","getCarouselItemWidth","carouselItem","getCurrentSlidedValue","get","getIfItemsNotFillTheCarousel","getMainCarouselWrapperWidth","getIsFirstItem","getCurrentActiveItem","itemVal","adjustCarouselWrapperPosition","_initialActiveItem","positionProperty","getDefaultPositionValue","setPosition","v","top","left","setStartPosition","setEndPosition","resize","innerWidth","immediate","floor","_thumbsFragment","getWrapperScrollDirection","getIfShouldEnableFluidDrag","bindDrag","useDrag","props","dragging","movement","offset","currentMovement","prevItemTreshold","nextItemTreshold","direction","cancelDrag","cancel","setDragDirection","setSlideActionType","emitDragObservable","getSlideActionType","resetAnimation","checkBounds","getIsDragging","setIsDragging","friction","tension","last","slideToPrevItem","slideToNextItem","getIsLastItem","enabled","axis","type","setActiveItem","newItem","setIsAnimating","val","getPrevItem","currentActiveItem","getNextItem","findItemIndex","findIndex","item","getToValue","customTo","slideToItem","onRest","nextItem","index","getFromValue","finished","currentItem","nextPrevValue","nextItemWillExceed","willExceed","currentWidth","_slideToItem","itemIndex","_item","console","warn","handleVisibilityChange","hidden","addEventListener","removeEventListener","contextProps","getIsAnimating","getIsNextItem","getIsPrevItem","getIsActiveItem","carouselFragment","Provider","percentValue","getAnimatedWrapperStyles","totalValue","singleItemValue","cssProp","quantityToMove","getInitialStyles","renderItem","_itemsPerSlide","marginRight","marginBottom","context","useContext","toPrevItemSpringProps","toNextItemSpringProps","trail","exitBeforeEnter","springAnimationProps","initial","opacity","enter","leave","useState","bindSwipe","mx","isFirstItem","isLastItem","itemsFragment","useTransition","getTransitionConfig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AErDhF,EAAe,CACbmB,UAAW,qBACXqH,gBAAiB8D,IACjB4B,SAAU,CACRC,MAAO0D,EACP7M,GAAIjD,EAAM6M,GAAW5J,MAKvBoH,EADEyF,EAAgBvD,EACC,OAEA,QAGrBlB,EAAcwB,GAEVlH,GAA6B1F,GAC/BoD,EAAmBwJ,IA+GrB7B,gBAAAA,EACAD,gBAAAA,EACAtL,gBAAAA,EACAG,eAAAA,EACAjC,uBAAAA,EACA4P,cA3BF,SAAuBtK,GACrB,MAAM4J,EAAYjB,EAAc3I,GAEhC,OAAIuC,GAAYlC,IAAetD,EAAM4E,OAAS,EACvB,IAAdiI,EAGFA,IAAcvJ,EAAa,GAqBlCkK,cAnBF,SAAuBvK,GACrB,MAAM4J,EAAYjB,EAAc3I,GAEhC,OAAIuC,GAA2B,IAAflC,EACPuJ,IAAc7M,EAAM4E,OAAS,EAG/BiI,IAAcvJ,EAAa,GAalCgK,eAAAA,EACAxN,gBAAAA,EACA2N,gBAAiBxK,GACR2I,EAAc3I,KAAQK,EAE/B+E,qBAAsB,MACpBpF,GAAIjD,EAAMsD,GAAYL,GACtBmJ,MAAO9I,KAILoK,EACJ9L,MAAC2D,EAA6BoI,wBAAS3M,MAAOqM,aAC5CzL,2BACEG,IAAKnD,GACDuQ,KACJhN,MAAO,CACLC,QAAS,OACTE,SAAU,WACVC,MAAO,OACPC,OAAQ,OACRuN,SAAU,qBAGXR,QAKD5N,EACJC,MAAC2D,EAA6BoI,wBAAS3M,MAAOqM,aAC3ChE,KAIL,sBACEqE,iBAAAA,EACA/L,eAAAA,GACG0L,mCA9YP,WACE,MAAMkB,EAAUC,aAAWjJ,GAE3B,IAAKgJ,EACH,MAAM,IAAI7M,MAAM,+KAIlB,OAAO6M"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/modules/useEventsModule.ts","../../src/modules/useThumbsModule.tsx","../../src/useSpringCarousel.tsx","../../src/modules/useFullscreenModule.ts"],"sourcesContent":["import { FullGestureState } from \"@use-gesture/react\";\nimport { useEffect, useRef } from \"react\";\nimport { SlideActionType, SlideMode } from \"../types/common\";\n\nconst eventLabel = \"RSC::Event\";\n\ntype OnSlideStartChange = {\n eventName: \"onSlideStartChange\";\n slideActionType: SlideActionType;\n slideMode: SlideMode;\n nextItem: {\n index: number;\n id: string;\n startReached: boolean;\n endReached: boolean;\n };\n};\ntype OnSlideChange = {\n eventName: \"onSlideChange\";\n slideActionType: SlideActionType;\n slideMode: SlideMode;\n currentItem: {\n index: number;\n id: string;\n startReached: boolean;\n endReached: boolean;\n };\n};\ntype OnFullscreenChange = {\n eventName: \"onFullscreenChange\";\n isFullscreen: boolean;\n};\ntype OnDrag = Omit<FullGestureState<\"drag\">, \"event\"> & {\n eventName: \"onDrag\";\n slideActionType: SlideActionType;\n};\n\ntype Events = OnSlideStartChange | OnSlideChange | OnDrag | OnFullscreenChange;\n\ntype EventHandler = (props: Events) => void;\n\nexport type EmitEvent = (event: Events) => void;\nexport type UseListenToCustomEvent = {\n useListenToCustomEvent: (eventHandler: EventHandler) => void;\n emitEvent: (event: Events) => void;\n};\n\nexport function useEventsModule() {\n const targetEvent = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n targetEvent.current = document.createElement(\"div\");\n }, []);\n\n function useListenToCustomEvent(eventHandler: EventHandler) {\n useEffect(() => {\n function handleEvent(event: CustomEvent<Events>) {\n eventHandler(event.detail);\n }\n\n if (targetEvent.current) {\n // @ts-ignore\n targetEvent.current.addEventListener(eventLabel, handleEvent, false);\n return () => {\n // @ts-ignore\n targetEvent.current?.removeEventListener(\n eventLabel,\n handleEvent,\n false\n );\n };\n }\n }, []);\n }\n function emitEvent(event: Events) {\n if (targetEvent.current) {\n const newEvent = new CustomEvent(eventLabel, {\n detail: event,\n });\n targetEvent.current.dispatchEvent(newEvent);\n }\n }\n\n return {\n useListenToCustomEvent,\n emitEvent,\n };\n}\n","import { useSpring } from \"@react-spring/web\";\nimport { useRef } from \"react\";\nimport {\n SpringCarouselWithThumbs,\n PrepareThumbsData,\n} from \"src/types/internals\";\n\ntype Props = {\n withThumbs?: boolean;\n thumbsSlideAxis: SpringCarouselWithThumbs[\"thumbsSlideAxis\"];\n prepareThumbsData?: PrepareThumbsData;\n items: SpringCarouselWithThumbs[\"items\"];\n};\n\nfunction isInViewport(el: HTMLElement) {\n const rect = el.getBoundingClientRect();\n return (\n rect.top >= 0 &&\n rect.left >= 0 &&\n rect.bottom <=\n (window.innerHeight || document.documentElement.clientHeight) &&\n rect.right <= (window.innerWidth || document.documentElement.clientWidth)\n );\n}\n\nexport function useThumbsModule({\n thumbsSlideAxis = \"x\",\n withThumbs = false,\n prepareThumbsData,\n items,\n}: Props) {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const [spring, setSpring] = useSpring(() => ({\n val: 0,\n }));\n\n function getTotalScrollValue() {\n return Math.round(\n Number(\n wrapperRef.current?.[\n thumbsSlideAxis === \"x\" ? \"scrollWidth\" : \"scrollHeight\"\n ]\n ) -\n wrapperRef.current!.getBoundingClientRect()[\n thumbsSlideAxis === \"x\" ? \"width\" : \"height\"\n ]\n );\n }\n\n function handleScroll(activeItem: number) {\n function getThumbNode() {\n if (wrapperRef.current) {\n return wrapperRef.current.querySelector(\n `#thumb-item-${items[activeItem].id}`\n ) as HTMLElement;\n }\n return null;\n }\n\n const thumbNode = getThumbNode();\n if (thumbNode && wrapperRef.current) {\n if (!isInViewport(thumbNode)) {\n const offset = thumbNode.offsetLeft;\n const val =\n offset > getTotalScrollValue() ? getTotalScrollValue() : offset;\n\n setSpring.start({\n from: {\n val:\n wrapperRef.current?.[\n thumbsSlideAxis === \"x\" ? \"scrollLeft\" : \"scrollTop\"\n ] ?? 0,\n },\n to: {\n val,\n },\n onChange: ({ value }) => {\n if (wrapperRef.current) {\n wrapperRef.current[\n thumbsSlideAxis === \"x\" ? \"scrollLeft\" : \"scrollTop\"\n ] = Math.abs(value.val);\n }\n },\n });\n }\n }\n }\n\n function handlePrepareThumbsData() {\n function getPreparedItems(\n _items: ReturnType<PrepareThumbsData>\n ): ReturnType<PrepareThumbsData> {\n return _items.map((i) => ({\n id: i.id,\n renderThumb: i.renderThumb,\n }));\n }\n\n if (prepareThumbsData) {\n return prepareThumbsData(getPreparedItems(items));\n }\n return getPreparedItems(items);\n }\n\n const thumbsFragment = withThumbs ? (\n <div\n className=\"use-spring-carousel-thumbs-wrapper\"\n ref={wrapperRef}\n onWheel={() => spring.val.stop()}\n style={{\n display: \"flex\",\n flex: \"1\",\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n flexDirection: thumbsSlideAxis === \"x\" ? \"row\" : \"column\",\n ...(thumbsSlideAxis === \"x\"\n ? { overflowX: \"auto\" }\n : {\n overflowY: \"auto\",\n maxHeight: \"100%\",\n }),\n }}\n >\n {handlePrepareThumbsData().map(({ id, renderThumb }) => {\n const thumbId = `thumb-item-${id}`;\n return (\n <div key={thumbId} id={thumbId} className=\"thumb-item\">\n {renderThumb}\n </div>\n );\n })}\n </div>\n ) : null;\n\n return {\n thumbsFragment,\n handleScroll,\n };\n}\n","import { config, useSpring } from \"@react-spring/web\";\nimport React, {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from \"react\";\n\nimport { SlideActionType, SlideMode } from \"./types/common\";\nimport { useEventsModule } from \"./modules/useEventsModule\";\nimport { useDrag } from \"@use-gesture/react\";\nimport { useFullscreenModule } from \"./modules/useFullscreenModule\";\nimport { useThumbsModule } from \"./modules/useThumbsModule\";\nimport {\n UseSpringReturnType,\n UseSpringCarouselWithThumbs,\n UseSpringCarouselComplete,\n UseSpringCarouselWithNoThumbs,\n UseSpringCarouselWithFixedItems,\n UseSpringCarouselWithNoFixedItems,\n SpringCarouselWithThumbs,\n} from \"./types/internals\";\n\nfunction useSpringCarousel(\n props: UseSpringCarouselWithThumbs\n): UseSpringReturnType;\nfunction useSpringCarousel(\n props: UseSpringCarouselWithNoThumbs\n): UseSpringReturnType;\nfunction useSpringCarousel(\n props: UseSpringCarouselWithFixedItems\n): UseSpringReturnType;\nfunction useSpringCarousel(\n props: UseSpringCarouselWithNoFixedItems\n): UseSpringReturnType;\n\nfunction useSpringCarousel({\n items,\n init = true,\n withThumbs,\n thumbsSlideAxis = \"x\",\n itemsPerSlide = 1,\n slideType = \"fixed\",\n gutter = 0,\n withLoop = false,\n startEndGutter = 0,\n carouselSlideAxis = \"x\",\n disableGestures = false,\n draggingSlideTreshold: _draggingSlideTreshold,\n slideWhenThresholdIsReached = false,\n freeScroll,\n enableFreeScrollDrag,\n initialStartingPosition,\n prepareThumbsData,\n initialActiveItem = 0,\n}: UseSpringCarouselComplete) {\n const prevWindowWidth = useRef(0);\n const draggingSlideTreshold = useRef(_draggingSlideTreshold ?? 0);\n const slideActionType = useRef<SlideActionType>(\"initial\");\n const slideModeType = useRef<SlideMode>(\"initial\");\n const prevSlidedValue = useRef(0);\n const [spring, setSpring] = useSpring(() => ({\n val: 0,\n pause: !init,\n onChange({ value }) {\n if (freeScroll && mainCarouselWrapperRef.current) {\n setStartEndItemReachedOnFreeScroll();\n if (carouselSlideAxis === \"x\") {\n mainCarouselWrapperRef.current.scrollLeft = Math.abs(value.val);\n } else {\n mainCarouselWrapperRef.current.scrollTop = Math.abs(value.val);\n }\n } else if (carouselTrackWrapperRef.current) {\n if (carouselSlideAxis === \"x\") {\n carouselTrackWrapperRef.current.style.transform = `translate3d(${value.val}px, 0px,0px)`;\n } else {\n carouselTrackWrapperRef.current.style.transform = `translate3d(0px,${value.val}px,0px)`;\n }\n }\n },\n }));\n const activeItem = useRef(initialActiveItem);\n const firstItemReached = useRef(initialActiveItem === 0);\n const lastItemReached = useRef(false);\n const mainCarouselWrapperRef = useRef<HTMLDivElement | null>(null);\n const carouselTrackWrapperRef = useRef<HTMLDivElement | null>(null);\n\n const getItems = useCallback(() => {\n if (withLoop) {\n return [\n ...items.map((i) => ({\n ...i,\n id: `prev-repeated-item-${i.id}`,\n })),\n ...items,\n ...items.map((i) => ({\n ...i,\n id: `next-repeated-item-${i.id}`,\n })),\n ];\n }\n return [...items];\n }, [items, withLoop]);\n const internalItems = getItems();\n\n const { emitEvent, useListenToCustomEvent } = useEventsModule();\n const { thumbsFragment, handleScroll } = useThumbsModule({\n withThumbs: !!withThumbs,\n thumbsSlideAxis,\n prepareThumbsData,\n items: items as SpringCarouselWithThumbs[\"items\"],\n });\n const { enterFullscreen, exitFullscreen, getIsFullscreen } =\n useFullscreenModule({\n mainCarouselWrapperRef,\n emitEvent,\n handleResize: () => adjustCarouselWrapperPosition(),\n });\n\n function getItemStyles() {\n if (slideType === \"fixed\" && !freeScroll) {\n return {\n marginRight: `${gutter}px`,\n flex: `1 0 calc(100% / ${itemsPerSlide} - ${\n (gutter * (itemsPerSlide - 1)) / itemsPerSlide\n }px)`,\n };\n }\n return {\n ...{ marginRight: `${gutter}px` },\n };\n }\n\n function getSlideValue() {\n const carouselItem = mainCarouselWrapperRef.current?.querySelector(\n \".use-spring-carousel-item\"\n );\n\n if (!carouselItem) {\n throw Error(\"No carousel items available!\");\n }\n\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === \"x\" ? \"width\" : \"height\"\n ] + gutter\n );\n }\n\n type SlideToItem = {\n from: number;\n to: number;\n nextActiveItem?: number;\n immediate?: boolean;\n slideMode: \"click\" | \"drag\";\n };\n\n function slideToItem({\n from,\n to,\n nextActiveItem,\n immediate = false,\n slideMode,\n }: SlideToItem) {\n slideModeType.current = slideMode;\n\n if (typeof nextActiveItem === \"number\") {\n if (!freeScroll) {\n activeItem.current = nextActiveItem;\n }\n emitEvent({\n eventName: \"onSlideStartChange\",\n slideActionType: slideActionType.current,\n slideMode: slideModeType.current,\n nextItem: {\n startReached: firstItemReached.current,\n endReached: lastItemReached.current,\n index: freeScroll ? -1 : activeItem.current,\n id: freeScroll ? \"\" : items[activeItem.current].id,\n },\n });\n }\n\n prevSlidedValue.current = to;\n setSpring.start({\n immediate,\n from: {\n val: from,\n },\n to: {\n val: to,\n },\n config: {\n ...config.default,\n velocity: spring.val.velocity,\n },\n onRest(value) {\n if (!immediate && value.finished) {\n emitEvent({\n eventName: \"onSlideChange\",\n slideActionType: slideActionType.current,\n slideMode: slideModeType.current,\n currentItem: {\n startReached: firstItemReached.current,\n endReached: lastItemReached.current,\n index: freeScroll ? -1 : activeItem.current,\n id: freeScroll ? \"\" : items[activeItem.current].id,\n },\n });\n }\n },\n });\n if (withThumbs && !immediate) {\n handleScroll(activeItem.current);\n }\n }\n\n function getTotalScrollValue() {\n if (withLoop) {\n return getSlideValue() * items.length;\n }\n return Math.round(\n Number(\n carouselTrackWrapperRef.current?.[\n carouselSlideAxis === \"x\" ? \"scrollWidth\" : \"scrollHeight\"\n ]\n ) -\n carouselTrackWrapperRef.current!.getBoundingClientRect()[\n carouselSlideAxis === \"x\" ? \"width\" : \"height\"\n ]\n );\n }\n function getAnimatedWrapperStyles() {\n const percentValue = `calc(100% - ${startEndGutter * 2}px)`;\n return {\n width: carouselSlideAxis === \"x\" ? percentValue : \"100%\",\n height: carouselSlideAxis === \"y\" ? percentValue : \"100%\",\n };\n }\n\n function getCarouselItemWidth() {\n const carouselItem = carouselTrackWrapperRef.current?.querySelector(\n \".use-spring-carousel-item\"\n );\n if (!carouselItem) {\n throw Error(\"No carousel items available!\");\n }\n return (\n carouselItem.getBoundingClientRect()[\n carouselSlideAxis === \"x\" ? \"width\" : \"height\"\n ] + gutter\n );\n }\n function adjustCarouselWrapperPosition() {\n const positionProperty = carouselSlideAxis === \"x\" ? \"left\" : \"top\";\n\n function setPosition(v: number) {\n const ref = carouselTrackWrapperRef.current;\n if (!ref) return;\n\n if (withLoop) {\n ref.style.top = \"0px\";\n ref.style.left = \"0px\";\n ref.style[positionProperty] = `-${v - startEndGutter}px`;\n } else {\n ref.style.left = \"0px\";\n ref.style.top = \"0px\";\n }\n }\n\n const currentFromValue = Math.abs(getFromValue());\n\n if (currentFromValue < getTotalScrollValue() && lastItemReached.current) {\n lastItemReached.current = false;\n }\n if (currentFromValue > getTotalScrollValue()) {\n const val = -getTotalScrollValue();\n lastItemReached.current = true;\n prevSlidedValue.current = val;\n setSpring.start({\n immediate: true,\n val,\n });\n return;\n }\n\n if (initialStartingPosition === \"center\") {\n setPosition(\n getCarouselItemWidth() * items.length -\n getSlideValue() * Math.round((itemsPerSlide - 1) / 2)\n );\n } else if (initialStartingPosition === \"end\") {\n setPosition(\n getCarouselItemWidth() * items.length -\n getSlideValue() * Math.round(itemsPerSlide - 1)\n );\n } else {\n setPosition(getCarouselItemWidth() * items.length);\n }\n\n if (!freeScroll && slideType === \"fixed\") {\n const val = -(getSlideValue() * activeItem.current);\n prevSlidedValue.current = val;\n setSpring.start({\n immediate: true,\n val,\n });\n }\n }\n\n function getFromValue() {\n if (freeScroll && mainCarouselWrapperRef.current) {\n return mainCarouselWrapperRef.current[\n carouselSlideAxis === \"x\" ? \"scrollLeft\" : \"scrollTop\"\n ];\n }\n return spring.val.get();\n }\n function getToValue(type: \"next\" | \"prev\", index?: number) {\n if (freeScroll && type === \"next\") {\n const next = prevSlidedValue.current + getSlideValue();\n if (next > getTotalScrollValue()) {\n return getTotalScrollValue();\n }\n return next;\n }\n\n if (freeScroll && type === \"prev\") {\n const next = prevSlidedValue.current - getSlideValue();\n if (next < 0) {\n return 0;\n }\n return next;\n }\n\n if (type === \"next\") {\n if (index) {\n return -(index * getSlideValue());\n }\n return prevSlidedValue.current - getSlideValue();\n }\n\n if (index) {\n return -(index * getSlideValue());\n }\n return prevSlidedValue.current + getSlideValue();\n }\n function slideToPrevItem(\n type: Exclude<SlideMode, \"initial\"> = \"click\",\n index?: number\n ) {\n if (!init || (firstItemReached.current && !withLoop)) return;\n\n slideActionType.current = \"prev\";\n lastItemReached.current = false;\n\n const nextItem = index || activeItem.current - 1;\n\n if (!withLoop) {\n const nextItemWillExceed =\n getToValue(\"prev\", index) + getSlideValue() / 3 > 0;\n\n if (firstItemReached.current) return;\n if (nextItemWillExceed) {\n firstItemReached.current = true;\n lastItemReached.current = false;\n\n slideToItem({\n slideMode: type,\n from: getFromValue(),\n to: 0,\n nextActiveItem: 0,\n });\n return;\n }\n }\n if (withLoop && firstItemReached.current) {\n firstItemReached.current = false;\n lastItemReached.current = true;\n slideToItem({\n slideMode: type,\n from: getFromValue() - getSlideValue() * items.length,\n to: -(getSlideValue() * items.length) + getSlideValue(),\n nextActiveItem: items.length - 1,\n });\n return;\n }\n if (nextItem === 0) {\n firstItemReached.current = true;\n }\n if (nextItem === items.length - 1 || nextItem === -1) {\n lastItemReached.current = true;\n }\n slideToItem({\n slideMode: type,\n from: getFromValue(),\n to: getToValue(\"prev\", index),\n nextActiveItem: nextItem,\n });\n }\n function slideToNextItem(\n type: Exclude<SlideMode, \"initial\"> = \"click\",\n index?: number\n ) {\n if (!init || (lastItemReached.current && !withLoop)) return;\n\n slideActionType.current = \"next\";\n firstItemReached.current = false;\n\n const nextItem = index || activeItem.current + 1;\n\n if (!withLoop) {\n const nextItemWillExceed =\n Math.abs(getToValue(\"next\", index)) >\n getTotalScrollValue() - getSlideValue() / 3;\n\n if (lastItemReached.current) return;\n if (nextItemWillExceed) {\n firstItemReached.current = false;\n lastItemReached.current = true;\n\n slideToItem({\n slideMode: type,\n from: getFromValue(),\n to: -getTotalScrollValue(),\n nextActiveItem: nextItem,\n });\n return;\n }\n }\n if (withLoop && lastItemReached.current) {\n lastItemReached.current = false;\n firstItemReached.current = true;\n slideToItem({\n slideMode: type,\n from: getFromValue() + getSlideValue() * items.length,\n to: 0,\n nextActiveItem: 0,\n });\n return;\n }\n if (nextItem === 0) {\n firstItemReached.current = true;\n }\n if (nextItem === items.length - 1) {\n lastItemReached.current = true;\n }\n slideToItem({\n slideMode: type,\n from: getFromValue(),\n to: getToValue(\"next\", index),\n nextActiveItem: nextItem,\n });\n }\n\n useEffect(() => {\n prevWindowWidth.current = window.innerWidth;\n }, []);\n useEffect(() => {\n adjustCarouselWrapperPosition();\n }, [\n initialStartingPosition,\n itemsPerSlide,\n withLoop,\n startEndGutter,\n gutter,\n freeScroll,\n slideType,\n init,\n ]);\n useLayoutEffect(() => {\n /**\n * Set initial track position\n */\n if (carouselTrackWrapperRef.current) {\n adjustCarouselWrapperPosition();\n }\n }, []);\n useEffect(() => {\n if (_draggingSlideTreshold) {\n draggingSlideTreshold.current = _draggingSlideTreshold;\n } else {\n draggingSlideTreshold.current = Math.floor(getSlideValue() / 2 / 2);\n }\n }, [_draggingSlideTreshold]);\n useEffect(() => {\n function handleResize() {\n if (window.innerWidth === prevWindowWidth.current) return;\n prevWindowWidth.current = window.innerWidth;\n adjustCarouselWrapperPosition();\n }\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"resize\", handleResize);\n };\n }, []);\n\n const bindDrag = useDrag(\n (state) => {\n const isDragging = state.dragging;\n const movement = state.offset[carouselSlideAxis === \"x\" ? 0 : 1];\n const currentMovement = state.movement[carouselSlideAxis === \"x\" ? 0 : 1];\n const direction = state.direction[carouselSlideAxis === \"x\" ? 0 : 1];\n\n const prevItemTreshold = currentMovement > draggingSlideTreshold.current;\n const nextItemTreshold = currentMovement < -draggingSlideTreshold.current;\n\n if (isDragging) {\n if (direction > 0) {\n slideActionType.current = \"prev\";\n } else {\n slideActionType.current = \"next\";\n }\n\n emitEvent({\n ...state,\n eventName: \"onDrag\",\n slideActionType: slideActionType.current,\n });\n\n if (freeScroll) {\n if (slideActionType.current === \"prev\" && movement > 0) {\n state.cancel();\n setSpring.start({\n from: {\n val: getFromValue(),\n },\n to: {\n val: 0,\n },\n config: {\n velocity: state.velocity,\n friction: 50,\n tension: 1000,\n },\n });\n return;\n }\n\n setSpring.start({\n from: {\n val: getFromValue(),\n },\n to: {\n val: -movement,\n },\n config: {\n velocity: state.velocity,\n friction: 50,\n tension: 1000,\n },\n });\n return;\n }\n\n setSpring.start({\n val: movement,\n config: {\n velocity: state.velocity,\n friction: 50,\n tension: 1000,\n },\n });\n\n if (slideWhenThresholdIsReached && nextItemTreshold) {\n slideToNextItem(\"drag\");\n state.cancel();\n } else if (slideWhenThresholdIsReached && prevItemTreshold) {\n slideToPrevItem(\"drag\");\n state.cancel();\n }\n return;\n }\n\n if (state.last && !state.canceled && freeScroll) {\n if (slideActionType.current === \"prev\") {\n slideToPrevItem(\"drag\");\n }\n if (slideActionType.current === \"next\") {\n slideToNextItem(\"drag\");\n }\n }\n\n if (state.last && !state.canceled && !freeScroll) {\n if (nextItemTreshold) {\n if (!withLoop && lastItemReached.current) {\n setSpring.start({\n val: -getTotalScrollValue(),\n config: {\n ...config.default,\n velocity: state.velocity,\n },\n });\n } else {\n slideToNextItem(\"drag\");\n }\n } else if (prevItemTreshold) {\n if (!withLoop && firstItemReached.current) {\n setSpring.start({\n val: 0,\n config: {\n ...config.default,\n velocity: state.velocity,\n },\n });\n } else {\n slideToPrevItem(\"drag\");\n }\n } else {\n setSpring.start({\n val: prevSlidedValue.current,\n config: {\n ...config.default,\n velocity: state.velocity,\n },\n });\n }\n }\n },\n {\n enabled:\n (init && !disableGestures && !freeScroll) ||\n (!!freeScroll && !!enableFreeScrollDrag),\n axis: carouselSlideAxis,\n from: () => {\n if (freeScroll && mainCarouselWrapperRef.current) {\n return [\n -mainCarouselWrapperRef.current.scrollLeft,\n -mainCarouselWrapperRef.current.scrollTop,\n ];\n }\n if (carouselSlideAxis === \"x\") {\n return [spring.val.get(), spring.val.get()];\n }\n return [spring.val.get(), spring.val.get()];\n },\n }\n );\n\n function getWrapperOverflowStyles() {\n if (freeScroll) {\n if (carouselSlideAxis === \"x\") {\n return {\n overflowX: \"auto\",\n };\n }\n return {\n overflowY: \"auto\",\n };\n }\n return {};\n }\n\n function setStartEndItemReachedOnFreeScroll() {\n if (mainCarouselWrapperRef.current) {\n prevSlidedValue.current =\n mainCarouselWrapperRef.current[\n carouselSlideAxis === \"x\" ? \"scrollLeft\" : \"scrollTop\"\n ];\n if (\n mainCarouselWrapperRef.current[\n carouselSlideAxis === \"x\" ? \"scrollLeft\" : \"scrollTop\"\n ] === 0\n ) {\n firstItemReached.current = true;\n lastItemReached.current = false;\n }\n if (\n mainCarouselWrapperRef.current[\n carouselSlideAxis === \"x\" ? \"scrollLeft\" : \"scrollTop\"\n ] > 0 &&\n mainCarouselWrapperRef.current[\n carouselSlideAxis === \"x\" ? \"scrollLeft\" : \"scrollTop\"\n ] < getTotalScrollValue()\n ) {\n firstItemReached.current = false;\n lastItemReached.current = false;\n }\n if (\n mainCarouselWrapperRef.current[\n carouselSlideAxis === \"x\" ? \"scrollLeft\" : \"scrollTop\"\n ] === getTotalScrollValue()\n ) {\n firstItemReached.current = false;\n lastItemReached.current = true;\n }\n }\n }\n function getScrollHandlers() {\n if (freeScroll) {\n return {\n onWheel() {\n spring.val.stop();\n setStartEndItemReachedOnFreeScroll();\n },\n };\n }\n return {};\n }\n function findItemIndex(id: string) {\n return items.findIndex((item) => item.id === id);\n }\n function findItemIndexById(id: string | number, error: string) {\n let itemIndex = 0;\n if (typeof id === \"string\") {\n itemIndex = items.findIndex((_item) => _item.id === id);\n } else {\n itemIndex = id;\n }\n\n if (itemIndex < 0 || itemIndex >= items.length) {\n throw new Error(error);\n }\n\n return itemIndex;\n }\n function internalSlideToItem(id: string | number) {\n if (!init) return;\n\n firstItemReached.current = false;\n lastItemReached.current = false;\n\n const itemIndex = findItemIndexById(\n id,\n \"The item you want to slide to doesn't exist; please check che item id or the index you're passing to.\"\n );\n\n if (itemIndex === activeItem.current) {\n return;\n }\n\n const currentItem = findItemIndex(items[activeItem.current].id);\n const newActiveItem = findItemIndex(items[itemIndex].id);\n\n if (newActiveItem > currentItem) {\n slideToNextItem(\"click\", newActiveItem);\n } else {\n slideToPrevItem(\"click\", newActiveItem);\n }\n }\n function getIsNextItem(id: string) {\n const itemIndex = findItemIndex(id);\n const _activeItem = activeItem.current;\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 = activeItem.current;\n if (withLoop && _activeItem === 0) {\n return itemIndex === items.length - 1;\n }\n return itemIndex === _activeItem - 1;\n }\n\n const carouselFragment = (\n <div\n ref={mainCarouselWrapperRef}\n {...getScrollHandlers()}\n style={{\n display: \"flex\",\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n ...(getWrapperOverflowStyles() as React.CSSProperties),\n }}\n >\n <div\n ref={carouselTrackWrapperRef}\n {...bindDrag()}\n style={{\n position: \"relative\",\n display: \"flex\",\n flexDirection: carouselSlideAxis === \"x\" ? \"row\" : \"column\",\n touchAction: \"none\",\n ...getAnimatedWrapperStyles(),\n }}\n >\n {internalItems.map((item, index) => {\n return (\n <div\n key={`${item.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 flex: \"1\",\n ...getItemStyles(),\n }}\n >\n {item.renderItem}\n </div>\n );\n })}\n </div>\n </div>\n );\n\n return {\n useListenToCustomEvent,\n carouselFragment,\n enterFullscreen,\n exitFullscreen,\n getIsFullscreen,\n thumbsFragment,\n slideToItem: internalSlideToItem,\n getIsNextItem,\n getIsPrevItem,\n slideToPrevItem: () => slideToPrevItem(),\n slideToNextItem: () => slideToNextItem(),\n getIsActiveItem: (id: string | number) => {\n return (\n findItemIndexById(id, \"The item you want to check doesn't exist\") ===\n activeItem.current\n );\n },\n };\n}\n\nconst Context =\n createContext<\n Omit<UseSpringReturnType, \"carouselFragment\" | \"thumbsFragment\"> | undefined\n >(undefined);\n\nfunction useSpringCarouselContext() {\n const context = useContext(Context);\n if (!context) {\n throw new Error(\n \"useSpringCarouselContext must be used within the carousel.\"\n );\n }\n return context;\n}\n\nexport { useSpringCarousel, useSpringCarouselContext };\n","import { useRef, MutableRefObject, useEffect } from \"react\";\nimport screenfull from \"screenfull\";\nimport { EmitEvent } from \"./useEventsModule\";\n\ntype FullscreenModule = {\n mainCarouselWrapperRef: MutableRefObject<HTMLDivElement | null>;\n emitEvent: EmitEvent;\n handleResize?(): void;\n};\n\nexport function useFullscreenModule({\n mainCarouselWrapperRef,\n emitEvent,\n handleResize,\n}: FullscreenModule) {\n const isFullscreen = useRef(false);\n\n useEffect(() => {\n function handleFullscreenChange() {\n if (document.fullscreenElement) {\n setIsFullscreen(true);\n emitEvent({\n eventName: \"onFullscreenChange\",\n isFullscreen: true,\n });\n\n handleResize && handleResize();\n }\n\n if (!document.fullscreenElement) {\n setIsFullscreen(false);\n emitEvent({\n eventName: \"onFullscreenChange\",\n isFullscreen: false,\n });\n handleResize && handleResize();\n }\n }\n\n if (screenfull.isEnabled) {\n screenfull.on(\"change\", handleFullscreenChange);\n return () => {\n if (screenfull.isEnabled) {\n screenfull.off(\"change\", handleFullscreenChange);\n }\n };\n }\n }, []);\n\n function setIsFullscreen(_isFullscreen: boolean) {\n isFullscreen.current = _isFullscreen;\n }\n\n function getIsFullscreen() {\n return isFullscreen.current;\n }\n\n function enterFullscreen(elementRef?: HTMLElement) {\n if (screenfull.isEnabled) {\n screenfull.request(\n (elementRef || mainCarouselWrapperRef.current) as Element\n );\n }\n }\n\n function exitFullscreen() {\n screenfull.isEnabled && screenfull.exit();\n }\n\n return {\n enterFullscreen,\n exitFullscreen,\n getIsFullscreen,\n };\n}\n"],"names":["eventLabel","useThumbsModule","thumbsSlideAxis","withThumbs","prepareThumbsData","items","wrapperRef","useRef","spring","setSpring","useSpring","val","getTotalScrollValue","Math","round","Number","_a","current","getBoundingClientRect","thumbsFragment","_jsx","jsx","Object","assign","className","ref","onWheel","stop","style","display","flex","position","width","height","flexDirection","overflowX","overflowY","maxHeight","children","getPreparedItems","_items","map","i","id","renderThumb","handlePrepareThumbsData","thumbId","handleScroll","activeItem","thumbNode","querySelector","el","rect","top","left","bottom","window","innerHeight","document","documentElement","clientHeight","right","innerWidth","clientWidth","isInViewport","offset","offsetLeft","start","from","to","onChange","value","abs","Context","createContext","undefined","init","itemsPerSlide","slideType","gutter","withLoop","startEndGutter","carouselSlideAxis","disableGestures","draggingSlideTreshold","_draggingSlideTreshold","slideWhenThresholdIsReached","freeScroll","enableFreeScrollDrag","initialStartingPosition","initialActiveItem","prevWindowWidth","slideActionType","slideModeType","prevSlidedValue","pause","mainCarouselWrapperRef","setStartEndItemReachedOnFreeScroll","scrollLeft","scrollTop","carouselTrackWrapperRef","transform","firstItemReached","lastItemReached","internalItems","useCallback","getItems","emitEvent","useListenToCustomEvent","targetEvent","useEffect","createElement","eventHandler","handleEvent","event","detail","addEventListener","removeEventListener","newEvent","CustomEvent","dispatchEvent","useEventsModule","enterFullscreen","exitFullscreen","getIsFullscreen","handleResize","isFullscreen","setIsFullscreen","_isFullscreen","handleFullscreenChange","fullscreenElement","eventName","screenfull","isEnabled","on","off","elementRef","request","exit","useFullscreenModule","adjustCarouselWrapperPosition","getSlideValue","carouselItem","Error","slideToItem","nextActiveItem","immediate","slideMode","nextItem","startReached","endReached","index","config","default","velocity","onRest","finished","currentItem","length","getCarouselItemWidth","positionProperty","setPosition","v","currentFromValue","getFromValue","get","getToValue","type","next","slideToPrevItem","nextItemWillExceed","slideToNextItem","useLayoutEffect","floor","bindDrag","useDrag","state","isDragging","dragging","movement","currentMovement","direction","prevItemTreshold","nextItemTreshold","cancel","friction","tension","last","canceled","enabled","axis","findItemIndex","findIndex","item","findItemIndexById","error","itemIndex","_item","carouselFragment","touchAction","percentValue","getAnimatedWrapperStyles","marginRight","renderItem","newActiveItem","getIsNextItem","_activeItem","getIsPrevItem","getIsActiveItem","context","useContext"],"mappings":"qhBAIA,MAAMA,EAAa,aCqBH,SAAAC,GAAgBC,gBAC9BA,EAAkB,IAAGC,WACrBA,GAAa,EAAKC,kBAClBA,EAAiBC,MACjBA,IAEA,MAAMC,EAAaC,SAA8B,OAC1CC,EAAQC,GAAaC,EAASA,WAAC,KAAO,CAC3CC,IAAK,MAGP,SAASC,UACP,OAAOC,KAAKC,MACVC,OACoB,QAAlBC,EAAAV,EAAWW,eAAO,IAAAD,OAAA,EAAAA,EACI,MAApBd,EAA0B,cAAgB,iBAG5CI,EAAWW,Q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c,EAAgB,QAASiC,GAEzBnC,EAAgB,QAASmC,EAE5B,EAsECC,cArEF,SAAuBlK,GACrB,MAAMyJ,EAAYL,GAAcpJ,GAC1BmK,EAAc9J,EAAW/B,QAC/B,OAAI+D,GAAY8H,IAAgBzM,EAAMyJ,OAAS,EACxB,IAAdsC,EAEFA,IAAcU,EAAc,CACpC,EA+DCC,cA9DF,SAAuBpK,GACrB,MAAMyJ,EAAYL,GAAcpJ,GAC1BmK,EAAc9J,EAAW/B,QAC/B,OAAI+D,GAA4B,IAAhB8H,EACPV,IAAc/L,EAAMyJ,OAAS,EAE/BsC,IAAcU,EAAc,CACpC,EAwDCrC,gBAAiB,IAAMA,IACvBE,gBAAiB,IAAMA,IACvBqC,gBAAkBrK,GAEduJ,GAAkBvJ,EAAI,8CACtBK,EAAW/B,QAInB,6BAOA,WACE,MAAMgM,EAAUC,aAAWzI,GAC3B,IAAKwI,EACH,MAAM,IAAIlE,MACR,8DAGJ,OAAOkE,CACT"}
|
package/package.json
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-spring-carousel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta001",
|
|
4
4
|
"description": "A new <Carousel /> experience for the web",
|
|
5
5
|
"homepage": "https://react-spring-carousel.emilianobucci.com",
|
|
6
6
|
"repository": "https://github.com/Emiliano-Bucci/react-spring-carousel",
|
|
7
7
|
"author": "Emiliano Bucci",
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"keywords": [
|
|
10
|
-
"react",
|
|
11
|
-
"react-spring",
|
|
12
|
-
"carousel",
|
|
13
|
-
"react-carousel",
|
|
14
|
-
"react-spring-carousel",
|
|
15
|
-
"slider",
|
|
16
|
-
"react-slider",
|
|
17
|
-
"react-spring-slider",
|
|
18
|
-
"animated"
|
|
19
|
-
],
|
|
20
9
|
"main": "./dist/cjs/index.js",
|
|
21
10
|
"module": "./dist/esm",
|
|
22
|
-
"
|
|
11
|
+
"type": "module",
|
|
23
12
|
"files": [
|
|
24
13
|
"dist"
|
|
25
14
|
],
|
|
@@ -29,83 +18,67 @@
|
|
|
29
18
|
"default": "./dist/esm/index.js"
|
|
30
19
|
}
|
|
31
20
|
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"react",
|
|
23
|
+
"react-spring",
|
|
24
|
+
"carousel",
|
|
25
|
+
"react-carousel",
|
|
26
|
+
"react-spring-carousel",
|
|
27
|
+
"slider",
|
|
28
|
+
"react-slider",
|
|
29
|
+
"react-spring-slider",
|
|
30
|
+
"animated"
|
|
31
|
+
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
34
|
+
"storybook": "start-storybook -p 6006",
|
|
35
35
|
"build-storybook": "build-storybook",
|
|
36
|
+
"clean": "rimraf dist",
|
|
36
37
|
"build:lib": "npm run clean && rollup -c",
|
|
37
|
-
"lint": "eslint --fix --config .eslintrc.js 'src/**/*.{ts,tsx,js}'",
|
|
38
|
-
"prepare": "husky install",
|
|
39
|
-
"lint-staged": "lint-staged",
|
|
40
|
-
"test": "NODE_ENV=test jest --watch",
|
|
41
|
-
"check:tag:branch": "node --experimental-modules scripts/release.js",
|
|
42
|
-
"release:test": "jest",
|
|
43
|
-
"push:tags": "git push --follow-tags",
|
|
44
|
-
"release:lib": "npm run lint && npm run check:tag:branch && npm run build:lib && npm run push:tags && npm publish",
|
|
45
|
-
"storybook": "start-storybook -p 6006",
|
|
46
38
|
"release:beta": "npm run build:lib && npm publish --tag beta"
|
|
47
39
|
},
|
|
48
|
-
"dependencies": {
|
|
49
|
-
"@use-gesture/react": "^10.2.11",
|
|
50
|
-
"rxjs": "^7.5.4",
|
|
51
|
-
"screenfull": "^5.2.0"
|
|
52
|
-
},
|
|
53
40
|
"devDependencies": {
|
|
54
|
-
"@babel/core": "^7.
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"@types/jest": "^27.4.1",
|
|
70
|
-
"@types/react": "^18.0.5",
|
|
71
|
-
"@types/react-dom": "^18.0.1",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^5.13.0",
|
|
73
|
-
"@typescript-eslint/parser": "^5.13.0",
|
|
74
|
-
"babel-loader": "^8.2.3",
|
|
75
|
-
"chalk": "^5.0.0",
|
|
76
|
-
"eslint": "^8.10.0",
|
|
41
|
+
"@babel/core": "^7.19.3",
|
|
42
|
+
"@storybook/addon-actions": "^6.5.12",
|
|
43
|
+
"@storybook/addon-essentials": "^6.5.12",
|
|
44
|
+
"@storybook/addon-interactions": "^6.5.12",
|
|
45
|
+
"@storybook/addon-links": "^6.5.12",
|
|
46
|
+
"@storybook/builder-webpack4": "^6.5.12",
|
|
47
|
+
"@storybook/manager-webpack4": "^6.5.12",
|
|
48
|
+
"@storybook/react": "^6.5.12",
|
|
49
|
+
"@storybook/testing-library": "^0.0.13",
|
|
50
|
+
"@types/react": "^18.0.21",
|
|
51
|
+
"@types/react-dom": "^18.0.6",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.40.0",
|
|
53
|
+
"@typescript-eslint/parser": "^5.40.0",
|
|
54
|
+
"babel-loader": "^8.2.5",
|
|
55
|
+
"eslint": "^8.25.0",
|
|
77
56
|
"eslint-config-prettier": "^8.5.0",
|
|
78
|
-
"eslint-plugin-prettier": "^4.
|
|
79
|
-
"eslint-plugin-react": "^7.
|
|
80
|
-
"eslint-plugin-react-hooks": "^4.
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"husky": "^7.0.4",
|
|
84
|
-
"jest": "^27.5.1",
|
|
85
|
-
"lint-staged": "^12.3.4",
|
|
86
|
-
"prettier": "^2.5.1",
|
|
87
|
-
"react-spring-carousel": "^2.0.13",
|
|
57
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
58
|
+
"eslint-plugin-react": "^7.31.10",
|
|
59
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
60
|
+
"react": "^18.2.0",
|
|
61
|
+
"react-dom": "^18.2.0",
|
|
88
62
|
"rimraf": "^3.0.2",
|
|
89
|
-
"rollup": "^
|
|
63
|
+
"rollup": "^3.1.0",
|
|
64
|
+
"typescript": "^4.8.4",
|
|
90
65
|
"rollup-plugin-babel": "^4.4.0",
|
|
91
66
|
"rollup-plugin-exclude-dependencies-from-bundle": "^1.1.22",
|
|
92
67
|
"rollup-plugin-filesize": "^9.1.2",
|
|
93
68
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
94
69
|
"rollup-plugin-terser": "^7.0.2",
|
|
95
|
-
"rollup-plugin-typescript2": "^0.
|
|
96
|
-
"rollup-plugin-visualizer": "^5.
|
|
97
|
-
"
|
|
98
|
-
"
|
|
70
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
71
|
+
"rollup-plugin-visualizer": "^5.8.2",
|
|
72
|
+
"@rollup/plugin-commonjs": "^21.0.2",
|
|
73
|
+
"@rollup/plugin-node-resolve": "^13.1.3"
|
|
99
74
|
},
|
|
100
75
|
"peerDependencies": {
|
|
101
|
-
"react": "^18.
|
|
102
|
-
"react-dom": "^18.
|
|
103
|
-
"react-spring": "^9.4.5-beta.0 "
|
|
76
|
+
"react": "^18.2.0",
|
|
77
|
+
"react-dom": "^18.2.0"
|
|
104
78
|
},
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
]
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"@react-spring/web": "^9.5.5",
|
|
81
|
+
"@use-gesture/react": "^10.2.20",
|
|
82
|
+
"screenfull": "^5.2.0"
|
|
110
83
|
}
|
|
111
84
|
}
|
package/dist/esm/index3.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{createContext as t,useContext as n,useRef as i,useState as r}from"react";import{config as s,useTransition as o,animated as a}from"react-spring";import{useDrag as l}from"@use-gesture/react";import{a as d,b as c,c as u}from"./useThumbsModule-0944decf.js";import"rxjs";import"screenfull";const m=t(void 0);function g(){const e=n(m);if(!e)throw new Error("useTransitionCarouselContext isn't being used within the useTransitionCarousel context; \n use the context only inside a component that is rendered within the Carousel.");return e}function h({items:t,withLoop:n=!1,withThumbs:g=!1,springConfig:h=s.default,thumbsSlideAxis:p="x",enableThumbsWrapperScroll:f=!0,draggingSlideTreshold:b=50,prepareThumbsData:x,toPrevItemSpringProps:v,toNextItemSpringProps:I,disableGestures:T=!1,trail:S,exitBeforeEnter:j=!1,springAnimationProps:O={initial:{opacity:1,position:"absolute"},from:{opacity:0,position:"absolute"},enter:{opacity:1,position:"absolute"},leave:{opacity:0,position:"absolute"}}}){const y=i("next"),C=i(null),w=i(!1),[A,N]=r(0),{emitObservable:F,useListenToCustomEvent:P}=d(),{enterFullscreen:E,exitFullscreen:L,getIsFullscreen:R}=c({emitObservable:F,mainCarouselWrapperRef:C}),{thumbsFragment:B,handleThumbsScroll:D}=u({items:t,withThumbs:g,thumbsSlideAxis:p,springConfig:h,prepareThumbsData:x,slideType:"fixed"}),W=l((({last:e,movement:[i]})=>{if(!G()&&e){const e=i>b,r=i<-b,s=0===A,o=A===t.length-1;if(r){if(!n&&o)return;H(),F({eventName:"onLeftSwipe"})}else if(e){if(!n&&s)return;J(),F({eventName:"onRightSwipe"})}}}),{enabled:!T});const k=o(A,Object.assign(Object.assign({config:h},function(){const e=z();return"prev"===e&&v?{initial:Object.assign({},O.initial),from:Object.assign({},v.from),enter:Object.assign({},v.enter),leave:Object.assign({},v.leave)}:"next"===e&&I?{initial:Object.assign({},O.initial),from:Object.assign({},I.from),enter:Object.assign({},I.enter),leave:Object.assign({},I.leave)}:{initial:Object.assign({},O.initial),from:Object.assign({},O.from),enter:Object.assign({},O.enter),leave:Object.assign({},O.leave)}}()),{onStart:()=>M(!0),trail:S,exitBeforeEnter:j,key:t[A].id,onRest:e=>{e.finished&&(M(!1),F({eventName:"onSlideChange",slideActionType:z(),currentItem:{index:A,id:t[A].id}}))}}))(((n,i)=>e(a.div,Object.assign({style:Object.assign(Object.assign({},n),{flex:"1 0 100%",width:"100%",height:"100%"})},{children:t[i].renderItem}))));function G(){return w.current}function M(e){w.current=e}function q(e){y.current=e}function z(){return y.current}function H(){const e=A===t.length-1;n?(q("next"),e?(F({eventName:"onSlideStartChange",slideActionType:z(),nextItem:{index:0,id:t[0].id}}),N(0)):(F({eventName:"onSlideStartChange",slideActionType:z(),nextItem:{index:A+1,id:t[A+1].id}}),N(A+1))):e||(F({eventName:"onSlideStartChange",slideActionType:z(),nextItem:{index:A+1,id:t[A+1].id}}),q("next"),N(A+1))}function J(){const e=0===A;n?(q("prev"),e?(F({eventName:"onSlideStartChange",slideActionType:z(),nextItem:{index:t.length-1,id:t[t.length-1].id}}),N(t.length-1)):(F({eventName:"onSlideStartChange",slideActionType:z(),nextItem:{index:A-1,id:t[A-1].id}}),N(A-1))):e||(q("prev"),F({eventName:"onSlideStartChange",slideActionType:z(),nextItem:{index:A-1,id:t[A-1].id}}),N(A-1))}function K(e){return t.findIndex((t=>t.id===e))}const Q={activeItem:A,slideToItem:function(e){let n=0;if(n="string"==typeof e?t.findIndex((t=>t.id===e)):e,n>=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(n===A)return;const i=K(t[A].id),r=K(t[n].id);F({eventName:"onSlideStartChange",slideActionType:z(),nextItem:{index:r,id:t[n].id}}),q(r>i?"next":"prev"),N(n),f&&g&&D(n)},slideToNextItem:H,slideToPrevItem:J,enterFullscreen:E,exitFullscreen:L,useListenToCustomEvent:P,getIsNextItem:function(e){const i=K(e);return n&&A===t.length-1?0===i:i===A+1},getIsPrevItem:function(e){const i=K(e);return n&&0===A?i===t.length-1:i===A-1},getIsAnimating:G,getIsFullscreen:R,getIsActiveItem:e=>K(e)===A,getCurrentActiveItem:()=>({id:t[A].id,index:A})},U=e(m.Provider,Object.assign({value:Q},{children:e("div",Object.assign({ref:C},W(),{style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden"}},{children:k}))})),V=e(m.Provider,Object.assign({value:Q},{children:B}));return Object.assign({carouselFragment:U,thumbsFragment:V},Q)}export{h as useTransitionCarousel,g as useTransitionCarouselContext};
|
|
2
|
-
//# sourceMappingURL=index3.js.map
|