react-simply-carousel
Advanced tools
Comparing version 8.3.1 to 8.3.2
@@ -1,1 +0,1 @@ | ||
import e,{memo as t,useState as n,useRef as r,Children as i,useCallback as o,useEffect as c}from"react";function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(){return a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a.apply(this,arguments)}function s(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],c=!0,u=!1;try{for(n=n.call(e);!(c=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{c||null==n.return||n.return()}finally{if(u)throw i}}return o}(e,t)||v(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){if(e){if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(e,t):void 0}}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var p=["responsiveProps"],b=["minWidth","maxWidth"],y=["style","onClickCapture"],w=["style"],g=["style","onTouchStart","onMouseDown","onTransitionEnd"],x=["children","show"],S=["children","show"],O=["className","style"],E=["className","style"],I=["className","onClick","style"],C=["props"];function T(e){var t=e.infinite,n=e.indexOfFirstSlideInDOM,r=e.itemsListRef;return t?m(r.current.children).slice(r.current.children.length/3-n,r.current.children.length/3-n+r.current.children.length/3):m(r.current.children)}function L(e){var t=e.activeSlideIndex,n=e.itemsListRef,r=e.innerRef,i=e.offsetCorrectionForCenterMode,o=e.offsetCorrectionForInfiniteMode,c=e.infinite,u=e.indexOfFirstSlideInDOM,l=e.itemsToShow,d=T({infinite:c,indexOfFirstSlideInDOM:u,itemsListRef:n}),a=l?d.reduce((function(e,n,r){return r>=t&&r<t+l||r<t&&r<t+l-d.length?e+n.offsetWidth:e}),0):r.current.offsetWidth,s=c?o+i:Math.min(n.current.offsetWidth-a,d.reduce((function(e,n,r){return r<t?e+n.offsetWidth:e}),0)),f=s+a,v=c?[].concat(m(d.slice(t).map((function(e,n){return{slideIndex:n+t,htmlElement:e}}))),m(d.map((function(e,t){return{slideIndex:t,htmlElement:e}}))),m(d.map((function(e,t){return{slideIndex:t,htmlElement:e}}))),m(d.slice(0,t).map((function(e,t){return{slideIndex:t,htmlElement:e}})))):d.map((function(e,t){return{slideIndex:t,htmlElement:e}})),h=v.reduce((function(e,t){var n=t.slideIndex,r=t.htmlElement.offsetWidth;return(e.summ>=s&&e.summ<f||e.summ+r>s&&e.summ+r<=f)&&e.items.push({slideIndex:n,isFullyVisible:e.summ+r<=f&&e.summ>=s}),e.summ+=r,e}),{summ:0,items:[]}),p=!!h.items.find((function(e){return 0===e.slideIndex})),b=!!h.items.find((function(e){return e.slideIndex===d.length-1}));return{visibleSlides:h.items,isFirstSlideVisible:p,isLastSlideVisible:b}}function M(t){var u=t.responsiveProps,d=void 0===u?[]:u,m=s(t,p),v=f(n(0),2),h=v[0],M=v[1],k=f(n(m.activeSlideIndex),2),P=k[0],j=k[1],W=r(null),F=r(null),A=r(null),D=r(0),N=r(!1),R=r(""),X=r(null),V=r(null),z=r(0),B=r(P),q=d.reduce((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minWidth,r=void 0===n?0:n,i=t.maxWidth,o=void 0===i?null:i,c=s(t,b);return h>r&&(!o||h<=o)?l(l({},e),c):e}),m),U=i.toArray(q.children),$=h?l(l({},q),{},{activeSlideIndex:Math.max(0,Math.min(q.activeSlideIndex,U.length-1)),itemsToShow:Math.min(U.length,q.itemsToShow||0),itemsToScroll:Math.min(U.length,q.itemsToScroll||1)}):m,G=$.containerProps,H=(G=void 0===G?{}:G).style,J=void 0===H?{}:H,K=G.onClickCapture,Q=void 0===K?null:K,Y=s(G,y),Z=$.innerProps,_=(Z=void 0===Z?{}:Z).style,ee=void 0===_?{}:_,te=s(Z,w),ne=$.itemsListProps,re=(ne=void 0===ne?{}:ne).style,ie=void 0===re?{}:re,oe=ne.onTouchStart,ce=void 0===oe?null:oe,ue=ne.onMouseDown,le=void 0===ue?null:ue,de=ne.onTransitionEnd,ae=void 0===de?null:de,se=s(ne,g),fe=$.backwardBtnProps,me=(fe=void 0===fe?{}:fe).children,ve=void 0===me?null:me,he=fe.show,pe=void 0===he||he,be=s(fe,x),ye=$.forwardBtnProps,we=(ye=void 0===ye?{}:ye).children,ge=void 0===we?null:we,xe=ye.show,Se=void 0===xe||xe,Oe=s(ye,S),Ee=$.activeSlideProps,Ie=(Ee=void 0===Ee?{}:Ee).className,Ce=void 0===Ie?"":Ie,Te=Ee.style,Le=void 0===Te?{}:Te,Me=s(Ee,O),ke=$.visibleSlideProps,Pe=(ke=void 0===ke?{}:ke).className,je=void 0===Pe?"":Pe,We=ke.style,Fe=void 0===We?{}:We,Ae=s(ke,E),De=$.updateOnItemClick,Ne=void 0!==De&&De,Re=$.activeSlideIndex,Xe=$.onRequestChange,Ve=$.speed,ze=void 0===Ve?0:Ve,Be=$.delay,qe=void 0===Be?0:Be,Ue=$.easing,$e=void 0===Ue?"linear":Ue,Ge=$.itemsToShow,He=void 0===Ge?0:Ge,Je=$.itemsToScroll,Ke=void 0===Je?1:Je,Qe=$.children,Ye=$.onAfterChange,Ze=$.autoplay,_e=void 0!==Ze&&Ze,et=$.autoplayDirection,tt=void 0===et?"forward":et,nt=$.disableNavIfAllVisible,rt=void 0===nt||nt,it=$.hideNavIfAllVisible,ot=void 0===it||it,ct=$.centerMode,ut=void 0!==ct&&ct,lt=$.infinite,dt=void 0===lt||lt,at=$.disableNavIfEdgeVisible,st=void 0===at||at,ft=$.disableNavIfEdgeActive,mt=void 0===ft||ft,vt=$.dotsNav,ht=void 0===vt?{}:vt,pt=$.persistentChangeCallbacks,bt=void 0!==pt&&pt,yt=ht||{},wt=yt.show,gt=void 0!==wt&&wt,xt=yt.containerProps,St=void 0===xt?{}:xt,Ot=yt.itemBtnProps,Et=void 0===Ot?{}:Ot,It=yt.activeItemBtnProps,Ct=void 0===It?{}:It,Tt=h?T({infinite:dt,indexOfFirstSlideInDOM:B.current,itemsListRef:A}):[],Lt=h&&He?Tt.reduce((function(e,t,n){return n>=Re&&n<Re+He||n<Re&&n<Re+He-Tt.length?e+t.offsetWidth:e}),0):0,Mt=h?A.current.offsetWidth-(Lt||F.current.offsetWidth):0,kt=function(e){var t=Tt.reduce((function(t,n,r){return r>=e?t:t+(n.offsetWidth||0)}),0);return dt?t:Math.min(Mt,t)},Pt=i.count(Qe)-1,jt=He===U.length,Wt=ot&&jt,Ft=rt&&jt,At=Re-P!=0,Dt=h&&At&&dt?kt(P):0,Nt=!h||!At&&dt?0:kt(Re),Rt=h?Tt[Re].offsetWidth:0,Xt=h&&(ut&&dt)?-((Lt||F.current.offsetWidth)-Rt)/2:0,Vt=dt&&h?A.current.offsetWidth/3:0,zt=P-Re!=0&&A.current?"forward"===R.current.toLowerCase()&&Re<P?Vt:"backward"===R.current.toLowerCase()&&Re>P?-Vt:0:0,Bt=At&&(ze||qe)?"transform ".concat(ze,"ms ").concat($e," ").concat(qe,"ms"):"none",qt=Ft||!h?0:Nt-Dt+Xt+zt+Vt,Ut=h?"translateX(-".concat(qt,"px)"):"none",$t=h?L({activeSlideIndex:Re,itemsListRef:A,innerRef:F,offsetCorrectionForCenterMode:Xt,infinite:dt,indexOfFirstSlideInDOM:B.current,offsetCorrectionForInfiniteMode:Vt,itemsToShow:He}):{visibleSlides:[],isFirstSlideVisible:!1,isLastSlideVisible:!1},Gt=o((function(e){if("forward"===e){var t=Re+Ke;return t>Pt?dt?t-Pt-1:Re:t}if("backward"===e){var n=Re-Ke;return n<0?dt?Pt+1+n:Re:n}return Re}),[Re,Ke,Pt,dt]),Ht=o((function(e,t){R.current=t,A.current.style.transition=ze||qe?"transform ".concat(ze,"ms ").concat($e," ").concat(qe,"ms"):"none",e!==Re||bt?(clearTimeout(X.current),Xe(e,L({activeSlideIndex:e,indexOfFirstSlideInDOM:P,infinite:dt,innerRef:F,itemsListRef:A,offsetCorrectionForCenterMode:Xt,offsetCorrectionForInfiniteMode:Vt,itemsToShow:He}))):(D.current=0,A.current.style.transform="translateX(-".concat(Xt+Vt+(dt?0:qt),"px)"))}),[bt,Re,Xt,qe,$e,ze,Xe,Vt,dt,qt,P,He]),Jt=o((function(){_e&&(clearTimeout(X.current),X.current=setTimeout((function(){Ht(Gt(tt),tt)}),qe))}),[_e,tt,Ht,Gt,qe]),Kt=o((function(e){N.current&&(e.preventDefault(),e.stopPropagation(),Q&&Q(e))}),[Q]),Qt=o((function(){Ht(Gt("backward"),"backward")}),[Ht,Gt]),Yt=o((function(e){N.current=!0;var t=e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX,n=D.current-t+Xt+Vt+(dt?0:qt),r=A.current.offsetWidth-F.current.offsetWidth,i=Math.max(Math.min(0,-n),-r);A.current.style.transition="none",A.current.style.transform="translateX(".concat(i,"px)")}),[Xt,Vt,dt,qt]),Zt=o((function(e){if(A.current.removeEventListener("mouseout",Zt),A.current.removeEventListener("dragstart",Zt),document.removeEventListener("mousemove",Yt),document.removeEventListener("mouseup",Zt),document.removeEventListener("touchmove",Yt),document.removeEventListener("touchend",Zt),N.current){var t=e.changedTouches&&e.changedTouches.length?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,n=D.current-t;n>Rt/2?Ht(Gt("forward"),"forward"):n<-Rt/2?Ht(Gt("backward"),"backward"):Ht(Re,"forward")}}),[Re,Rt,Ht,Gt,Yt]),_t=o((function(e){clearTimeout(X.current),N.current||(D.current=e.clientX,document.addEventListener("mousemove",Yt),document.addEventListener("mouseup",Zt),A.current.addEventListener("mouseout",Zt),A.current.addEventListener("dragstart",Zt)),le&&le(e)}),[Yt,Zt,le]),en=o((function(e){clearTimeout(X.current),N.current||(D.current=e.touches[0].clientX,document.addEventListener("touchmove",Yt),document.addEventListener("touchend",Zt)),ce&&ce(e)}),[Yt,Zt,ce]),tn=o((function(e){j(Re),ae&&ae(e)}),[Re,ae]),nn=o((function(){Ht(Gt("forward"),"forward")}),[Ht,Gt]),rn=function(e,t,n){return e.map((function(e,r){var i=e.props,o=(i=void 0===i?{}:i).className,c=void 0===o?"":o,u=i.onClick,d=void 0===u?null:u,a=i.style,f=void 0===a?{}:a,m=s(i,I),v=s(e,C),h=dt?z.current>=U.length?"forward":"backward":r>=Re?"forward":"backward",p=r+t===Re,b=$t.visibleSlides.find((function(e){return e.slideIndex===r+t})),y="".concat(c," ").concat(h," ").concat(p?Ce:""," ").concat(b?je:""),w=l(l(l(l({},f),b?Fe:{}),p?Le:{}),{},{boxSizing:"border-box",margin:0}),g=!n&&Ne?function(e){var t=e.direction,n=e.index,r=e.onClick;return function(e){Ht(n,t||(Re<n?"forward":"")||(Re>n?"backward":"")),r&&r(e)}}({direction:h,index:r+t,onClick:d}):d,x=l(l(l({role:"tabpanel",className:y,style:w,onClick:g},m),b?Ae:{}),p?Me:{});return z.current+=1,l({props:x},v)}))};return c((function(){return D.current=0,P===Re&&(N.current=!1),R.current="",Re!==P?ze||qe||j(Re):(Ye&&Ye(Re,P),(dt||"forward"===tt&&Re!==Pt||"backward"===tt&&0!==Re)&&Jt()),function(){clearTimeout(X.current)}}),[P,Re,Ye,ze,qe,Jt,dt,Pt,tt]),c((function(){return h&&Jt(),function(){clearTimeout(X.current)}}),[h]),c((function(){var e=A.current;function t(){clearTimeout(V.current),clearTimeout(X.current),V.current=setTimeout((function(){h!==window.innerWidth&&M(window.innerWidth)}),400)}return h!==window.innerWidth&&M(window.innerWidth),window.addEventListener("resize",t),function(){clearTimeout(V.current),window.removeEventListener("resize",t),document.removeEventListener("mousemove",Yt),document.removeEventListener("mouseup",Zt),document.removeEventListener("touchmove",Yt),document.removeEventListener("touchend",Zt),e.removeEventListener("mouseout",Zt),e.removeEventListener("dragstart",Zt)}}),[Yt,Zt]),z.current=0,B.current=P,e.createElement("div",a({onClickCapture:Kt,style:l({display:"flex",flexFlow:"row wrap",boxSizing:"border-box",justifyContent:"center",width:"100%"},J)},Y,{ref:W}),pe&&!Wt&&e.createElement("button",a({},be,{type:"button",onClick:(0===qt&&st||0===Re&&mt)&&!dt?void 0:Qt,disabled:"boolean"==typeof be.disabled?be.disabled:!(!(0===qt&&st||0===Re&&mt)||dt)}),ve),e.createElement("div",a({},te,{style:l(l({},ee),{},{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:Lt?"".concat(Lt,"px"):void 0,flex:Lt?void 0:"1 0"}),ref:F}),e.createElement("div",a({},se,{style:l(l({},ie),{},{display:"flex",boxSizing:"border-box",outline:"none",transition:Bt,transform:Ut}),onTouchStart:Ft?void 0:en,onMouseDown:Ft?void 0:_t,onTransitionEnd:ze||qe?tn:void 0,tabIndex:-1,role:"presentation",ref:A}),dt&&rn(U.slice(P),P,Ft),rn(U,0,Ft),dt&&rn(U,0,Ft),dt&&rn(U.slice(0,P),0,Ft))),Se&&!Wt&&e.createElement("button",a({},Oe,{type:"button",onClick:(qt===Mt&&st||Re===Pt&&mt)&&!dt?void 0:nn,disabled:"boolean"==typeof Oe.disabled?Oe.disabled:!(!(qt===Mt&&st||Re===Pt&&mt)||dt)}),ge),!!gt&&e.createElement("div",a({style:{width:"100%",display:"flex",justifyContent:"center"}},St),Array.from({length:Math.ceil(U.length/Ke)}).map((function(t,n){return e.createElement("button",a({type:"button",key:n,title:"".concat(n)},Et,Math.min(n*Ke,U.length-1)===Re?Ct:{},{onClick:function(){Ht(Math.min(n*Ke,U.length-1),Math.min(n*Ke,U.length-1)>Re?"forward":"backward")}}))}))))}var k=t(M);export{k as default}; | ||
import e,{memo as t,useState as n,useRef as r,Children as i,useCallback as o,useEffect as c}from"react";function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function u(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],c=!0,d=!1;try{for(n=n.call(e);!(c=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);c=!0);}catch(e){d=!0,i=e}finally{try{c||null==n.return||n.return()}finally{if(d)throw i}}return o}(e,t)||v(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){if(e){if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(e,t):void 0}}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var b=["responsiveProps"],p=["minWidth","maxWidth"],y=["style","onClickCapture"],w=["style"],x=["style","onTouchStart","onMouseDown","onTransitionEnd"],g=["children","show"],S=["children","show"],E=["className","style"],T=["className","style"],I=["className","onClick","style"],O=["props"];function M(e){var t=e.infinite,n=e.correctionSlideIndex,r=e.prevCorrectionSlideIndex,i=e.itemsListDOMElement,o=e.curActiveSlideIndex,c=e.itemsToShow,d=e.innerDOMElement,l=e.centerMode,a=e.direction,s=e.disableNav,u=t?f(i.children).slice(i.children.length/3-r,i.children.length/3-r+i.children.length/3):f(i.children),m=u[o].offsetWidth,v=c?u.reduce((function(e,t,n){return n>=o&&n<o+c||n<o&&n<o+c-u.length?e+t.offsetWidth:e}),0):d.offsetWidth,h=i.offsetWidth-v,b=l&&t?-(v-m)/2:0,p=t?i.offsetWidth/3:0,y=n-o==0?0:"forward"===a&&o<n?p:"backward"===a&&o>n?-p:0,w=o-n!=0,x=function(e){var n=u.reduce((function(t,n,r){return r>=e?t:t+(n.offsetWidth||0)}),0);return t?n:Math.min(h,n)},g=w&&t?x(n):0,S=w||!t?x(o):0,E=s?0:S-g+b+y+p,T="translateX(-".concat(E,"px)"),I=t?p+b:Math.min(i.offsetWidth-v,u.reduce((function(e,t,n){return n<o?e+t.offsetWidth:e}),0)),O=I+v,M=t?[].concat(f(u.slice(o).map((function(e,t){return{slideIndex:t+o,htmlElement:e}}))),f(u.map((function(e,t){return{slideIndex:t,htmlElement:e}}))),f(u.map((function(e,t){return{slideIndex:t,htmlElement:e}}))),f(u.slice(0,o).map((function(e,t){return{slideIndex:t,htmlElement:e}})))):u.map((function(e,t){return{slideIndex:t,htmlElement:e}})),L=M.reduce((function(e,t){var n=t.slideIndex,r=t.htmlElement.offsetWidth;return(e.summ>=I&&e.summ<O||e.summ+r>I&&e.summ+r<=O)&&e.items.push({slideIndex:n,isFullyVisible:e.summ+r<=O&&e.summ>=I}),e.summ+=r,e}),{summ:0,items:[]}),C=!!L.items.find((function(e){return 0===e.slideIndex})),k=!!L.items.find((function(e){return e.slideIndex===u.length-1}));return{slidesHTMLElements:u,innerMaxWidth:v,itemsListMaxTranslateX:h,activeSlideWidth:m,offsetCorrectionForCenterMode:b,offsetCorrectionForInfiniteMode:p,itemsListTranslateX:E,itemsListTransform:T,visibleSlides:L.items,isFirstSlideVisible:C,isLastSlideVisible:k}}function L(t){var d=t.responsiveProps,a=void 0===d?[]:d,f=u(t,b),v=m(n(0),2),h=v[0],L=v[1],C=m(n(f.activeSlideIndex),2),k=C[0],P=C[1],j=r(null),W=r(null),A=r(null),D=r(0),N=r(!1),X=r(""),F=r(null),V=r(null),z=r(0),B=r(k),q=a.reduce((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minWidth,r=void 0===n?0:n,i=t.maxWidth,o=void 0===i?null:i,c=u(t,p);return h>r&&(!o||h<=o)?l(l({},e),c):e}),f),H=i.toArray(q.children),R=h?l(l({},q),{},{activeSlideIndex:Math.max(0,Math.min(q.activeSlideIndex,H.length-1)),itemsToShow:Math.min(H.length,q.itemsToShow||0),itemsToScroll:Math.min(H.length,q.itemsToScroll||1)}):f,U=R.containerProps,$=(U=void 0===U?{}:U).style,G=void 0===$?{}:$,J=U.onClickCapture,K=void 0===J?null:J,Q=u(U,y),Y=R.innerProps,Z=(Y=void 0===Y?{}:Y).style,_=void 0===Z?{}:Z,ee=u(Y,w),te=R.itemsListProps,ne=(te=void 0===te?{}:te).style,re=void 0===ne?{}:ne,ie=te.onTouchStart,oe=void 0===ie?null:ie,ce=te.onMouseDown,de=void 0===ce?null:ce,le=te.onTransitionEnd,ae=void 0===le?null:le,se=u(te,x),ue=R.backwardBtnProps,me=(ue=void 0===ue?{}:ue).children,fe=void 0===me?null:me,ve=ue.show,he=void 0===ve||ve,be=u(ue,g),pe=R.forwardBtnProps,ye=(pe=void 0===pe?{}:pe).children,we=void 0===ye?null:ye,xe=pe.show,ge=void 0===xe||xe,Se=u(pe,S),Ee=R.activeSlideProps,Te=(Ee=void 0===Ee?{}:Ee).className,Ie=void 0===Te?"":Te,Oe=Ee.style,Me=void 0===Oe?{}:Oe,Le=u(Ee,E),Ce=R.visibleSlideProps,ke=(Ce=void 0===Ce?{}:Ce).className,Pe=void 0===ke?"":ke,je=Ce.style,We=void 0===je?{}:je,Ae=u(Ce,T),De=R.updateOnItemClick,Ne=void 0!==De&&De,Xe=R.activeSlideIndex,Fe=R.onRequestChange,Ve=R.speed,ze=void 0===Ve?0:Ve,Be=R.delay,qe=void 0===Be?0:Be,He=R.easing,Re=void 0===He?"linear":He,Ue=R.itemsToShow,$e=void 0===Ue?0:Ue,Ge=R.itemsToScroll,Je=void 0===Ge?1:Ge,Ke=R.children,Qe=R.onAfterChange,Ye=R.autoplay,Ze=void 0!==Ye&&Ye,_e=R.autoplayDirection,et=void 0===_e?"forward":_e,tt=R.disableNavIfAllVisible,nt=void 0===tt||tt,rt=R.hideNavIfAllVisible,it=void 0===rt||rt,ot=R.centerMode,ct=void 0!==ot&&ot,dt=R.infinite,lt=void 0===dt||dt,at=R.disableNavIfEdgeVisible,st=void 0===at||at,ut=R.disableNavIfEdgeActive,mt=void 0===ut||ut,ft=R.dotsNav,vt=void 0===ft?{}:ft,ht=R.persistentChangeCallbacks,bt=void 0!==ht&&ht,pt=vt||{},yt=pt.show,wt=void 0!==yt&&yt,xt=pt.containerProps,gt=void 0===xt?{}:xt,St=pt.itemBtnProps,Et=void 0===St?{}:St,Tt=pt.activeItemBtnProps,It=void 0===Tt?{}:Tt,Ot=i.count(Ke)-1,Mt=$e===H.length,Lt=it&&Mt,Ct=nt&&Mt,kt=Xe-k==0||!ze&&!qe?"none":"transform ".concat(ze,"ms ").concat(Re," ").concat(qe,"ms"),Pt=h?M({infinite:lt,itemsListDOMElement:A.current,prevCorrectionSlideIndex:B.current,itemsToShow:$e,curActiveSlideIndex:Xe,innerDOMElement:W.current,centerMode:ct,correctionSlideIndex:k,direction:X.current,disableNav:Ct}):{},jt=Pt.innerMaxWidth,Wt=void 0===jt?0:jt,At=Pt.itemsListMaxTranslateX,Dt=void 0===At?0:At,Nt=Pt.activeSlideWidth,Xt=void 0===Nt?0:Nt,Ft=Pt.offsetCorrectionForCenterMode,Vt=void 0===Ft?0:Ft,zt=Pt.offsetCorrectionForInfiniteMode,Bt=void 0===zt?0:zt,qt=Pt.itemsListTranslateX,Ht=void 0===qt?0:qt,Rt=Pt.itemsListTransform,Ut=void 0===Rt?"none":Rt,$t=Pt.visibleSlides,Gt=void 0===$t?[]:$t,Jt=o((function(e){if("forward"===e){var t=Xe+Je;return t>Ot?lt?t-Ot-1:Xe:t}if("backward"===e){var n=Xe-Je;return n<0?lt?Ot+1+n:Xe:n}return Xe}),[Xe,Je,Ot,lt]),Kt=o((function(e,t){if(X.current=t,A.current.style.transition=ze||qe?"transform ".concat(ze,"ms ").concat(Re," ").concat(qe,"ms"):"none",e!==Xe||bt){clearTimeout(F.current);var n=M({infinite:lt,correctionSlideIndex:k,prevCorrectionSlideIndex:k,curActiveSlideIndex:e,itemsToShow:$e,itemsListDOMElement:A.current,innerDOMElement:W.current,centerMode:ct,disableNav:Ct,direction:X.current}),r=n.visibleSlides,i=n.isFirstSlideVisible,o=n.isLastSlideVisible;Fe(e,{visibleSlides:r,isFirstSlideVisible:i,isLastSlideVisible:o})}else D.current=0,A.current.style.transform="translateX(-".concat(Vt+Bt+(lt?0:Ht),"px)")}),[bt,Xe,Vt,qe,Re,ze,Fe,Bt,lt,Ht,k,$e,ct,Ct]),Qt=o((function(){Ze&&(clearTimeout(F.current),F.current=setTimeout((function(){Kt(Jt(et),et)}),qe))}),[Ze,et,Kt,Jt,qe]),Yt=o((function(e){N.current&&(e.preventDefault(),e.stopPropagation(),K&&K(e))}),[K]),Zt=o((function(){Kt(Jt("backward"),"backward")}),[Kt,Jt]),_t=o((function(e){N.current=!0;var t=e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX,n=D.current-t+Vt+Bt+(lt?0:Ht),r=A.current.offsetWidth-W.current.offsetWidth,i=Math.max(Math.min(0,-n),-r);A.current.style.transition="none",A.current.style.transform="translateX(".concat(i,"px)")}),[Vt,Bt,lt,Ht]),en=o((function(e){if(A.current.removeEventListener("mouseout",en),A.current.removeEventListener("dragstart",en),document.removeEventListener("mousemove",_t),document.removeEventListener("mouseup",en),document.removeEventListener("touchmove",_t),document.removeEventListener("touchend",en),N.current){var t=e.changedTouches&&e.changedTouches.length?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,n=D.current-t,r=n>Xt/2?{index:Jt("forward"),direction:"forward"}:n<-Xt/2?{index:Jt("backward"),direction:"backward"}:{index:Xe,direction:"forward"};r.index===Xe&&(N.current=!1),Kt(r.index,r.direction)}}),[Xe,Xt,Kt,Jt,_t]),tn=o((function(e){clearTimeout(F.current),N.current||(D.current=e.clientX,document.addEventListener("mousemove",_t),document.addEventListener("mouseup",en),A.current.addEventListener("mouseout",en),A.current.addEventListener("dragstart",en)),de&&de(e)}),[_t,en,de]),nn=o((function(e){clearTimeout(F.current),N.current||(D.current=e.touches[0].clientX,document.addEventListener("touchmove",_t),document.addEventListener("touchend",en)),oe&&oe(e)}),[_t,en,oe]),rn=o((function(e){P(Xe),ae&&ae(e)}),[Xe,ae]),on=o((function(){Kt(Jt("forward"),"forward")}),[Kt,Jt]),cn=function(e,t,n){return e.map((function(e,r){var i=e.props,o=(i=void 0===i?{}:i).className,c=void 0===o?"":o,d=i.onClick,a=void 0===d?null:d,s=i.style,m=void 0===s?{}:s,f=u(i,I),v=u(e,O),h=lt?z.current>=H.length?"forward":"backward":r>=Xe?"forward":"backward",b=r+t===Xe,p=Gt.find((function(e){return e.slideIndex===r+t})),y="".concat(c," ").concat(h," ").concat(b?Ie:""," ").concat(p?Pe:""),w=l(l(l(l({},m),p?We:{}),b?Me:{}),{},{boxSizing:"border-box",margin:0}),x=!n&&Ne?function(e){var t=e.direction,n=e.index,r=e.onClick;return function(e){Kt(n,t||(Xe<n?"forward":"")||(Xe>n?"backward":"")),r&&r(e)}}({direction:h,index:r+t,onClick:a}):a,g=l(l(l({role:"tabpanel",className:y,style:w,onClick:x},f),p?Ae:{}),b?Le:{});return z.current+=1,l({props:g},v)}))};return c((function(){return D.current=0,k===Xe&&(N.current=!1),X.current="",Xe!==k?ze||qe||P(Xe):(Qe&&Qe(Xe,k),(lt||"forward"===et&&Xe!==Ot||"backward"===et&&0!==Xe)&&Qt()),function(){clearTimeout(F.current)}}),[k,Xe,Qe,ze,qe,Qt,lt,Ot,et]),c((function(){return h&&Qt(),function(){clearTimeout(F.current)}}),[h]),c((function(){var e=A.current;function t(){clearTimeout(V.current),clearTimeout(F.current),V.current=setTimeout((function(){h!==window.innerWidth&&L(window.innerWidth)}),400)}return h!==window.innerWidth&&L(window.innerWidth),window.addEventListener("resize",t),function(){clearTimeout(V.current),window.removeEventListener("resize",t),document.removeEventListener("mousemove",_t),document.removeEventListener("mouseup",en),document.removeEventListener("touchmove",_t),document.removeEventListener("touchend",en),e.removeEventListener("mouseout",en),e.removeEventListener("dragstart",en)}}),[_t,en]),z.current=0,B.current=k,e.createElement("div",s({onClickCapture:Yt,style:l({display:"flex",flexFlow:"row wrap",boxSizing:"border-box",justifyContent:"center",width:"100%"},G)},Q,{ref:j}),he&&!Lt&&e.createElement("button",s({},be,{type:"button",onClick:(0===Ht&&st||0===Xe&&mt)&&!lt?void 0:Zt,disabled:"boolean"==typeof be.disabled?be.disabled:!(!(0===Ht&&st||0===Xe&&mt)||lt)}),fe),e.createElement("div",s({},ee,{style:l(l({},_),{},{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:Wt?"".concat(Wt,"px"):void 0,flex:Wt?void 0:"1 0"}),ref:W}),e.createElement("div",s({},se,{style:l(l({},re),{},{display:"flex",boxSizing:"border-box",outline:"none",transition:kt,transform:Ut}),onTouchStart:Ct?void 0:nn,onMouseDown:Ct?void 0:tn,onTransitionEnd:ze||qe?rn:void 0,tabIndex:-1,role:"presentation",ref:A}),lt&&cn(H.slice(k),k,Ct),cn(H,0,Ct),lt&&cn(H,0,Ct),lt&&cn(H.slice(0,k),0,Ct))),ge&&!Lt&&e.createElement("button",s({},Se,{type:"button",onClick:(Ht===Dt&&st||Xe===Ot&&mt)&&!lt?void 0:on,disabled:"boolean"==typeof Se.disabled?Se.disabled:!(!(Ht===Dt&&st||Xe===Ot&&mt)||lt)}),we),!!wt&&e.createElement("div",s({style:{width:"100%",display:"flex",justifyContent:"center"}},gt),Array.from({length:Math.ceil(H.length/Je)}).map((function(t,n){return e.createElement("button",s({type:"button",key:n,title:"".concat(n)},Et,Math.min(n*Je,H.length-1)===Xe?It:{},{onClick:function(){Kt(Math.min(n*Je,H.length-1),Math.min(n*Je,H.length-1)>Xe?"forward":"backward")}}))}))))}var C=t(L);export{C 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";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function u(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],c=!0,u=!1;try{for(n=n.call(e);!(c=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{c||null==n.return||n.return()}finally{if(u)throw i}}return o}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var f=["responsiveProps"],m=["minWidth","maxWidth"],v=["style","onClickCapture"],h=["style"],b=["style","onTouchStart","onMouseDown","onTransitionEnd"],p=["children","show"],y=["children","show"],w=["className","style"],g=["className","style"],x=["className","onClick","style"],S=["props"];function C(e){var t=e.infinite,n=e.indexOfFirstSlideInDOM,r=e.itemsListRef;return t?a(r.current.children).slice(r.current.children.length/3-n,r.current.children.length/3-n+r.current.children.length/3):a(r.current.children)}function E(e){var t=e.activeSlideIndex,n=e.itemsListRef,r=e.innerRef,i=e.offsetCorrectionForCenterMode,o=e.offsetCorrectionForInfiniteMode,c=e.infinite,u=e.indexOfFirstSlideInDOM,l=e.itemsToShow,s=C({infinite:c,indexOfFirstSlideInDOM:u,itemsListRef:n}),d=l?s.reduce((function(e,n,r){return r>=t&&r<t+l||r<t&&r<t+l-s.length?e+n.offsetWidth:e}),0):r.current.offsetWidth,f=c?o+i:Math.min(n.current.offsetWidth-d,s.reduce((function(e,n,r){return r<t?e+n.offsetWidth:e}),0)),m=f+d,v=c?[].concat(a(s.slice(t).map((function(e,n){return{slideIndex:n+t,htmlElement:e}}))),a(s.map((function(e,t){return{slideIndex:t,htmlElement:e}}))),a(s.map((function(e,t){return{slideIndex:t,htmlElement:e}}))),a(s.slice(0,t).map((function(e,t){return{slideIndex:t,htmlElement:e}})))):s.map((function(e,t){return{slideIndex:t,htmlElement:e}})),h=v.reduce((function(e,t){var n=t.slideIndex,r=t.htmlElement.offsetWidth;return(e.summ>=f&&e.summ<m||e.summ+r>f&&e.summ+r<=m)&&e.items.push({slideIndex:n,isFullyVisible:e.summ+r<=m&&e.summ>=f}),e.summ+=r,e}),{summ:0,items:[]}),b=!!h.items.find((function(e){return 0===e.slideIndex})),p=!!h.items.find((function(e){return e.slideIndex===s.length-1}));return{visibleSlides:h.items,isFirstSlideVisible:b,isLastSlideVisible:p}}function O(t){var r=t.responsiveProps,o=void 0===r?[]:r,a=u(t,f),s=l(e.useState(0),2),d=s[0],O=s[1],k=l(e.useState(a.activeSlideIndex),2),I=k[0],T=k[1],L=e.useRef(null),M=e.useRef(null),j=e.useRef(null),P=e.useRef(0),W=e.useRef(!1),R=e.useRef(""),F=e.useRef(null),A=e.useRef(null),D=e.useRef(0),N=e.useRef(I),X=o.reduce((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minWidth,r=void 0===n?0:n,o=t.maxWidth,c=void 0===o?null:o,l=u(t,m);return d>r&&(!c||d<=c)?i(i({},e),l):e}),a),V=e.Children.toArray(X.children),z=d?i(i({},X),{},{activeSlideIndex:Math.max(0,Math.min(X.activeSlideIndex,V.length-1)),itemsToShow:Math.min(V.length,X.itemsToShow||0),itemsToScroll:Math.min(V.length,X.itemsToScroll||1)}):a,B=z.containerProps,q=(B=void 0===B?{}:B).style,U=void 0===q?{}:q,$=B.onClickCapture,G=void 0===$?null:$,H=u(B,v),J=z.innerProps,K=(J=void 0===J?{}:J).style,Q=void 0===K?{}:K,Y=u(J,h),Z=z.itemsListProps,_=(Z=void 0===Z?{}:Z).style,ee=void 0===_?{}:_,te=Z.onTouchStart,ne=void 0===te?null:te,re=Z.onMouseDown,ie=void 0===re?null:re,oe=Z.onTransitionEnd,ce=void 0===oe?null:oe,ue=u(Z,b),le=z.backwardBtnProps,ae=(le=void 0===le?{}:le).children,se=void 0===ae?null:ae,de=le.show,fe=void 0===de||de,me=u(le,p),ve=z.forwardBtnProps,he=(ve=void 0===ve?{}:ve).children,be=void 0===he?null:he,pe=ve.show,ye=void 0===pe||pe,we=u(ve,y),ge=z.activeSlideProps,xe=(ge=void 0===ge?{}:ge).className,Se=void 0===xe?"":xe,Ce=ge.style,Ee=void 0===Ce?{}:Ce,Oe=u(ge,w),ke=z.visibleSlideProps,Ie=(ke=void 0===ke?{}:ke).className,Te=void 0===Ie?"":Ie,Le=ke.style,Me=void 0===Le?{}:Le,je=u(ke,g),Pe=z.updateOnItemClick,We=void 0!==Pe&&Pe,Re=z.activeSlideIndex,Fe=z.onRequestChange,Ae=z.speed,De=void 0===Ae?0:Ae,Ne=z.delay,Xe=void 0===Ne?0:Ne,Ve=z.easing,ze=void 0===Ve?"linear":Ve,Be=z.itemsToShow,qe=void 0===Be?0:Be,Ue=z.itemsToScroll,$e=void 0===Ue?1:Ue,Ge=z.children,He=z.onAfterChange,Je=z.autoplay,Ke=void 0!==Je&&Je,Qe=z.autoplayDirection,Ye=void 0===Qe?"forward":Qe,Ze=z.disableNavIfAllVisible,_e=void 0===Ze||Ze,et=z.hideNavIfAllVisible,tt=void 0===et||et,nt=z.centerMode,rt=void 0!==nt&&nt,it=z.infinite,ot=void 0===it||it,ct=z.disableNavIfEdgeVisible,ut=void 0===ct||ct,lt=z.disableNavIfEdgeActive,at=void 0===lt||lt,st=z.dotsNav,dt=void 0===st?{}:st,ft=z.persistentChangeCallbacks,mt=void 0!==ft&&ft,vt=dt||{},ht=vt.show,bt=void 0!==ht&&ht,pt=vt.containerProps,yt=void 0===pt?{}:pt,wt=vt.itemBtnProps,gt=void 0===wt?{}:wt,xt=vt.activeItemBtnProps,St=void 0===xt?{}:xt,Ct=d?C({infinite:ot,indexOfFirstSlideInDOM:N.current,itemsListRef:j}):[],Et=d&&qe?Ct.reduce((function(e,t,n){return n>=Re&&n<Re+qe||n<Re&&n<Re+qe-Ct.length?e+t.offsetWidth:e}),0):0,Ot=d?j.current.offsetWidth-(Et||M.current.offsetWidth):0,kt=function(e){var t=Ct.reduce((function(t,n,r){return r>=e?t:t+(n.offsetWidth||0)}),0);return ot?t:Math.min(Ot,t)},It=e.Children.count(Ge)-1,Tt=qe===V.length,Lt=tt&&Tt,Mt=_e&&Tt,jt=Re-I!=0,Pt=d&&jt&&ot?kt(I):0,Wt=!d||!jt&&ot?0:kt(Re),Rt=d?Ct[Re].offsetWidth:0,Ft=d&&(rt&&ot)?-((Et||M.current.offsetWidth)-Rt)/2:0,At=ot&&d?j.current.offsetWidth/3:0,Dt=I-Re!=0&&j.current?"forward"===R.current.toLowerCase()&&Re<I?At:"backward"===R.current.toLowerCase()&&Re>I?-At:0:0,Nt=jt&&(De||Xe)?"transform ".concat(De,"ms ").concat(ze," ").concat(Xe,"ms"):"none",Xt=Mt||!d?0:Wt-Pt+Ft+Dt+At,Vt=d?"translateX(-".concat(Xt,"px)"):"none",zt=d?E({activeSlideIndex:Re,itemsListRef:j,innerRef:M,offsetCorrectionForCenterMode:Ft,infinite:ot,indexOfFirstSlideInDOM:N.current,offsetCorrectionForInfiniteMode:At,itemsToShow:qe}):{visibleSlides:[],isFirstSlideVisible:!1,isLastSlideVisible:!1},Bt=e.useCallback((function(e){if("forward"===e){var t=Re+$e;return t>It?ot?t-It-1:Re:t}if("backward"===e){var n=Re-$e;return n<0?ot?It+1+n:Re:n}return Re}),[Re,$e,It,ot]),qt=e.useCallback((function(e,t){R.current=t,j.current.style.transition=De||Xe?"transform ".concat(De,"ms ").concat(ze," ").concat(Xe,"ms"):"none",e!==Re||mt?(clearTimeout(F.current),Fe(e,E({activeSlideIndex:e,indexOfFirstSlideInDOM:I,infinite:ot,innerRef:M,itemsListRef:j,offsetCorrectionForCenterMode:Ft,offsetCorrectionForInfiniteMode:At,itemsToShow:qe}))):(P.current=0,j.current.style.transform="translateX(-".concat(Ft+At+(ot?0:Xt),"px)"))}),[mt,Re,Ft,Xe,ze,De,Fe,At,ot,Xt,I,qe]),Ut=e.useCallback((function(){Ke&&(clearTimeout(F.current),F.current=setTimeout((function(){qt(Bt(Ye),Ye)}),Xe))}),[Ke,Ye,qt,Bt,Xe]),$t=e.useCallback((function(e){W.current&&(e.preventDefault(),e.stopPropagation(),G&&G(e))}),[G]),Gt=e.useCallback((function(){qt(Bt("backward"),"backward")}),[qt,Bt]),Ht=e.useCallback((function(e){W.current=!0;var t=e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX,n=P.current-t+Ft+At+(ot?0:Xt),r=j.current.offsetWidth-M.current.offsetWidth,i=Math.max(Math.min(0,-n),-r);j.current.style.transition="none",j.current.style.transform="translateX(".concat(i,"px)")}),[Ft,At,ot,Xt]),Jt=e.useCallback((function(e){if(j.current.removeEventListener("mouseout",Jt),j.current.removeEventListener("dragstart",Jt),document.removeEventListener("mousemove",Ht),document.removeEventListener("mouseup",Jt),document.removeEventListener("touchmove",Ht),document.removeEventListener("touchend",Jt),W.current){var t=e.changedTouches&&e.changedTouches.length?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,n=P.current-t;n>Rt/2?qt(Bt("forward"),"forward"):n<-Rt/2?qt(Bt("backward"),"backward"):qt(Re,"forward")}}),[Re,Rt,qt,Bt,Ht]),Kt=e.useCallback((function(e){clearTimeout(F.current),W.current||(P.current=e.clientX,document.addEventListener("mousemove",Ht),document.addEventListener("mouseup",Jt),j.current.addEventListener("mouseout",Jt),j.current.addEventListener("dragstart",Jt)),ie&&ie(e)}),[Ht,Jt,ie]),Qt=e.useCallback((function(e){clearTimeout(F.current),W.current||(P.current=e.touches[0].clientX,document.addEventListener("touchmove",Ht),document.addEventListener("touchend",Jt)),ne&&ne(e)}),[Ht,Jt,ne]),Yt=e.useCallback((function(e){T(Re),ce&&ce(e)}),[Re,ce]),Zt=e.useCallback((function(){qt(Bt("forward"),"forward")}),[qt,Bt]),_t=function(e,t,n){return e.map((function(e,r){var o=e.props,c=(o=void 0===o?{}:o).className,l=void 0===c?"":c,a=o.onClick,s=void 0===a?null:a,d=o.style,f=void 0===d?{}:d,m=u(o,x),v=u(e,S),h=ot?D.current>=V.length?"forward":"backward":r>=Re?"forward":"backward",b=r+t===Re,p=zt.visibleSlides.find((function(e){return e.slideIndex===r+t})),y="".concat(l," ").concat(h," ").concat(b?Se:""," ").concat(p?Te:""),w=i(i(i(i({},f),p?Me:{}),b?Ee:{}),{},{boxSizing:"border-box",margin:0}),g=!n&&We?function(e){var t=e.direction,n=e.index,r=e.onClick;return function(e){qt(n,t||(Re<n?"forward":"")||(Re>n?"backward":"")),r&&r(e)}}({direction:h,index:r+t,onClick:s}):s,C=i(i(i({role:"tabpanel",className:y,style:w,onClick:g},m),p?je:{}),b?Oe:{});return D.current+=1,i({props:C},v)}))};return e.useEffect((function(){return P.current=0,I===Re&&(W.current=!1),R.current="",Re!==I?De||Xe||T(Re):(He&&He(Re,I),(ot||"forward"===Ye&&Re!==It||"backward"===Ye&&0!==Re)&&Ut()),function(){clearTimeout(F.current)}}),[I,Re,He,De,Xe,Ut,ot,It,Ye]),e.useEffect((function(){return d&&Ut(),function(){clearTimeout(F.current)}}),[d]),e.useEffect((function(){var e=j.current;function t(){clearTimeout(A.current),clearTimeout(F.current),A.current=setTimeout((function(){d!==window.innerWidth&&O(window.innerWidth)}),400)}return d!==window.innerWidth&&O(window.innerWidth),window.addEventListener("resize",t),function(){clearTimeout(A.current),window.removeEventListener("resize",t),document.removeEventListener("mousemove",Ht),document.removeEventListener("mouseup",Jt),document.removeEventListener("touchmove",Ht),document.removeEventListener("touchend",Jt),e.removeEventListener("mouseout",Jt),e.removeEventListener("dragstart",Jt)}}),[Ht,Jt]),D.current=0,N.current=I,n.default.createElement("div",c({onClickCapture:$t,style:i({display:"flex",flexFlow:"row wrap",boxSizing:"border-box",justifyContent:"center",width:"100%"},U)},H,{ref:L}),fe&&!Lt&&n.default.createElement("button",c({},me,{type:"button",onClick:(0===Xt&&ut||0===Re&&at)&&!ot?void 0:Gt,disabled:"boolean"==typeof me.disabled?me.disabled:!(!(0===Xt&&ut||0===Re&&at)||ot)}),se),n.default.createElement("div",c({},Y,{style:i(i({},Q),{},{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:Et?"".concat(Et,"px"):void 0,flex:Et?void 0:"1 0"}),ref:M}),n.default.createElement("div",c({},ue,{style:i(i({},ee),{},{display:"flex",boxSizing:"border-box",outline:"none",transition:Nt,transform:Vt}),onTouchStart:Mt?void 0:Qt,onMouseDown:Mt?void 0:Kt,onTransitionEnd:De||Xe?Yt:void 0,tabIndex:-1,role:"presentation",ref:j}),ot&&_t(V.slice(I),I,Mt),_t(V,0,Mt),ot&&_t(V,0,Mt),ot&&_t(V.slice(0,I),0,Mt))),ye&&!Lt&&n.default.createElement("button",c({},we,{type:"button",onClick:(Xt===Ot&&ut||Re===It&&at)&&!ot?void 0:Zt,disabled:"boolean"==typeof we.disabled?we.disabled:!(!(Xt===Ot&&ut||Re===It&&at)||ot)}),be),!!bt&&n.default.createElement("div",c({style:{width:"100%",display:"flex",justifyContent:"center"}},yt),Array.from({length:Math.ceil(V.length/$e)}).map((function(e,t){return n.default.createElement("button",c({type:"button",key:t,title:"".concat(t)},gt,Math.min(t*$e,V.length-1)===Re?St:{},{onClick:function(){qt(Math.min(t*$e,V.length-1),Math.min(t*$e,V.length-1)>Re?"forward":"backward")}}))}))))}return e.memo(O)})); | ||
!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";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function l(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],c=!0,l=!1;try{for(n=n.call(e);!(c=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{c||null==n.return||n.return()}finally{if(l)throw i}}return o}(e,t)||u(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var f=["responsiveProps"],m=["minWidth","maxWidth"],v=["style","onClickCapture"],h=["style"],b=["style","onTouchStart","onMouseDown","onTransitionEnd"],p=["children","show"],y=["children","show"],w=["className","style"],x=["className","style"],g=["className","onClick","style"],S=["props"];function E(e){var t=e.infinite,n=e.correctionSlideIndex,r=e.prevCorrectionSlideIndex,i=e.itemsListDOMElement,o=e.curActiveSlideIndex,c=e.itemsToShow,l=e.innerDOMElement,a=e.centerMode,u=e.direction,s=e.disableNav,f=t?d(i.children).slice(i.children.length/3-r,i.children.length/3-r+i.children.length/3):d(i.children),m=f[o].offsetWidth,v=c?f.reduce((function(e,t,n){return n>=o&&n<o+c||n<o&&n<o+c-f.length?e+t.offsetWidth:e}),0):l.offsetWidth,h=i.offsetWidth-v,b=a&&t?-(v-m)/2:0,p=t?i.offsetWidth/3:0,y=n-o==0?0:"forward"===u&&o<n?p:"backward"===u&&o>n?-p:0,w=o-n!=0,x=function(e){var n=f.reduce((function(t,n,r){return r>=e?t:t+(n.offsetWidth||0)}),0);return t?n:Math.min(h,n)},g=w&&t?x(n):0,S=w||!t?x(o):0,E=s?0:S-g+b+y+p,C="translateX(-".concat(E,"px)"),T=t?p+b:Math.min(i.offsetWidth-v,f.reduce((function(e,t,n){return n<o?e+t.offsetWidth:e}),0)),k=T+v,I=t?[].concat(d(f.slice(o).map((function(e,t){return{slideIndex:t+o,htmlElement:e}}))),d(f.map((function(e,t){return{slideIndex:t,htmlElement:e}}))),d(f.map((function(e,t){return{slideIndex:t,htmlElement:e}}))),d(f.slice(0,o).map((function(e,t){return{slideIndex:t,htmlElement:e}})))):f.map((function(e,t){return{slideIndex:t,htmlElement:e}})),O=I.reduce((function(e,t){var n=t.slideIndex,r=t.htmlElement.offsetWidth;return(e.summ>=T&&e.summ<k||e.summ+r>T&&e.summ+r<=k)&&e.items.push({slideIndex:n,isFullyVisible:e.summ+r<=k&&e.summ>=T}),e.summ+=r,e}),{summ:0,items:[]}),M=!!O.items.find((function(e){return 0===e.slideIndex})),L=!!O.items.find((function(e){return e.slideIndex===f.length-1}));return{slidesHTMLElements:f,innerMaxWidth:v,itemsListMaxTranslateX:h,activeSlideWidth:m,offsetCorrectionForCenterMode:b,offsetCorrectionForInfiniteMode:p,itemsListTranslateX:E,itemsListTransform:C,visibleSlides:O.items,isFirstSlideVisible:M,isLastSlideVisible:L}}function C(t){var r=t.responsiveProps,o=void 0===r?[]:r,d=l(t,f),u=a(e.useState(0),2),s=u[0],C=u[1],T=a(e.useState(d.activeSlideIndex),2),k=T[0],I=T[1],O=e.useRef(null),M=e.useRef(null),L=e.useRef(null),j=e.useRef(0),P=e.useRef(!1),W=e.useRef(""),A=e.useRef(null),D=e.useRef(null),N=e.useRef(0),R=e.useRef(k),X=o.reduce((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minWidth,r=void 0===n?0:n,o=t.maxWidth,c=void 0===o?null:o,a=l(t,m);return s>r&&(!c||s<=c)?i(i({},e),a):e}),d),F=e.Children.toArray(X.children),V=s?i(i({},X),{},{activeSlideIndex:Math.max(0,Math.min(X.activeSlideIndex,F.length-1)),itemsToShow:Math.min(F.length,X.itemsToShow||0),itemsToScroll:Math.min(F.length,X.itemsToScroll||1)}):d,z=V.containerProps,B=(z=void 0===z?{}:z).style,q=void 0===B?{}:B,H=z.onClickCapture,U=void 0===H?null:H,$=l(z,v),G=V.innerProps,J=(G=void 0===G?{}:G).style,K=void 0===J?{}:J,Q=l(G,h),Y=V.itemsListProps,Z=(Y=void 0===Y?{}:Y).style,_=void 0===Z?{}:Z,ee=Y.onTouchStart,te=void 0===ee?null:ee,ne=Y.onMouseDown,re=void 0===ne?null:ne,ie=Y.onTransitionEnd,oe=void 0===ie?null:ie,ce=l(Y,b),le=V.backwardBtnProps,ae=(le=void 0===le?{}:le).children,de=void 0===ae?null:ae,ue=le.show,se=void 0===ue||ue,fe=l(le,p),me=V.forwardBtnProps,ve=(me=void 0===me?{}:me).children,he=void 0===ve?null:ve,be=me.show,pe=void 0===be||be,ye=l(me,y),we=V.activeSlideProps,xe=(we=void 0===we?{}:we).className,ge=void 0===xe?"":xe,Se=we.style,Ee=void 0===Se?{}:Se,Ce=l(we,w),Te=V.visibleSlideProps,ke=(Te=void 0===Te?{}:Te).className,Ie=void 0===ke?"":ke,Oe=Te.style,Me=void 0===Oe?{}:Oe,Le=l(Te,x),je=V.updateOnItemClick,Pe=void 0!==je&&je,We=V.activeSlideIndex,Ae=V.onRequestChange,De=V.speed,Ne=void 0===De?0:De,Re=V.delay,Xe=void 0===Re?0:Re,Fe=V.easing,Ve=void 0===Fe?"linear":Fe,ze=V.itemsToShow,Be=void 0===ze?0:ze,qe=V.itemsToScroll,He=void 0===qe?1:qe,Ue=V.children,$e=V.onAfterChange,Ge=V.autoplay,Je=void 0!==Ge&&Ge,Ke=V.autoplayDirection,Qe=void 0===Ke?"forward":Ke,Ye=V.disableNavIfAllVisible,Ze=void 0===Ye||Ye,_e=V.hideNavIfAllVisible,et=void 0===_e||_e,tt=V.centerMode,nt=void 0!==tt&&tt,rt=V.infinite,it=void 0===rt||rt,ot=V.disableNavIfEdgeVisible,ct=void 0===ot||ot,lt=V.disableNavIfEdgeActive,at=void 0===lt||lt,dt=V.dotsNav,ut=void 0===dt?{}:dt,st=V.persistentChangeCallbacks,ft=void 0!==st&&st,mt=ut||{},vt=mt.show,ht=void 0!==vt&&vt,bt=mt.containerProps,pt=void 0===bt?{}:bt,yt=mt.itemBtnProps,wt=void 0===yt?{}:yt,xt=mt.activeItemBtnProps,gt=void 0===xt?{}:xt,St=e.Children.count(Ue)-1,Et=Be===F.length,Ct=et&&Et,Tt=Ze&&Et,kt=We-k==0||!Ne&&!Xe?"none":"transform ".concat(Ne,"ms ").concat(Ve," ").concat(Xe,"ms"),It=s?E({infinite:it,itemsListDOMElement:L.current,prevCorrectionSlideIndex:R.current,itemsToShow:Be,curActiveSlideIndex:We,innerDOMElement:M.current,centerMode:nt,correctionSlideIndex:k,direction:W.current,disableNav:Tt}):{},Ot=It.innerMaxWidth,Mt=void 0===Ot?0:Ot,Lt=It.itemsListMaxTranslateX,jt=void 0===Lt?0:Lt,Pt=It.activeSlideWidth,Wt=void 0===Pt?0:Pt,At=It.offsetCorrectionForCenterMode,Dt=void 0===At?0:At,Nt=It.offsetCorrectionForInfiniteMode,Rt=void 0===Nt?0:Nt,Xt=It.itemsListTranslateX,Ft=void 0===Xt?0:Xt,Vt=It.itemsListTransform,zt=void 0===Vt?"none":Vt,Bt=It.visibleSlides,qt=void 0===Bt?[]:Bt,Ht=e.useCallback((function(e){if("forward"===e){var t=We+He;return t>St?it?t-St-1:We:t}if("backward"===e){var n=We-He;return n<0?it?St+1+n:We:n}return We}),[We,He,St,it]),Ut=e.useCallback((function(e,t){if(W.current=t,L.current.style.transition=Ne||Xe?"transform ".concat(Ne,"ms ").concat(Ve," ").concat(Xe,"ms"):"none",e!==We||ft){clearTimeout(A.current);var n=E({infinite:it,correctionSlideIndex:k,prevCorrectionSlideIndex:k,curActiveSlideIndex:e,itemsToShow:Be,itemsListDOMElement:L.current,innerDOMElement:M.current,centerMode:nt,disableNav:Tt,direction:W.current}),r=n.visibleSlides,i=n.isFirstSlideVisible,o=n.isLastSlideVisible;Ae(e,{visibleSlides:r,isFirstSlideVisible:i,isLastSlideVisible:o})}else j.current=0,L.current.style.transform="translateX(-".concat(Dt+Rt+(it?0:Ft),"px)")}),[ft,We,Dt,Xe,Ve,Ne,Ae,Rt,it,Ft,k,Be,nt,Tt]),$t=e.useCallback((function(){Je&&(clearTimeout(A.current),A.current=setTimeout((function(){Ut(Ht(Qe),Qe)}),Xe))}),[Je,Qe,Ut,Ht,Xe]),Gt=e.useCallback((function(e){P.current&&(e.preventDefault(),e.stopPropagation(),U&&U(e))}),[U]),Jt=e.useCallback((function(){Ut(Ht("backward"),"backward")}),[Ut,Ht]),Kt=e.useCallback((function(e){P.current=!0;var t=e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX,n=j.current-t+Dt+Rt+(it?0:Ft),r=L.current.offsetWidth-M.current.offsetWidth,i=Math.max(Math.min(0,-n),-r);L.current.style.transition="none",L.current.style.transform="translateX(".concat(i,"px)")}),[Dt,Rt,it,Ft]),Qt=e.useCallback((function(e){if(L.current.removeEventListener("mouseout",Qt),L.current.removeEventListener("dragstart",Qt),document.removeEventListener("mousemove",Kt),document.removeEventListener("mouseup",Qt),document.removeEventListener("touchmove",Kt),document.removeEventListener("touchend",Qt),P.current){var t=e.changedTouches&&e.changedTouches.length?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,n=j.current-t,r=n>Wt/2?{index:Ht("forward"),direction:"forward"}:n<-Wt/2?{index:Ht("backward"),direction:"backward"}:{index:We,direction:"forward"};r.index===We&&(P.current=!1),Ut(r.index,r.direction)}}),[We,Wt,Ut,Ht,Kt]),Yt=e.useCallback((function(e){clearTimeout(A.current),P.current||(j.current=e.clientX,document.addEventListener("mousemove",Kt),document.addEventListener("mouseup",Qt),L.current.addEventListener("mouseout",Qt),L.current.addEventListener("dragstart",Qt)),re&&re(e)}),[Kt,Qt,re]),Zt=e.useCallback((function(e){clearTimeout(A.current),P.current||(j.current=e.touches[0].clientX,document.addEventListener("touchmove",Kt),document.addEventListener("touchend",Qt)),te&&te(e)}),[Kt,Qt,te]),_t=e.useCallback((function(e){I(We),oe&&oe(e)}),[We,oe]),en=e.useCallback((function(){Ut(Ht("forward"),"forward")}),[Ut,Ht]),tn=function(e,t,n){return e.map((function(e,r){var o=e.props,c=(o=void 0===o?{}:o).className,a=void 0===c?"":c,d=o.onClick,u=void 0===d?null:d,s=o.style,f=void 0===s?{}:s,m=l(o,g),v=l(e,S),h=it?N.current>=F.length?"forward":"backward":r>=We?"forward":"backward",b=r+t===We,p=qt.find((function(e){return e.slideIndex===r+t})),y="".concat(a," ").concat(h," ").concat(b?ge:""," ").concat(p?Ie:""),w=i(i(i(i({},f),p?Me:{}),b?Ee:{}),{},{boxSizing:"border-box",margin:0}),x=!n&&Pe?function(e){var t=e.direction,n=e.index,r=e.onClick;return function(e){Ut(n,t||(We<n?"forward":"")||(We>n?"backward":"")),r&&r(e)}}({direction:h,index:r+t,onClick:u}):u,E=i(i(i({role:"tabpanel",className:y,style:w,onClick:x},m),p?Le:{}),b?Ce:{});return N.current+=1,i({props:E},v)}))};return e.useEffect((function(){return j.current=0,k===We&&(P.current=!1),W.current="",We!==k?Ne||Xe||I(We):($e&&$e(We,k),(it||"forward"===Qe&&We!==St||"backward"===Qe&&0!==We)&&$t()),function(){clearTimeout(A.current)}}),[k,We,$e,Ne,Xe,$t,it,St,Qe]),e.useEffect((function(){return s&&$t(),function(){clearTimeout(A.current)}}),[s]),e.useEffect((function(){var e=L.current;function t(){clearTimeout(D.current),clearTimeout(A.current),D.current=setTimeout((function(){s!==window.innerWidth&&C(window.innerWidth)}),400)}return s!==window.innerWidth&&C(window.innerWidth),window.addEventListener("resize",t),function(){clearTimeout(D.current),window.removeEventListener("resize",t),document.removeEventListener("mousemove",Kt),document.removeEventListener("mouseup",Qt),document.removeEventListener("touchmove",Kt),document.removeEventListener("touchend",Qt),e.removeEventListener("mouseout",Qt),e.removeEventListener("dragstart",Qt)}}),[Kt,Qt]),N.current=0,R.current=k,n.default.createElement("div",c({onClickCapture:Gt,style:i({display:"flex",flexFlow:"row wrap",boxSizing:"border-box",justifyContent:"center",width:"100%"},q)},$,{ref:O}),se&&!Ct&&n.default.createElement("button",c({},fe,{type:"button",onClick:(0===Ft&&ct||0===We&&at)&&!it?void 0:Jt,disabled:"boolean"==typeof fe.disabled?fe.disabled:!(!(0===Ft&&ct||0===We&&at)||it)}),de),n.default.createElement("div",c({},Q,{style:i(i({},K),{},{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:Mt?"".concat(Mt,"px"):void 0,flex:Mt?void 0:"1 0"}),ref:M}),n.default.createElement("div",c({},ce,{style:i(i({},_),{},{display:"flex",boxSizing:"border-box",outline:"none",transition:kt,transform:zt}),onTouchStart:Tt?void 0:Zt,onMouseDown:Tt?void 0:Yt,onTransitionEnd:Ne||Xe?_t:void 0,tabIndex:-1,role:"presentation",ref:L}),it&&tn(F.slice(k),k,Tt),tn(F,0,Tt),it&&tn(F,0,Tt),it&&tn(F.slice(0,k),0,Tt))),pe&&!Ct&&n.default.createElement("button",c({},ye,{type:"button",onClick:(Ft===jt&&ct||We===St&&at)&&!it?void 0:en,disabled:"boolean"==typeof ye.disabled?ye.disabled:!(!(Ft===jt&&ct||We===St&&at)||it)}),he),!!ht&&n.default.createElement("div",c({style:{width:"100%",display:"flex",justifyContent:"center"}},pt),Array.from({length:Math.ceil(F.length/He)}).map((function(e,t){return n.default.createElement("button",c({type:"button",key:t,title:"".concat(t)},wt,Math.min(t*He,F.length-1)===We?gt:{},{onClick:function(){Ut(Math.min(t*He,F.length-1),Math.min(t*He,F.length-1)>We?"forward":"backward")}}))}))))}return e.memo(C)})); |
{ | ||
"name": "react-simply-carousel", | ||
"version": "8.3.1", | ||
"version": "8.3.2", | ||
"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": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
52258
168