Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-simply-carousel

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simply-carousel - npm Package Compare versions

Comparing version 9.0.2 to 9.0.3

2

dist/index.esm.js

@@ -1,1 +0,1 @@

import e,{memo as t,useState as n,useRef as i,Children as r,useCallback as o,useEffect as d}from"react";var l=function(){return l=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},l.apply(this,arguments)};function c(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),d=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)d.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return d}function a(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var u=t((function(t){var u=t.responsiveProps,v=void 0===u?[]:u,m=c(t,["responsiveProps"]),f=s(n(0),2),h=f[0],p=f[1],b=s(n(m.activeSlideIndex),2),w=b[0],y=b[1],x=i(null),S=i(null),g=i(null),E=i(!1),L=i(0),T=i(!1),I=i(""),k=i(null),C=i(null),M=i(0),W=i(w),P=v.reduce((function(e,t){void 0===t&&(t={});var n=t.minWidth,i=void 0===n?0:n,r=t.maxWidth,o=void 0===r?null:r,d=c(t,["minWidth","maxWidth"]);return h>i&&(!o||h<=o)?l(l({},e),d):e}),m),O=r.toArray(P.children),X=h?l(l({},P),{activeSlideIndex:Math.max(0,Math.min(P.activeSlideIndex,O.length-1)),itemsToShow:Math.min(O.length,P.itemsToShow||0),itemsToScroll:Math.min(O.length,P.itemsToScroll||1)}):m,A=X.containerProps,N=void 0===A?{}:A,F=N.style,V=void 0===F?{}:F,j=c(N,["style"]),z=X.innerProps,B=void 0===z?{}:z,R=B.style,D=void 0===R?{}:R,q=c(B,["style"]),H=X.itemsListProps,G=void 0===H?{}:H,J=G.style,K=void 0===J?{}:J,Q=G.onTransitionEnd,U=void 0===Q?void 0:Q,Y=c(G,["style","onTransitionEnd"]),Z=X.backwardBtnProps,$=void 0===Z?{}:Z,_=$.children,ee=void 0===_?null:_,te=$.show,ne=void 0===te||te,ie=c($,["children","show"]),re=X.forwardBtnProps,oe=void 0===re?{}:re,de=oe.children,le=void 0===de?null:de,ce=oe.show,se=void 0===ce||ce,ae=c(oe,["children","show"]),ue=X.activeSlideProps,ve=void 0===ue?{}:ue,me=ve.className,fe=void 0===me?"":me,he=ve.style,pe=void 0===he?{}:he,be=c(ve,["className","style"]),we=X.visibleSlideProps,ye=void 0===we?{}:we,xe=ye.className,Se=void 0===xe?"":xe,ge=ye.style,Ee=void 0===ge?{}:ge,Le=c(ye,["className","style"]),Te=X.updateOnItemClick,Ie=void 0!==Te&&Te,ke=X.activeSlideIndex,Ce=X.onRequestChange,Me=X.speed,We=void 0===Me?0:Me,Pe=X.delay,Oe=void 0===Pe?0:Pe,Xe=X.easing,Ae=void 0===Xe?"linear":Xe,Ne=X.itemsToShow,Fe=void 0===Ne?0:Ne,Ve=X.itemsToScroll,je=void 0===Ve?1:Ve,ze=X.children,Be=X.onAfterChange,Re=X.autoplay,De=void 0!==Re&&Re,qe=X.autoplayDirection,He=void 0===qe?"forward":qe,Ge=X.disableNavIfAllVisible,Je=void 0===Ge||Ge,Ke=X.hideNavIfAllVisible,Qe=void 0===Ke||Ke,Ue=X.centerMode,Ye=void 0!==Ue&&Ue,Ze=X.infinite,$e=void 0===Ze||Ze,_e=X.disableNavIfEdgeVisible,et=void 0===_e||_e,tt=X.disableNavIfEdgeActive,nt=void 0===tt||tt,it=X.dotsNav,rt=void 0===it?{}:it,ot=X.persistentChangeCallbacks,dt=void 0!==ot&&ot,lt=X.autoplayDelay,ct=void 0===lt?0:lt,st=X.preventScrollOnSwipe,at=void 0!==st&&st,ut=X.disableSwipeByMouse,vt=void 0!==ut&&ut,mt=X.disableSwipeByTouch,ft=void 0!==mt&&mt,ht=X.touchSwipeTreshold,pt=X.mouseSwipeTreshold,bt=X.swipeTreshold,wt=X.touchSwipeRatio,yt=X.mouseSwipeRatio,xt=X.swipeRatio,St=void 0===xt?1:xt,gt=rt||{},Et=gt.show,Lt=void 0!==Et&&Et,Tt=gt.containerProps,It=void 0===Tt?{}:Tt,kt=gt.itemBtnProps,Ct=void 0===kt?{}:kt,Mt=gt.activeItemBtnProps,Wt=void 0===Mt?{}:Mt,Pt=r.count(ze)-1,Ot=Fe===O.length,Xt=Qe&&Ot,At=Je&&Ot,Nt=ke-w==0||!We&&!Oe?"none":"transform ".concat(We,"ms ").concat(Ae," ").concat(Oe,"ms"),Ft=o((function(e){var t,n=e.correctionSlideIndex,i=e.prevCorrectionSlideIndex,r=e.curActiveSlideIndex,o=g.current.offsetWidth,d=g.current.children,l=d.length,c=$e?a([],s(d),!1).slice(l/3-i,l/3-i+l/3):a([],s(d),!1),u=null===(t=c[r])||void 0===t?void 0:t.offsetWidth,v=Fe?c.reduce((function(e,t,n){return n>=r&&n<r+Fe||n<r&&n<r+Fe-c.length?e+t.offsetWidth:e}),0):S.current.offsetWidth,m=Math.min(v,S.current.offsetWidth),f=o-m,h=Ye&&$e?-(m-u)/2:0,p=$e?o/3:0,b=n-r==0?0:"forward"===I.current&&r<n?p:"backward"===I.current&&r>n?-p:0,w=r-n!=0,y=function(e){var t=c.reduce((function(t,n,i){return i>=e?t:t+(n.offsetWidth||0)}),0);return $e?t:Math.min(f,t)},x=w&&$e?y(n):0,E=w||!$e?y(r):0,L=At?0:E-x+h+b+p,T="translateX(-".concat(L,"px)"),k=$e?p+h:Math.min(f,c.reduce((function(e,t,n){return n<r?e+t.offsetWidth:e}),0)),C=k+m,M=c.map((function(e,t){return{slideIndex:t,htmlElement:e}})),W=$e?a(a(a(a([],s(c.slice(r).map((function(e,t){return{slideIndex:t+r,htmlElement:e}}))),!1),s(M),!1),s(M),!1),s(c.slice(0,r).map((function(e,t){return{slideIndex:t,htmlElement:e}}))),!1):M,P=W.reduce((function(e,t){var n=t.slideIndex,i=t.htmlElement.offsetWidth;return(e.summ>=k&&e.summ<C||e.summ+i>k&&e.summ+i<=C)&&e.items.push({slideIndex:n,isFullyVisible:e.summ+i<=C&&e.summ>=k}),e.summ+=i,e}),{summ:0,items:[]}),O=!!P.items.find((function(e){return 0===e.slideIndex})),X=!!P.items.find((function(e){return e.slideIndex===c.length-1}));return{slidesHTMLElements:c,innerMaxWidth:v,itemsListMaxTranslateX:f,activeSlideWidth:u,offsetCorrectionForCenterMode:h,offsetCorrectionForInfiniteMode:p,itemsListTranslateX:L,itemsListTransform:T,visibleSlides:P.items,isFirstSlideVisible:O,isLastSlideVisible:X}}),[Ye,At,$e,Fe]),Vt=h?Ft({prevCorrectionSlideIndex:W.current,curActiveSlideIndex:ke,correctionSlideIndex:w}):{},jt=Vt.innerMaxWidth,zt=void 0===jt?0:jt,Bt=Vt.itemsListMaxTranslateX,Rt=void 0===Bt?0:Bt,Dt=Vt.activeSlideWidth,qt=void 0===Dt?0:Dt,Ht=Vt.offsetCorrectionForCenterMode,Gt=void 0===Ht?0:Ht,Jt=Vt.offsetCorrectionForInfiniteMode,Kt=void 0===Jt?0:Jt,Qt=Vt.itemsListTranslateX,Ut=void 0===Qt?0:Qt,Yt=Vt.itemsListTransform,Zt=void 0===Yt?"none":Yt,$t=Vt.visibleSlides,_t=void 0===$t?[]:$t,en=o((function(e){var t;return"forward"===e?(t=ke+je)>Pt?$e?t-Pt-1:Pt:t:"backward"===e?(t=ke-je)<0?$e?Pt+1+t:0:t:ke}),[ke,je,Pt,$e]),tn=o((function(e,t){var n;if(I.current=t,g.current.style.transition=We||Oe?"transform ".concat(We,"ms ").concat(Ae," ").concat(Oe,"ms"):"none",e!==ke||dt){clearTimeout(k.current);var i=Ft({correctionSlideIndex:w,prevCorrectionSlideIndex:w,curActiveSlideIndex:e}),r=i.visibleSlides,o=i.isFirstSlideVisible,d=i.isLastSlideVisible,l=i.itemsListTransform;e!==ke&&(null===(n=g.current)||void 0===n?void 0:n.style.transform)===l&&(E.current=!0),g.current.style.transform=l,Ce(e,{visibleSlides:r,isFirstSlideVisible:o,isLastSlideVisible:d})}else g.current.style.transform="translateX(-".concat(Gt+Kt+($e?0:Ut),"px)")}),[dt,ke,Gt,Oe,Ae,We,Ce,Kt,$e,Ut,w,Ft]),nn=o((function(){De&&(clearTimeout(k.current),k.current=setTimeout((function(){tn(en(He),He)}),ct||Oe))}),[De,He,ct,tn,en,Oe]),rn=o((function(){tn(en("backward"),"backward")}),[tn,en]),on=o((function(e){y(ke),U&&U(e)}),[ke,U]),dn=o((function(){tn(en("forward"),"forward")}),[tn,en]),ln=function(e,t,n){return e.map((function(e,i){var r=e.props,o=void 0===r?{}:r,d=o.className,s=void 0===d?"":d,a=o.onClick,u=void 0===a?null:a,v=o.style,m=void 0===v?{}:v,f=c(o,["className","onClick","style"]),h=c(e,["props"]),p=$e?M.current>=O.length?"forward":"backward":i>=ke?"forward":"backward",b=i+t===ke,w=_t.find((function(e){return e.slideIndex===i+t})),y="".concat(s," ").concat(b?fe:""," ").concat(w?Se:"").trim()||void 0,x=l(l(l(l({},m),w?Ee:{}),b?pe:{}),{boxSizing:"border-box",margin:0}),S=!n&&Ie?function(e){var t=e.direction,n=e.index,i=e.onClick;return function(e){tn(n,t||(ke<n?"forward":"")||(ke>n?"backward":"")),i&&i(e)}}({direction:p,index:i+t,onClick:u}):u,g=l(l(l({role:"tabpanel",className:y,style:x,onClick:S},f),w?Le:{}),b?be:{});return M.current+=1,l({props:g},h)}))};return d((function(){var e=g.current;function t(e){e.preventDefault(),e.stopPropagation()}function n(e){var t,n;T.current=!0;var i=!!(null===(t=e.touches)||void 0===t?void 0:t[0]),r=i?null===(n=e.touches)||void 0===n?void 0:n[0].clientX:e.clientX,o=(L.current-r)*((i?wt:yt)||St)+Gt+Kt+($e?0:Ut),d=g.current.offsetWidth,l=Math.max(-o,-d);g.current.style.transition="none",g.current.style.transform="translateX(".concat(l,"px)")}function i(e){var r,o,d;if(document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",i),T.current){null===(r=e.target)||void 0===r||r.addEventListener("click",t);var l=!!(null===(o=e.changedTouches)||void 0===o?void 0:o[0]),c=l?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,s=(L.current-c)*((l?wt:yt)||St),a=(l?ht:pt)||bt||qt/2,u=s>a?{index:en("forward"),direction:"forward"}:s<-a?{index:en("backward"),direction:"backward"}:{index:ke,direction:"forward"};tn(u.index,u.direction)}else null===(d=e.target)||void 0===d||d.removeEventListener("click",t);L.current=0,T.current=!1}function r(e){var t,r;clearTimeout(k.current);var o=!!(null===(t=e.touches)||void 0===t?void 0:t[0]);L.current=o?null===(r=e.touches)||void 0===r?void 0:r[0].clientX:e.clientX,o?(document.addEventListener("touchmove",n),document.addEventListener("touchend",i)):(document.addEventListener("mousemove",n),document.addEventListener("mouseup",i))}return At||(vt||null==e||e.addEventListener("mousedown",r),ft||null==e||e.addEventListener("touchstart",r,{passive:!0}),vt&&ft||null==e||e.addEventListener("dragstart",i)),function(){T.current=!1,L.current=0,null==e||e.removeEventListener("mousedown",r),null==e||e.removeEventListener("touchstart",r),null==e||e.removeEventListener("dragstart",i),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",i)}}),[$e,Ut,Zt,Gt,Kt,ke,qt,en,tn,At,vt,ft,ht,pt,bt,wt,yt,St]),d((function(){return ke!==w?(!We&&!Oe||E.current)&&(E.current=!1,y(ke)):(Be&&Be(ke,w),($e||"forward"===He&&ke!==Pt||"backward"===He&&0!==ke)&&nn()),function(){clearTimeout(k.current)}}),[w,ke,Be,We,Oe,nn,$e,Pt,He]),d((function(){return h&&nn(),function(){clearTimeout(k.current)}}),[h]),d((function(){function e(){clearTimeout(C.current),clearTimeout(k.current),C.current=setTimeout((function(){h!==window.innerWidth&&p(window.innerWidth)}),400)}return h!==window.innerWidth&&p(window.innerWidth),window.addEventListener("resize",e),function(){clearTimeout(C.current),window.removeEventListener("resize",e)}}),[h]),M.current=0,W.current=w,e.createElement("div",l({style:l({display:"flex",flexFlow:"row wrap",boxSizing:"border-box",justifyContent:"center",width:"100%"},V)},j,{ref:x}),ne&&!Xt&&e.createElement("button",l({},ie,{type:"button",onClick:(0===Ut&&et||0===ke&&nt)&&!$e?void 0:rn,disabled:"boolean"==typeof ie.disabled?ie.disabled:!(!(0===Ut&&et||0===ke&&nt)||$e)}),ee),e.createElement("div",l({},q,{style:l(l({width:"100%"},D),{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:zt?"".concat(zt,"px"):void 0,flex:zt?void 0:"1 0 auto"}),ref:S}),e.createElement("div",l({},Y,{style:l(l({},K),{display:"flex",boxSizing:"border-box",outline:"none",transition:Nt,transform:Zt,touchAction:at?"none":"auto"}),onTransitionEnd:We||Oe?on:U,tabIndex:-1,role:"presentation",ref:g}),$e&&ln(O.slice(w),w,At),ln(O,0,At),$e&&ln(O,0,At),$e&&ln(O.slice(0,w),0,At))),se&&!Xt&&e.createElement("button",l({},ae,{type:"button",onClick:(Ut===Rt&&et||ke===Pt&&nt)&&!$e?void 0:dn,disabled:"boolean"==typeof ae.disabled?ae.disabled:!(!(Ut===Rt&&et||ke===Pt&&nt)||$e)}),le),!!Lt&&e.createElement("div",l({style:{width:"100%",display:"flex",justifyContent:"center"}},It),Array.from({length:Math.ceil(O.length/je)}).map((function(t,n){return e.createElement("button",l({type:"button",key:n,title:"".concat(n)},Ct,ke>=n*je&&ke<Math.min(je*(n+1),Pt+1)?Wt:{},{onClick:function(){tn(Math.min(n*je,O.length-1),Math.min(n*je,O.length-1)>ke?"forward":"backward")}}))}))))}));export{u as default};
import e,{memo as t,useState as n,useRef as i,Children as r,useCallback as o,useEffect as d}from"react";var l=function(){return l=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},l.apply(this,arguments)};function c(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),d=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)d.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return d}function a(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var u=t((function(t){var u,v,m=t.responsiveProps,f=void 0===m?[]:m,h=c(t,["responsiveProps"]),p=s(n(0),2),b=p[0],w=p[1],y=s(n(h.activeSlideIndex),2),x=y[0],S=y[1],E=i(null),g=i(null),L=i(null),T=i(!1),I=i(0),k=i(!1),C=i(""),W=i(null),M=i(null),P=i(0),O=i(x),X=f.reduce((function(e,t){void 0===t&&(t={});var n=t.minWidth,i=void 0===n?0:n,r=t.maxWidth,o=void 0===r?null:r,d=c(t,["minWidth","maxWidth"]);return b>i&&(!o||b<=o)?l(l({},e),d):e}),h),A=r.toArray(X.children),N=b?l(l({},X),{activeSlideIndex:Math.max(0,Math.min(X.activeSlideIndex,A.length-1)),itemsToShow:Math.min(A.length,X.itemsToShow||0),itemsToScroll:Math.min(A.length,X.itemsToScroll||1)}):h,F=N.containerProps,V=void 0===F?{}:F,j=V.style,z=void 0===j?{}:j,B=c(V,["style"]),R=N.innerProps,D=void 0===R?{}:R,q=D.style,H=void 0===q?{}:q,G=c(D,["style"]),J=N.itemsListProps,K=void 0===J?{}:J,Q=K.style,U=void 0===Q?{}:Q,Y=K.onTransitionEnd,Z=void 0===Y?void 0:Y,$=c(K,["style","onTransitionEnd"]),_=N.backwardBtnProps,ee=void 0===_?{}:_,te=ee.children,ne=void 0===te?null:te,ie=ee.show,re=void 0===ie||ie,oe=c(ee,["children","show"]),de=N.forwardBtnProps,le=void 0===de?{}:de,ce=le.children,se=void 0===ce?null:ce,ae=le.show,ue=void 0===ae||ae,ve=c(le,["children","show"]),me=N.activeSlideProps,fe=void 0===me?{}:me,he=fe.className,pe=void 0===he?"":he,be=fe.style,we=void 0===be?{}:be,ye=c(fe,["className","style"]),xe=N.visibleSlideProps,Se=void 0===xe?{}:xe,Ee=Se.className,ge=void 0===Ee?"":Ee,Le=Se.style,Te=void 0===Le?{}:Le,Ie=c(Se,["className","style"]),ke=N.updateOnItemClick,Ce=void 0!==ke&&ke,We=N.activeSlideIndex,Me=N.onRequestChange,Pe=N.speed,Oe=void 0===Pe?0:Pe,Xe=N.delay,Ae=void 0===Xe?0:Xe,Ne=N.easing,Fe=void 0===Ne?"linear":Ne,Ve=N.itemsToShow,je=void 0===Ve?0:Ve,ze=N.itemsToScroll,Be=void 0===ze?1:ze,Re=N.children,De=N.onAfterChange,qe=N.autoplay,He=void 0!==qe&&qe,Ge=N.autoplayDirection,Je=void 0===Ge?"forward":Ge,Ke=N.disableNavIfAllVisible,Qe=void 0===Ke||Ke,Ue=N.hideNavIfAllVisible,Ye=void 0===Ue||Ue,Ze=N.centerMode,$e=void 0!==Ze&&Ze,_e=N.infinite,et=void 0===_e||_e,tt=N.disableNavIfEdgeVisible,nt=void 0===tt||tt,it=N.disableNavIfEdgeActive,rt=void 0===it||it,ot=N.dotsNav,dt=void 0===ot?{}:ot,lt=N.persistentChangeCallbacks,ct=void 0!==lt&&lt,st=N.autoplayDelay,at=void 0===st?0:st,ut=N.preventScrollOnSwipe,vt=void 0!==ut&&ut,mt=N.disableSwipeByMouse,ft=void 0!==mt&&mt,ht=N.disableSwipeByTouch,pt=void 0!==ht&&ht,bt=N.touchSwipeTreshold,wt=N.mouseSwipeTreshold,yt=N.swipeTreshold,xt=N.touchSwipeRatio,St=N.mouseSwipeRatio,Et=N.swipeRatio,gt=void 0===Et?1:Et,Lt=dt||{},Tt=Lt.show,It=void 0!==Tt&&Tt,kt=Lt.containerProps,Ct=void 0===kt?{}:kt,Wt=Lt.itemBtnProps,Mt=void 0===Wt?{}:Wt,Pt=Lt.activeItemBtnProps,Ot=void 0===Pt?{}:Pt,Xt=r.count(Re)-1,At=!!b&&(null===(u=g.current)||void 0===u?void 0:u.offsetWidth)>=(null===(v=L.current)||void 0===v?void 0:v.offsetWidth),Nt=Ye&&At,Ft=Qe&&At,Vt=We-x==0||!Oe&&!Ae?"none":"transform ".concat(Oe,"ms ").concat(Fe," ").concat(Ae,"ms"),jt=o((function(e){var t,n=e.correctionSlideIndex,i=e.prevCorrectionSlideIndex,r=e.curActiveSlideIndex,o=L.current.offsetWidth,d=L.current.children,l=d.length,c=et?a([],s(d),!1).slice(l/3-i,l/3-i+l/3):a([],s(d),!1),u=null===(t=c[r])||void 0===t?void 0:t.offsetWidth,v=je?c.reduce((function(e,t,n){return n>=r&&n<r+je||n<r&&n<r+je-c.length?e+t.offsetWidth:e}),0):g.current.offsetWidth,m=Math.min(v,g.current.offsetWidth),f=o-m,h=$e&&et?-(m-u)/2:0,p=et?o/3:0,b=n-r==0?0:"forward"===C.current&&r<n?p:"backward"===C.current&&r>n?-p:0,w=r-n!=0,y=function(e){var t=c.reduce((function(t,n,i){return i>=e?t:t+(n.offsetWidth||0)}),0);return et?t:Math.min(f,t)},x=w&&et?y(n):0,S=w||!et?y(r):0,E=Ft?0:S-x+h+b+p,T="translateX(-".concat(E,"px)"),I=et?p+h:Math.min(f,c.reduce((function(e,t,n){return n<r?e+t.offsetWidth:e}),0)),k=I+m,W=c.map((function(e,t){return{slideIndex:t,htmlElement:e}})),M=et?a(a(a(a([],s(c.slice(r).map((function(e,t){return{slideIndex:t+r,htmlElement:e}}))),!1),s(W),!1),s(W),!1),s(c.slice(0,r).map((function(e,t){return{slideIndex:t,htmlElement:e}}))),!1):W,P=M.reduce((function(e,t){var n=t.slideIndex,i=t.htmlElement.offsetWidth;return(e.summ>=I&&e.summ<k||e.summ+i>I&&e.summ+i<=k)&&e.items.push({slideIndex:n,isFullyVisible:e.summ+i<=k&&e.summ>=I}),e.summ+=i,e}),{summ:0,items:[]}),O=!!P.items.find((function(e){return 0===e.slideIndex})),X=!!P.items.find((function(e){return e.slideIndex===c.length-1}));return{slidesHTMLElements:c,innerMaxWidth:v,itemsListMaxTranslateX:f,activeSlideWidth:u,offsetCorrectionForCenterMode:h,offsetCorrectionForInfiniteMode:p,itemsListTranslateX:E,itemsListTransform:T,visibleSlides:P.items,isFirstSlideVisible:O,isLastSlideVisible:X}}),[$e,Ft,et,je]),zt=b?jt({prevCorrectionSlideIndex:O.current,curActiveSlideIndex:We,correctionSlideIndex:x}):{},Bt=zt.innerMaxWidth,Rt=void 0===Bt?0:Bt,Dt=zt.itemsListMaxTranslateX,qt=void 0===Dt?0:Dt,Ht=zt.activeSlideWidth,Gt=void 0===Ht?0:Ht,Jt=zt.offsetCorrectionForCenterMode,Kt=void 0===Jt?0:Jt,Qt=zt.offsetCorrectionForInfiniteMode,Ut=void 0===Qt?0:Qt,Yt=zt.itemsListTranslateX,Zt=void 0===Yt?0:Yt,$t=zt.itemsListTransform,_t=void 0===$t?"none":$t,en=zt.visibleSlides,tn=void 0===en?[]:en,nn=o((function(e){var t;return"forward"===e?(t=We+Be)>Xt?et?t-Xt-1:Xt:t:"backward"===e?(t=We-Be)<0?et?Xt+1+t:0:t:We}),[We,Be,Xt,et]),rn=o((function(e,t){var n;if(C.current=t,L.current.style.transition=Oe||Ae?"transform ".concat(Oe,"ms ").concat(Fe," ").concat(Ae,"ms"):"none",e!==We||ct){clearTimeout(W.current);var i=jt({correctionSlideIndex:x,prevCorrectionSlideIndex:x,curActiveSlideIndex:e}),r=i.visibleSlides,o=i.isFirstSlideVisible,d=i.isLastSlideVisible,l=i.itemsListTransform;e!==We&&(null===(n=L.current)||void 0===n?void 0:n.style.transform)===l&&(T.current=!0),L.current.style.transform=l,Me(e,{visibleSlides:r,isFirstSlideVisible:o,isLastSlideVisible:d})}else L.current.style.transform="translateX(-".concat(Kt+Ut+(et?0:Zt),"px)")}),[ct,We,Kt,Ae,Fe,Oe,Me,Ut,et,Zt,x,jt]),on=o((function(){He&&(clearTimeout(W.current),W.current=setTimeout((function(){rn(nn(Je),Je)}),at||Ae))}),[He,Je,at,rn,nn,Ae]),dn=o((function(){rn(nn("backward"),"backward")}),[rn,nn]),ln=o((function(e){S(We),Z&&Z(e)}),[We,Z]),cn=o((function(){rn(nn("forward"),"forward")}),[rn,nn]),sn=function(e,t,n){return e.map((function(e,i){var r=e.props,o=void 0===r?{}:r,d=o.className,s=void 0===d?"":d,a=o.onClick,u=void 0===a?null:a,v=o.style,m=void 0===v?{}:v,f=c(o,["className","onClick","style"]),h=c(e,["props"]),p=et?P.current>=A.length?"forward":"backward":i>=We?"forward":"backward",b=i+t===We,w=tn.find((function(e){return e.slideIndex===i+t})),y="".concat(s," ").concat(b?pe:""," ").concat(w?ge:"").trim()||void 0,x=l(l(l(l({},m),w?Te:{}),b?we:{}),{boxSizing:"border-box",margin:0}),S=!n&&Ce?function(e){var t=e.direction,n=e.index,i=e.onClick;return function(e){rn(n,t||(We<n?"forward":"")||(We>n?"backward":"")),i&&i(e)}}({direction:p,index:i+t,onClick:u}):u,E=l(l(l({role:"tabpanel",className:y,style:x,onClick:S},f),w?Ie:{}),b?ye:{});return P.current+=1,l({props:E},h)}))};return d((function(){var e=L.current;function t(e){e.preventDefault(),e.stopPropagation()}function n(e){var t,n;k.current=!0;var i=!!(null===(t=e.touches)||void 0===t?void 0:t[0]),r=i?null===(n=e.touches)||void 0===n?void 0:n[0].clientX:e.clientX,o=(I.current-r)*((i?xt:St)||gt)+Kt+Ut+(et?0:Zt),d=L.current.offsetWidth,l=Math.max(-o,-d);L.current.style.transition="none",L.current.style.transform="translateX(".concat(l,"px)")}function i(e){var r,o,d;if(document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",i),k.current){null===(r=e.target)||void 0===r||r.addEventListener("click",t);var l=!!(null===(o=e.changedTouches)||void 0===o?void 0:o[0]),c=l?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,s=(I.current-c)*((l?xt:St)||gt),a=(l?bt:wt)||yt||Gt/2,u=s>a?{index:nn("forward"),direction:"forward"}:s<-a?{index:nn("backward"),direction:"backward"}:{index:We,direction:"forward"};rn(u.index,u.direction)}else null===(d=e.target)||void 0===d||d.removeEventListener("click",t);I.current=0,k.current=!1}function r(e){var t,r;clearTimeout(W.current);var o=!!(null===(t=e.touches)||void 0===t?void 0:t[0]);I.current=o?null===(r=e.touches)||void 0===r?void 0:r[0].clientX:e.clientX,o?(document.addEventListener("touchmove",n),document.addEventListener("touchend",i)):(document.addEventListener("mousemove",n),document.addEventListener("mouseup",i))}return Ft||(ft||null==e||e.addEventListener("mousedown",r),pt||null==e||e.addEventListener("touchstart",r,{passive:!0}),ft&&pt||null==e||e.addEventListener("dragstart",i)),function(){k.current=!1,I.current=0,null==e||e.removeEventListener("mousedown",r),null==e||e.removeEventListener("touchstart",r),null==e||e.removeEventListener("dragstart",i),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",i)}}),[et,Zt,_t,Kt,Ut,We,Gt,nn,rn,Ft,ft,pt,bt,wt,yt,xt,St,gt]),d((function(){return We!==x?(!Oe&&!Ae||T.current)&&(T.current=!1,S(We)):(De&&De(We,x),(et||"forward"===Je&&We!==Xt||"backward"===Je&&0!==We)&&on()),function(){clearTimeout(W.current)}}),[x,We,De,Oe,Ae,on,et,Xt,Je]),d((function(){return b&&on(),function(){clearTimeout(W.current)}}),[b]),d((function(){function e(){clearTimeout(M.current),clearTimeout(W.current),M.current=setTimeout((function(){b!==window.innerWidth&&w(window.innerWidth)}),400)}return b!==window.innerWidth&&w(window.innerWidth),window.addEventListener("resize",e),function(){clearTimeout(M.current),window.removeEventListener("resize",e)}}),[b]),P.current=0,O.current=x,e.createElement("div",l({style:l({display:"flex",flexFlow:"row wrap",boxSizing:"border-box",justifyContent:"center",width:"100%"},z)},B,{ref:E}),re&&!Nt&&e.createElement("button",l({},oe,{type:"button",onClick:(0===Zt&&nt||0===We&&rt)&&!et?void 0:dn,disabled:"boolean"==typeof oe.disabled?oe.disabled:!(!(0===Zt&&nt||0===We&&rt)||et)}),ne),e.createElement("div",l({},G,{style:l(l({width:"100%"},H),{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:Rt?"".concat(Rt,"px"):void 0,flex:Rt?void 0:"1 0 auto"}),ref:g}),e.createElement("div",l({},$,{style:l(l({},U),{display:"flex",boxSizing:"border-box",outline:"none",transition:Vt,transform:_t,touchAction:vt?"none":"auto"}),onTransitionEnd:Oe||Ae?ln:Z,tabIndex:-1,role:"presentation",ref:L}),et&&sn(A.slice(x),x,Ft),sn(A,0,Ft),et&&sn(A,0,Ft),et&&sn(A.slice(0,x),0,Ft))),ue&&!Nt&&e.createElement("button",l({},ve,{type:"button",onClick:(Zt===qt&&nt||We===Xt&&rt)&&!et?void 0:cn,disabled:"boolean"==typeof ve.disabled?ve.disabled:!(!(Zt===qt&&nt||We===Xt&&rt)||et)}),se),!!It&&e.createElement("div",l({style:{width:"100%",display:"flex",justifyContent:"center"}},Ct),Array.from({length:Math.ceil(A.length/Be)}).map((function(t,n){return e.createElement("button",l({type:"button",key:n,title:"".concat(n)},Mt,We>=n*Be&&We<Math.min(Be*(n+1),Xt+1)?Ot:{},{onClick:function(){rn(Math.min(n*Be,A.length-1),Math.min(n*Be,A.length-1)>We?"forward":"backward")}}))}))))}));export{u as default};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ReactSimplyCarousel=t(e.React)}(this,(function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},t.apply(this,arguments)};function n(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),d=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)d.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return d}function r(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}return e.memo((function(o){var d=o.responsiveProps,l=void 0===d?[]:d,s=n(o,["responsiveProps"]),c=i(e.useState(0),2),a=c[0],u=c[1],v=i(e.useState(s.activeSlideIndex),2),f=v[0],m=v[1],h=e.useRef(null),p=e.useRef(null),b=e.useRef(null),y=e.useRef(!1),w=e.useRef(0),x=e.useRef(!1),S=e.useRef(""),E=e.useRef(null),g=e.useRef(null),T=e.useRef(0),C=e.useRef(f),L=l.reduce((function(e,i){void 0===i&&(i={});var r=i.minWidth,o=void 0===r?0:r,d=i.maxWidth,l=void 0===d?null:d,s=n(i,["minWidth","maxWidth"]);return a>o&&(!l||a<=l)?t(t({},e),s):e}),s),k=e.Children.toArray(L.children),I=a?t(t({},L),{activeSlideIndex:Math.max(0,Math.min(L.activeSlideIndex,k.length-1)),itemsToShow:Math.min(k.length,L.itemsToShow||0),itemsToScroll:Math.min(k.length,L.itemsToScroll||1)}):s,M=I.containerProps,W=void 0===M?{}:M,P=W.style,R=void 0===P?{}:P,O=n(W,["style"]),X=I.innerProps,A=void 0===X?{}:X,N=A.style,F=void 0===N?{}:N,V=n(A,["style"]),j=I.itemsListProps,z=void 0===j?{}:j,B=z.style,D=void 0===B?{}:B,q=z.onTransitionEnd,H=void 0===q?void 0:q,G=n(z,["style","onTransitionEnd"]),J=I.backwardBtnProps,K=void 0===J?{}:J,Q=K.children,U=void 0===Q?null:Q,Y=K.show,Z=void 0===Y||Y,$=n(K,["children","show"]),_=I.forwardBtnProps,ee=void 0===_?{}:_,te=ee.children,ne=void 0===te?null:te,ie=ee.show,re=void 0===ie||ie,oe=n(ee,["children","show"]),de=I.activeSlideProps,le=void 0===de?{}:de,se=le.className,ce=void 0===se?"":se,ae=le.style,ue=void 0===ae?{}:ae,ve=n(le,["className","style"]),fe=I.visibleSlideProps,me=void 0===fe?{}:fe,he=me.className,pe=void 0===he?"":he,be=me.style,ye=void 0===be?{}:be,we=n(me,["className","style"]),xe=I.updateOnItemClick,Se=void 0!==xe&&xe,Ee=I.activeSlideIndex,ge=I.onRequestChange,Te=I.speed,Ce=void 0===Te?0:Te,Le=I.delay,ke=void 0===Le?0:Le,Ie=I.easing,Me=void 0===Ie?"linear":Ie,We=I.itemsToShow,Pe=void 0===We?0:We,Re=I.itemsToScroll,Oe=void 0===Re?1:Re,Xe=I.children,Ae=I.onAfterChange,Ne=I.autoplay,Fe=void 0!==Ne&&Ne,Ve=I.autoplayDirection,je=void 0===Ve?"forward":Ve,ze=I.disableNavIfAllVisible,Be=void 0===ze||ze,De=I.hideNavIfAllVisible,qe=void 0===De||De,He=I.centerMode,Ge=void 0!==He&&He,Je=I.infinite,Ke=void 0===Je||Je,Qe=I.disableNavIfEdgeVisible,Ue=void 0===Qe||Qe,Ye=I.disableNavIfEdgeActive,Ze=void 0===Ye||Ye,$e=I.dotsNav,_e=void 0===$e?{}:$e,et=I.persistentChangeCallbacks,tt=void 0!==et&&et,nt=I.autoplayDelay,it=void 0===nt?0:nt,rt=I.preventScrollOnSwipe,ot=void 0!==rt&&rt,dt=I.disableSwipeByMouse,lt=void 0!==dt&&dt,st=I.disableSwipeByTouch,ct=void 0!==st&&st,at=I.touchSwipeTreshold,ut=I.mouseSwipeTreshold,vt=I.swipeTreshold,ft=I.touchSwipeRatio,mt=I.mouseSwipeRatio,ht=I.swipeRatio,pt=void 0===ht?1:ht,bt=_e||{},yt=bt.show,wt=void 0!==yt&&yt,xt=bt.containerProps,St=void 0===xt?{}:xt,Et=bt.itemBtnProps,gt=void 0===Et?{}:Et,Tt=bt.activeItemBtnProps,Ct=void 0===Tt?{}:Tt,Lt=e.Children.count(Xe)-1,kt=Pe===k.length,It=qe&&kt,Mt=Be&&kt,Wt=Ee-f==0||!Ce&&!ke?"none":"transform ".concat(Ce,"ms ").concat(Me," ").concat(ke,"ms"),Pt=e.useCallback((function(e){var t,n=e.correctionSlideIndex,o=e.prevCorrectionSlideIndex,d=e.curActiveSlideIndex,l=b.current.offsetWidth,s=b.current.children,c=s.length,a=Ke?r([],i(s),!1).slice(c/3-o,c/3-o+c/3):r([],i(s),!1),u=null===(t=a[d])||void 0===t?void 0:t.offsetWidth,v=Pe?a.reduce((function(e,t,n){return n>=d&&n<d+Pe||n<d&&n<d+Pe-a.length?e+t.offsetWidth:e}),0):p.current.offsetWidth,f=Math.min(v,p.current.offsetWidth),m=l-f,h=Ge&&Ke?-(f-u)/2:0,y=Ke?l/3:0,w=n-d==0?0:"forward"===S.current&&d<n?y:"backward"===S.current&&d>n?-y:0,x=d-n!=0,E=function(e){var t=a.reduce((function(t,n,i){return i>=e?t:t+(n.offsetWidth||0)}),0);return Ke?t:Math.min(m,t)},g=x&&Ke?E(n):0,T=x||!Ke?E(d):0,C=Mt?0:T-g+h+w+y,L="translateX(-".concat(C,"px)"),k=Ke?y+h:Math.min(m,a.reduce((function(e,t,n){return n<d?e+t.offsetWidth:e}),0)),I=k+f,M=a.map((function(e,t){return{slideIndex:t,htmlElement:e}})),W=Ke?r(r(r(r([],i(a.slice(d).map((function(e,t){return{slideIndex:t+d,htmlElement:e}}))),!1),i(M),!1),i(M),!1),i(a.slice(0,d).map((function(e,t){return{slideIndex:t,htmlElement:e}}))),!1):M,P=W.reduce((function(e,t){var n=t.slideIndex,i=t.htmlElement.offsetWidth;return(e.summ>=k&&e.summ<I||e.summ+i>k&&e.summ+i<=I)&&e.items.push({slideIndex:n,isFullyVisible:e.summ+i<=I&&e.summ>=k}),e.summ+=i,e}),{summ:0,items:[]}),R=!!P.items.find((function(e){return 0===e.slideIndex})),O=!!P.items.find((function(e){return e.slideIndex===a.length-1}));return{slidesHTMLElements:a,innerMaxWidth:v,itemsListMaxTranslateX:m,activeSlideWidth:u,offsetCorrectionForCenterMode:h,offsetCorrectionForInfiniteMode:y,itemsListTranslateX:C,itemsListTransform:L,visibleSlides:P.items,isFirstSlideVisible:R,isLastSlideVisible:O}}),[Ge,Mt,Ke,Pe]),Rt=a?Pt({prevCorrectionSlideIndex:C.current,curActiveSlideIndex:Ee,correctionSlideIndex:f}):{},Ot=Rt.innerMaxWidth,Xt=void 0===Ot?0:Ot,At=Rt.itemsListMaxTranslateX,Nt=void 0===At?0:At,Ft=Rt.activeSlideWidth,Vt=void 0===Ft?0:Ft,jt=Rt.offsetCorrectionForCenterMode,zt=void 0===jt?0:jt,Bt=Rt.offsetCorrectionForInfiniteMode,Dt=void 0===Bt?0:Bt,qt=Rt.itemsListTranslateX,Ht=void 0===qt?0:qt,Gt=Rt.itemsListTransform,Jt=void 0===Gt?"none":Gt,Kt=Rt.visibleSlides,Qt=void 0===Kt?[]:Kt,Ut=e.useCallback((function(e){var t;return"forward"===e?(t=Ee+Oe)>Lt?Ke?t-Lt-1:Lt:t:"backward"===e?(t=Ee-Oe)<0?Ke?Lt+1+t:0:t:Ee}),[Ee,Oe,Lt,Ke]),Yt=e.useCallback((function(e,t){var n;if(S.current=t,b.current.style.transition=Ce||ke?"transform ".concat(Ce,"ms ").concat(Me," ").concat(ke,"ms"):"none",e!==Ee||tt){clearTimeout(E.current);var i=Pt({correctionSlideIndex:f,prevCorrectionSlideIndex:f,curActiveSlideIndex:e}),r=i.visibleSlides,o=i.isFirstSlideVisible,d=i.isLastSlideVisible,l=i.itemsListTransform;e!==Ee&&(null===(n=b.current)||void 0===n?void 0:n.style.transform)===l&&(y.current=!0),b.current.style.transform=l,ge(e,{visibleSlides:r,isFirstSlideVisible:o,isLastSlideVisible:d})}else b.current.style.transform="translateX(-".concat(zt+Dt+(Ke?0:Ht),"px)")}),[tt,Ee,zt,ke,Me,Ce,ge,Dt,Ke,Ht,f,Pt]),Zt=e.useCallback((function(){Fe&&(clearTimeout(E.current),E.current=setTimeout((function(){Yt(Ut(je),je)}),it||ke))}),[Fe,je,it,Yt,Ut,ke]),$t=e.useCallback((function(){Yt(Ut("backward"),"backward")}),[Yt,Ut]),_t=e.useCallback((function(e){m(Ee),H&&H(e)}),[Ee,H]),en=e.useCallback((function(){Yt(Ut("forward"),"forward")}),[Yt,Ut]),tn=function(e,i,r){return e.map((function(e,o){var d=e.props,l=void 0===d?{}:d,s=l.className,c=void 0===s?"":s,a=l.onClick,u=void 0===a?null:a,v=l.style,f=void 0===v?{}:v,m=n(l,["className","onClick","style"]),h=n(e,["props"]),p=Ke?T.current>=k.length?"forward":"backward":o>=Ee?"forward":"backward",b=o+i===Ee,y=Qt.find((function(e){return e.slideIndex===o+i})),w="".concat(c," ").concat(b?ce:""," ").concat(y?pe:"").trim()||void 0,x=t(t(t(t({},f),y?ye:{}),b?ue:{}),{boxSizing:"border-box",margin:0}),S=!r&&Se?function(e){var t=e.direction,n=e.index,i=e.onClick;return function(e){Yt(n,t||(Ee<n?"forward":"")||(Ee>n?"backward":"")),i&&i(e)}}({direction:p,index:o+i,onClick:u}):u,E=t(t(t({role:"tabpanel",className:w,style:x,onClick:S},m),y?we:{}),b?ve:{});return T.current+=1,t({props:E},h)}))};return e.useEffect((function(){var e=b.current;function t(e){e.preventDefault(),e.stopPropagation()}function n(e){var t,n;x.current=!0;var i=!!(null===(t=e.touches)||void 0===t?void 0:t[0]),r=i?null===(n=e.touches)||void 0===n?void 0:n[0].clientX:e.clientX,o=(w.current-r)*((i?ft:mt)||pt)+zt+Dt+(Ke?0:Ht),d=b.current.offsetWidth,l=Math.max(-o,-d);b.current.style.transition="none",b.current.style.transform="translateX(".concat(l,"px)")}function i(e){var r,o,d;if(document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",i),x.current){null===(r=e.target)||void 0===r||r.addEventListener("click",t);var l=!!(null===(o=e.changedTouches)||void 0===o?void 0:o[0]),s=l?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,c=(w.current-s)*((l?ft:mt)||pt),a=(l?at:ut)||vt||Vt/2,u=c>a?{index:Ut("forward"),direction:"forward"}:c<-a?{index:Ut("backward"),direction:"backward"}:{index:Ee,direction:"forward"};Yt(u.index,u.direction)}else null===(d=e.target)||void 0===d||d.removeEventListener("click",t);w.current=0,x.current=!1}function r(e){var t,r;clearTimeout(E.current);var o=!!(null===(t=e.touches)||void 0===t?void 0:t[0]);w.current=o?null===(r=e.touches)||void 0===r?void 0:r[0].clientX:e.clientX,o?(document.addEventListener("touchmove",n),document.addEventListener("touchend",i)):(document.addEventListener("mousemove",n),document.addEventListener("mouseup",i))}return Mt||(lt||null==e||e.addEventListener("mousedown",r),ct||null==e||e.addEventListener("touchstart",r,{passive:!0}),lt&&ct||null==e||e.addEventListener("dragstart",i)),function(){x.current=!1,w.current=0,null==e||e.removeEventListener("mousedown",r),null==e||e.removeEventListener("touchstart",r),null==e||e.removeEventListener("dragstart",i),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",i)}}),[Ke,Ht,Jt,zt,Dt,Ee,Vt,Ut,Yt,Mt,lt,ct,at,ut,vt,ft,mt,pt]),e.useEffect((function(){return Ee!==f?(!Ce&&!ke||y.current)&&(y.current=!1,m(Ee)):(Ae&&Ae(Ee,f),(Ke||"forward"===je&&Ee!==Lt||"backward"===je&&0!==Ee)&&Zt()),function(){clearTimeout(E.current)}}),[f,Ee,Ae,Ce,ke,Zt,Ke,Lt,je]),e.useEffect((function(){return a&&Zt(),function(){clearTimeout(E.current)}}),[a]),e.useEffect((function(){function e(){clearTimeout(g.current),clearTimeout(E.current),g.current=setTimeout((function(){a!==window.innerWidth&&u(window.innerWidth)}),400)}return a!==window.innerWidth&&u(window.innerWidth),window.addEventListener("resize",e),function(){clearTimeout(g.current),window.removeEventListener("resize",e)}}),[a]),T.current=0,C.current=f,e.createElement("div",t({style:t({display:"flex",flexFlow:"row wrap",boxSizing:"border-box",justifyContent:"center",width:"100%"},R)},O,{ref:h}),Z&&!It&&e.createElement("button",t({},$,{type:"button",onClick:(0===Ht&&Ue||0===Ee&&Ze)&&!Ke?void 0:$t,disabled:"boolean"==typeof $.disabled?$.disabled:!(!(0===Ht&&Ue||0===Ee&&Ze)||Ke)}),U),e.createElement("div",t({},V,{style:t(t({width:"100%"},F),{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:Xt?"".concat(Xt,"px"):void 0,flex:Xt?void 0:"1 0 auto"}),ref:p}),e.createElement("div",t({},G,{style:t(t({},D),{display:"flex",boxSizing:"border-box",outline:"none",transition:Wt,transform:Jt,touchAction:ot?"none":"auto"}),onTransitionEnd:Ce||ke?_t:H,tabIndex:-1,role:"presentation",ref:b}),Ke&&tn(k.slice(f),f,Mt),tn(k,0,Mt),Ke&&tn(k,0,Mt),Ke&&tn(k.slice(0,f),0,Mt))),re&&!It&&e.createElement("button",t({},oe,{type:"button",onClick:(Ht===Nt&&Ue||Ee===Lt&&Ze)&&!Ke?void 0:en,disabled:"boolean"==typeof oe.disabled?oe.disabled:!(!(Ht===Nt&&Ue||Ee===Lt&&Ze)||Ke)}),ne),!!wt&&e.createElement("div",t({style:{width:"100%",display:"flex",justifyContent:"center"}},St),Array.from({length:Math.ceil(k.length/Oe)}).map((function(n,i){return e.createElement("button",t({type:"button",key:i,title:"".concat(i)},gt,Ee>=i*Oe&&Ee<Math.min(Oe*(i+1),Lt+1)?Ct:{},{onClick:function(){Yt(Math.min(i*Oe,k.length-1),Math.min(i*Oe,k.length-1)>Ee?"forward":"backward")}}))}))))}))}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ReactSimplyCarousel=t(e.React)}(this,(function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},t.apply(this,arguments)};function n(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),d=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)d.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return d}function r(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}return e.memo((function(o){var d,l,s=o.responsiveProps,c=void 0===s?[]:s,a=n(o,["responsiveProps"]),u=i(e.useState(0),2),v=u[0],f=u[1],m=i(e.useState(a.activeSlideIndex),2),h=m[0],p=m[1],b=e.useRef(null),y=e.useRef(null),w=e.useRef(null),x=e.useRef(!1),S=e.useRef(0),E=e.useRef(!1),g=e.useRef(""),T=e.useRef(null),C=e.useRef(null),L=e.useRef(0),k=e.useRef(h),I=c.reduce((function(e,i){void 0===i&&(i={});var r=i.minWidth,o=void 0===r?0:r,d=i.maxWidth,l=void 0===d?null:d,s=n(i,["minWidth","maxWidth"]);return v>o&&(!l||v<=l)?t(t({},e),s):e}),a),W=e.Children.toArray(I.children),M=v?t(t({},I),{activeSlideIndex:Math.max(0,Math.min(I.activeSlideIndex,W.length-1)),itemsToShow:Math.min(W.length,I.itemsToShow||0),itemsToScroll:Math.min(W.length,I.itemsToScroll||1)}):a,P=M.containerProps,R=void 0===P?{}:P,O=R.style,X=void 0===O?{}:O,A=n(R,["style"]),N=M.innerProps,F=void 0===N?{}:N,V=F.style,j=void 0===V?{}:V,z=n(F,["style"]),B=M.itemsListProps,D=void 0===B?{}:B,q=D.style,H=void 0===q?{}:q,G=D.onTransitionEnd,J=void 0===G?void 0:G,K=n(D,["style","onTransitionEnd"]),Q=M.backwardBtnProps,U=void 0===Q?{}:Q,Y=U.children,Z=void 0===Y?null:Y,$=U.show,_=void 0===$||$,ee=n(U,["children","show"]),te=M.forwardBtnProps,ne=void 0===te?{}:te,ie=ne.children,re=void 0===ie?null:ie,oe=ne.show,de=void 0===oe||oe,le=n(ne,["children","show"]),se=M.activeSlideProps,ce=void 0===se?{}:se,ae=ce.className,ue=void 0===ae?"":ae,ve=ce.style,fe=void 0===ve?{}:ve,me=n(ce,["className","style"]),he=M.visibleSlideProps,pe=void 0===he?{}:he,be=pe.className,ye=void 0===be?"":be,we=pe.style,xe=void 0===we?{}:we,Se=n(pe,["className","style"]),Ee=M.updateOnItemClick,ge=void 0!==Ee&&Ee,Te=M.activeSlideIndex,Ce=M.onRequestChange,Le=M.speed,ke=void 0===Le?0:Le,Ie=M.delay,We=void 0===Ie?0:Ie,Me=M.easing,Pe=void 0===Me?"linear":Me,Re=M.itemsToShow,Oe=void 0===Re?0:Re,Xe=M.itemsToScroll,Ae=void 0===Xe?1:Xe,Ne=M.children,Fe=M.onAfterChange,Ve=M.autoplay,je=void 0!==Ve&&Ve,ze=M.autoplayDirection,Be=void 0===ze?"forward":ze,De=M.disableNavIfAllVisible,qe=void 0===De||De,He=M.hideNavIfAllVisible,Ge=void 0===He||He,Je=M.centerMode,Ke=void 0!==Je&&Je,Qe=M.infinite,Ue=void 0===Qe||Qe,Ye=M.disableNavIfEdgeVisible,Ze=void 0===Ye||Ye,$e=M.disableNavIfEdgeActive,_e=void 0===$e||$e,et=M.dotsNav,tt=void 0===et?{}:et,nt=M.persistentChangeCallbacks,it=void 0!==nt&&nt,rt=M.autoplayDelay,ot=void 0===rt?0:rt,dt=M.preventScrollOnSwipe,lt=void 0!==dt&&dt,st=M.disableSwipeByMouse,ct=void 0!==st&&st,at=M.disableSwipeByTouch,ut=void 0!==at&&at,vt=M.touchSwipeTreshold,ft=M.mouseSwipeTreshold,mt=M.swipeTreshold,ht=M.touchSwipeRatio,pt=M.mouseSwipeRatio,bt=M.swipeRatio,yt=void 0===bt?1:bt,wt=tt||{},xt=wt.show,St=void 0!==xt&&xt,Et=wt.containerProps,gt=void 0===Et?{}:Et,Tt=wt.itemBtnProps,Ct=void 0===Tt?{}:Tt,Lt=wt.activeItemBtnProps,kt=void 0===Lt?{}:Lt,It=e.Children.count(Ne)-1,Wt=!!v&&(null===(d=y.current)||void 0===d?void 0:d.offsetWidth)>=(null===(l=w.current)||void 0===l?void 0:l.offsetWidth),Mt=Ge&&Wt,Pt=qe&&Wt,Rt=Te-h==0||!ke&&!We?"none":"transform ".concat(ke,"ms ").concat(Pe," ").concat(We,"ms"),Ot=e.useCallback((function(e){var t,n=e.correctionSlideIndex,o=e.prevCorrectionSlideIndex,d=e.curActiveSlideIndex,l=w.current.offsetWidth,s=w.current.children,c=s.length,a=Ue?r([],i(s),!1).slice(c/3-o,c/3-o+c/3):r([],i(s),!1),u=null===(t=a[d])||void 0===t?void 0:t.offsetWidth,v=Oe?a.reduce((function(e,t,n){return n>=d&&n<d+Oe||n<d&&n<d+Oe-a.length?e+t.offsetWidth:e}),0):y.current.offsetWidth,f=Math.min(v,y.current.offsetWidth),m=l-f,h=Ke&&Ue?-(f-u)/2:0,p=Ue?l/3:0,b=n-d==0?0:"forward"===g.current&&d<n?p:"backward"===g.current&&d>n?-p:0,x=d-n!=0,S=function(e){var t=a.reduce((function(t,n,i){return i>=e?t:t+(n.offsetWidth||0)}),0);return Ue?t:Math.min(m,t)},E=x&&Ue?S(n):0,T=x||!Ue?S(d):0,C=Pt?0:T-E+h+b+p,L="translateX(-".concat(C,"px)"),k=Ue?p+h:Math.min(m,a.reduce((function(e,t,n){return n<d?e+t.offsetWidth:e}),0)),I=k+f,W=a.map((function(e,t){return{slideIndex:t,htmlElement:e}})),M=Ue?r(r(r(r([],i(a.slice(d).map((function(e,t){return{slideIndex:t+d,htmlElement:e}}))),!1),i(W),!1),i(W),!1),i(a.slice(0,d).map((function(e,t){return{slideIndex:t,htmlElement:e}}))),!1):W,P=M.reduce((function(e,t){var n=t.slideIndex,i=t.htmlElement.offsetWidth;return(e.summ>=k&&e.summ<I||e.summ+i>k&&e.summ+i<=I)&&e.items.push({slideIndex:n,isFullyVisible:e.summ+i<=I&&e.summ>=k}),e.summ+=i,e}),{summ:0,items:[]}),R=!!P.items.find((function(e){return 0===e.slideIndex})),O=!!P.items.find((function(e){return e.slideIndex===a.length-1}));return{slidesHTMLElements:a,innerMaxWidth:v,itemsListMaxTranslateX:m,activeSlideWidth:u,offsetCorrectionForCenterMode:h,offsetCorrectionForInfiniteMode:p,itemsListTranslateX:C,itemsListTransform:L,visibleSlides:P.items,isFirstSlideVisible:R,isLastSlideVisible:O}}),[Ke,Pt,Ue,Oe]),Xt=v?Ot({prevCorrectionSlideIndex:k.current,curActiveSlideIndex:Te,correctionSlideIndex:h}):{},At=Xt.innerMaxWidth,Nt=void 0===At?0:At,Ft=Xt.itemsListMaxTranslateX,Vt=void 0===Ft?0:Ft,jt=Xt.activeSlideWidth,zt=void 0===jt?0:jt,Bt=Xt.offsetCorrectionForCenterMode,Dt=void 0===Bt?0:Bt,qt=Xt.offsetCorrectionForInfiniteMode,Ht=void 0===qt?0:qt,Gt=Xt.itemsListTranslateX,Jt=void 0===Gt?0:Gt,Kt=Xt.itemsListTransform,Qt=void 0===Kt?"none":Kt,Ut=Xt.visibleSlides,Yt=void 0===Ut?[]:Ut,Zt=e.useCallback((function(e){var t;return"forward"===e?(t=Te+Ae)>It?Ue?t-It-1:It:t:"backward"===e?(t=Te-Ae)<0?Ue?It+1+t:0:t:Te}),[Te,Ae,It,Ue]),$t=e.useCallback((function(e,t){var n;if(g.current=t,w.current.style.transition=ke||We?"transform ".concat(ke,"ms ").concat(Pe," ").concat(We,"ms"):"none",e!==Te||it){clearTimeout(T.current);var i=Ot({correctionSlideIndex:h,prevCorrectionSlideIndex:h,curActiveSlideIndex:e}),r=i.visibleSlides,o=i.isFirstSlideVisible,d=i.isLastSlideVisible,l=i.itemsListTransform;e!==Te&&(null===(n=w.current)||void 0===n?void 0:n.style.transform)===l&&(x.current=!0),w.current.style.transform=l,Ce(e,{visibleSlides:r,isFirstSlideVisible:o,isLastSlideVisible:d})}else w.current.style.transform="translateX(-".concat(Dt+Ht+(Ue?0:Jt),"px)")}),[it,Te,Dt,We,Pe,ke,Ce,Ht,Ue,Jt,h,Ot]),_t=e.useCallback((function(){je&&(clearTimeout(T.current),T.current=setTimeout((function(){$t(Zt(Be),Be)}),ot||We))}),[je,Be,ot,$t,Zt,We]),en=e.useCallback((function(){$t(Zt("backward"),"backward")}),[$t,Zt]),tn=e.useCallback((function(e){p(Te),J&&J(e)}),[Te,J]),nn=e.useCallback((function(){$t(Zt("forward"),"forward")}),[$t,Zt]),rn=function(e,i,r){return e.map((function(e,o){var d=e.props,l=void 0===d?{}:d,s=l.className,c=void 0===s?"":s,a=l.onClick,u=void 0===a?null:a,v=l.style,f=void 0===v?{}:v,m=n(l,["className","onClick","style"]),h=n(e,["props"]),p=Ue?L.current>=W.length?"forward":"backward":o>=Te?"forward":"backward",b=o+i===Te,y=Yt.find((function(e){return e.slideIndex===o+i})),w="".concat(c," ").concat(b?ue:""," ").concat(y?ye:"").trim()||void 0,x=t(t(t(t({},f),y?xe:{}),b?fe:{}),{boxSizing:"border-box",margin:0}),S=!r&&ge?function(e){var t=e.direction,n=e.index,i=e.onClick;return function(e){$t(n,t||(Te<n?"forward":"")||(Te>n?"backward":"")),i&&i(e)}}({direction:p,index:o+i,onClick:u}):u,E=t(t(t({role:"tabpanel",className:w,style:x,onClick:S},m),y?Se:{}),b?me:{});return L.current+=1,t({props:E},h)}))};return e.useEffect((function(){var e=w.current;function t(e){e.preventDefault(),e.stopPropagation()}function n(e){var t,n;E.current=!0;var i=!!(null===(t=e.touches)||void 0===t?void 0:t[0]),r=i?null===(n=e.touches)||void 0===n?void 0:n[0].clientX:e.clientX,o=(S.current-r)*((i?ht:pt)||yt)+Dt+Ht+(Ue?0:Jt),d=w.current.offsetWidth,l=Math.max(-o,-d);w.current.style.transition="none",w.current.style.transform="translateX(".concat(l,"px)")}function i(e){var r,o,d;if(document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",i),E.current){null===(r=e.target)||void 0===r||r.addEventListener("click",t);var l=!!(null===(o=e.changedTouches)||void 0===o?void 0:o[0]),s=l?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,c=(S.current-s)*((l?ht:pt)||yt),a=(l?vt:ft)||mt||zt/2,u=c>a?{index:Zt("forward"),direction:"forward"}:c<-a?{index:Zt("backward"),direction:"backward"}:{index:Te,direction:"forward"};$t(u.index,u.direction)}else null===(d=e.target)||void 0===d||d.removeEventListener("click",t);S.current=0,E.current=!1}function r(e){var t,r;clearTimeout(T.current);var o=!!(null===(t=e.touches)||void 0===t?void 0:t[0]);S.current=o?null===(r=e.touches)||void 0===r?void 0:r[0].clientX:e.clientX,o?(document.addEventListener("touchmove",n),document.addEventListener("touchend",i)):(document.addEventListener("mousemove",n),document.addEventListener("mouseup",i))}return Pt||(ct||null==e||e.addEventListener("mousedown",r),ut||null==e||e.addEventListener("touchstart",r,{passive:!0}),ct&&ut||null==e||e.addEventListener("dragstart",i)),function(){E.current=!1,S.current=0,null==e||e.removeEventListener("mousedown",r),null==e||e.removeEventListener("touchstart",r),null==e||e.removeEventListener("dragstart",i),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",i)}}),[Ue,Jt,Qt,Dt,Ht,Te,zt,Zt,$t,Pt,ct,ut,vt,ft,mt,ht,pt,yt]),e.useEffect((function(){return Te!==h?(!ke&&!We||x.current)&&(x.current=!1,p(Te)):(Fe&&Fe(Te,h),(Ue||"forward"===Be&&Te!==It||"backward"===Be&&0!==Te)&&_t()),function(){clearTimeout(T.current)}}),[h,Te,Fe,ke,We,_t,Ue,It,Be]),e.useEffect((function(){return v&&_t(),function(){clearTimeout(T.current)}}),[v]),e.useEffect((function(){function e(){clearTimeout(C.current),clearTimeout(T.current),C.current=setTimeout((function(){v!==window.innerWidth&&f(window.innerWidth)}),400)}return v!==window.innerWidth&&f(window.innerWidth),window.addEventListener("resize",e),function(){clearTimeout(C.current),window.removeEventListener("resize",e)}}),[v]),L.current=0,k.current=h,e.createElement("div",t({style:t({display:"flex",flexFlow:"row wrap",boxSizing:"border-box",justifyContent:"center",width:"100%"},X)},A,{ref:b}),_&&!Mt&&e.createElement("button",t({},ee,{type:"button",onClick:(0===Jt&&Ze||0===Te&&_e)&&!Ue?void 0:en,disabled:"boolean"==typeof ee.disabled?ee.disabled:!(!(0===Jt&&Ze||0===Te&&_e)||Ue)}),Z),e.createElement("div",t({},z,{style:t(t({width:"100%"},j),{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:Nt?"".concat(Nt,"px"):void 0,flex:Nt?void 0:"1 0 auto"}),ref:y}),e.createElement("div",t({},K,{style:t(t({},H),{display:"flex",boxSizing:"border-box",outline:"none",transition:Rt,transform:Qt,touchAction:lt?"none":"auto"}),onTransitionEnd:ke||We?tn:J,tabIndex:-1,role:"presentation",ref:w}),Ue&&rn(W.slice(h),h,Pt),rn(W,0,Pt),Ue&&rn(W,0,Pt),Ue&&rn(W.slice(0,h),0,Pt))),de&&!Mt&&e.createElement("button",t({},le,{type:"button",onClick:(Jt===Vt&&Ze||Te===It&&_e)&&!Ue?void 0:nn,disabled:"boolean"==typeof le.disabled?le.disabled:!(!(Jt===Vt&&Ze||Te===It&&_e)||Ue)}),re),!!St&&e.createElement("div",t({style:{width:"100%",display:"flex",justifyContent:"center"}},gt),Array.from({length:Math.ceil(W.length/Ae)}).map((function(n,i){return e.createElement("button",t({type:"button",key:i,title:"".concat(i)},Ct,Te>=i*Ae&&Te<Math.min(Ae*(i+1),It+1)?kt:{},{onClick:function(){$t(Math.min(i*Ae,W.length-1),Math.min(i*Ae,W.length-1)>Te?"forward":"backward")}}))}))))}))}));
{
"name": "react-simply-carousel",
"version": "9.0.2",
"version": "9.0.3",
"description": "A simple, lightweight, fully controlled isomorphic (with SSR support) React.js carousel component. Touch enabled and responsive. With support for autoplay and infinity options. Fully customizable",

@@ -5,0 +5,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc