react-simply-carousel
Advanced tools
Comparing version 5.1.1 to 5.1.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactSimplyCarousel=t(require("react")):e.ReactSimplyCarousel=t(e.React)}(this,(function(e){return(()=>{"use strict";var t={383:t=>{t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{default:()=>C});var e=n(383),t=n.n(e),r=["responsiveProps"],i=["minWidth","maxWidth"],a=["style","onClickCapture"],c=["style"],u=["style","onTouchStart","onMouseDown","onTransitionEnd"],l=["children","show"],s=["children","show"],d=["className","style"],f=["show","activeClassName"],m=["className","onClick","style"],p=["props"];function v(){return(v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function b(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)||E(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 h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){w(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}}(e,t)||E(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 E(e,t){if(e){if("string"==typeof e)return S(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(e,t):void 0}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function k(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function x(n){var o=n.responsiveProps,h=k(n,r),w=g((0,e.useState)(0),2),E=w[0],S=w[1],x=g((0,e.useState)(h.activeSlideIndex),2),C=x[0],O=x[1],P=(0,e.useRef)(null),T=(0,e.useRef)(null),j=(0,e.useRef)(null),L=(0,e.useRef)(null),M=(0,e.useRef)(!1),I=(0,e.useRef)(""),N=(0,e.useRef)(null),A=(0,e.useRef)(null),W=(0,e.useRef)(0),R=o.reduce((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minWidth,n=void 0===r?0:r,o=t.maxWidth,a=void 0===o?null:o,c=k(t,i);return E>n&&(!a||E<=a)?y(y({},e),c):e}),h),D=e.Children.toArray(R.children),X=E?y(y({},R),{},{activeSlideIndex:Math.max(0,Math.min(R.activeSlideIndex,D.length-1)),itemsToShow:Math.min(D.length,R.itemsToShow),itemsToScroll:Math.min(D.length,R.itemsToScroll)}):h,z=X.containerProps,V=z.style,B=z.onClickCapture,_=k(z,a),q=X.innerProps,F=q.style,U=k(q,c),$=X.itemsListProps,G=$.style,H=($.onTouchStart,$.onMouseDown,$.onTransitionEnd,k($,u)),J=X.backwardBtnProps,K=J.children,Q=void 0===K?null:K,Y=J.show,Z=void 0===Y||Y,ee=k(J,l),te=X.forwardBtnProps,re=te.children,ne=void 0===re?null:re,oe=te.show,ie=void 0===oe||oe,ae=k(te,s),ce=X.activeSlideProps,ue=ce.className,le=void 0===ue?"":ue,se=ce.style,de=void 0===se?{}:se,fe=k(ce,d),me=X.updateOnItemClick,pe=X.activeSlideIndex,ve=X.onRequestChange,be=X.speed,he=X.delay,ye=X.easing,we=X.itemsToShow,ge=X.itemsToScroll,Ee=X.children,Se=X.onAfterChange,ke=X.autoplay,xe=X.autoplayDirection,Ce=X.disableNavIfAllVisible,Oe=X.hideNavIfAllVisible,Pe=X.centerMode,Te=X.infinite,je=X.disableNavIfEdgeVisible,Le=X.disableNavIfEdgeActive,Me=X.dotsNav,Ie=X.dotsNavWrapperProps,Ne=Me||{},Ae=Ne.show,We=void 0!==Ae&&Ae,Re=Ne.activeClassName,De=void 0===Re?"":Re,Xe=k(Ne,f),ze=(0,e.useMemo)((function(){return E?Te?b(j.current.children).slice(D.length-C,D.length-C+D.length):b(j.current.children):[]}),[C,D.length,E,Te]),Ve=E?j.current.offsetWidth-T.current.offsetWidth:0,Be=function(e){var t=ze.reduce((function(t,r,n){return n>=e?t:t+(r.offsetWidth||0)}),0);return Te?t:Math.min(Ve,t)},_e=(0,e.useMemo)((function(){return E&&we?ze.reduce((function(e,t,r){return r>=pe&&r<pe+we||r<pe&&r<pe+we-ze.length?e+t.offsetWidth:e}),0):null}),[pe,we,ze,E]),qe=e.Children.count(Ee)-1,Fe=we===D.length,Ue=Oe&&Fe,$e=Ce&&Fe,Ge=pe-C!=0,He=E&&Ge&&Te?Be(C):0,Je=!E||!Ge&&Te?0:Be(pe),Ke=E?ze[pe].offsetWidth:0,Qe=E&&Pe&&Te?-(Math.min(_e||T.current.offsetWidth,T.current.offsetWidth)-Ke)/2:0,Ye=(0,e.useMemo)((function(){return Te&&E?j.current.offsetWidth/3:0}),[E,Te]),Ze=C-pe!=0&&j.current?"forward"===I.current.toLowerCase()&&pe<C?Ye:"backward"===I.current.toLowerCase()&&pe>C?-Ye:0:0,et=Ge&&(be||he)?"transform ".concat(be,"ms ").concat(ye," ").concat(he,"ms"):null,tt=$e||!E?0:Je-He+Qe+Ze+Ye,rt=E?"translateX(-".concat(tt,"px)"):null,nt=(0,e.useCallback)((function(e){if("forward"===e){var t=pe+ge;return t>qe?Te?t-qe-1:pe:t}if("backward"===e){var r=pe-ge;return r<0?Te?qe+1+r:pe:r}return pe}),[pe,ge,qe,Te]),ot=(0,e.useCallback)((function(e,t){I.current=t,j.current.style.transition=be||he?"transform ".concat(be,"ms ").concat(ye," ").concat(he,"ms"):null,e!==pe?(clearTimeout(N.current),ve(e)):(L.current=null,M.current=!1,j.current.style.transform="translateX(-".concat(Qe+Ye+(Te?0:tt),"px)"))}),[pe,Qe,he,ye,be,ve,Ye,Te,tt]),it=(0,e.useCallback)((function(){ke&&(clearTimeout(N.current),N.current=setTimeout((function(){ot(nt(xe),xe)}),he))}),[ke,xe,ot,nt,he]),at=(0,e.useCallback)((function(e){M.current&&(e.preventDefault(),e.stopPropagation(),B&&B(e))}),[B]),ct=(0,e.useCallback)((function(){ot(nt("backward"),"backward")}),[ot,nt]),ut=(0,e.useCallback)((function(e){M.current=!0;var t=e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX,r=L.current-t+Qe+Ye+(Te?0:tt),n=j.current.offsetWidth-T.current.offsetWidth,o=Math.max(Math.min(0,-r),-n);j.current.style.transition=null,j.current.style.transform="translateX(".concat(o,"px)")}),[Qe,Ye,Te,tt]),lt=(0,e.useCallback)((function(e){if(j.current.removeEventListener("mouseout",lt),j.current.removeEventListener("dragstart",lt),document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",lt),document.removeEventListener("touchmove",ut),document.removeEventListener("touchend",lt),M.current){var t=e.changedTouches&&e.changedTouches.length?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,r=L.current-t;r>Ke/2?ot(nt("forward"),"forward"):r<-Ke/2?ot(nt("backward"),"backward"):ot(pe,"forward")}}),[pe,Ke,ot,nt,ut]),st=(0,e.useCallback)((function(e){clearTimeout(N.current),M.current||(L.current=e.clientX,document.addEventListener("mousemove",ut),document.addEventListener("mouseup",lt),j.current.addEventListener("mouseout",lt),j.current.addEventListener("dragstart",lt))}),[ut,lt]),dt=(0,e.useCallback)((function(e){clearTimeout(N.current),M.current||(L.current=e.touches[0].clientX,document.addEventListener("touchmove",ut),document.addEventListener("touchend",lt))}),[ut,lt]),ft=(0,e.useCallback)((function(){O(pe)}),[pe]),mt=(0,e.useCallback)((function(){ot(nt("forward"),"forward")}),[ot,nt]),pt=function(e,t,r){return e.map((function(e,n){var o=e.props,i=(o=void 0===o?{}:o).className,a=void 0===i?"":i,c=o.onClick,u=o.style,l=void 0===u?{}:u,s=k(o,m),d=k(e,p),f=Te?W.current>=D.length?"forward":"backward":n>=pe?"forward":"backward",v=n+t===pe,b="".concat(a," ").concat(f," ").concat(v?le:""),h=y(y(y({},l),v?de:{}),{},{boxSizing:"border-box",margin:0}),w=y(y({role:"tabpanel",className:b,style:h,onClick:!r&&me?function(e){var t=e.direction,r=e.index,n=e.onClick;return function(e){ot(r,t||(pe<r?"forward":"")||(pe>r?"backward":"")),n&&n(e)}}({direction:f,index:n+t,onClick:c}):c},s),v?fe:{});return W.current+=1,y({props:w},d)}))};return(0,e.useEffect)((function(){return L.current=null,M.current=!1,I.current="",pe!==C?be||he||O(pe):(Se&&Se(pe,C),(Te||"forward"===xe&&pe!==qe||"backward"===xe&&0!==pe)&&it()),function(){clearTimeout(N.current)}}),[C,pe,Se,be,he,it,Te,qe,xe]),(0,e.useEffect)((function(){return E&&it(),function(){clearTimeout(N.current)}}),[E]),(0,e.useEffect)((function(){var e=j.current;function t(){clearTimeout(A.current),clearTimeout(N.current),A.current=setTimeout((function(){S(window.innerWidth)}),400)}return S(window.innerWidth),window.addEventListener("resize",t),function(){clearTimeout(A.current),window.removeEventListener("resize",t),document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",lt),document.removeEventListener("touchmove",ut),document.removeEventListener("touchend",lt),e.removeEventListener("mouseout",lt),e.removeEventListener("dragstart",lt)}}),[ut,lt]),W.current=0,E&&(j.current.style.transform=rt),t().createElement("div",v({onClickCapture:at,style:y({display:"flex",boxSizing:"border-box",justifyContent:"center"},V||{})},_,{ref:P}),Z&&!Ue&&t().createElement("button",v({},ee,{type:"button",onClick:(0===tt&&je||0===pe&&Le)&&!Te?null:ct,disabled:"boolean"==typeof ee.disabled?ee.disabled:!(!(0===tt&&je||0===pe&&Le)||Te)}),Q),t().createElement("div",v({},U,{style:y(y({},F||{}),{},{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:_e?"".concat(_e,"px"):"100%"}),ref:T}),t().createElement("div",v({},H,{style:y(y({},G||{}),{},{display:"flex",boxSizing:"border-box",outline:"none",transition:et,transform:rt}),"data-transform":rt,onTouchStart:$e?null:dt,onMouseDown:$e?null:st,onTransitionEnd:be||he?ft:null,tabIndex:"-1",role:"presentation",ref:j}),!$e&&Te&&pt(D.slice(C),C),pt(D,0,$e),!$e&&Te&&pt(D,0),!$e&&Te&&pt(D.slice(0,C),0))),ie&&!Ue&&t().createElement("button",v({},ae,{type:"button",onClick:(tt===Ve&&je||pe===qe&&Le)&&!Te?null:mt,disabled:"boolean"==typeof ae.disabled?ae.disabled:!(!(tt===Ve&&je||pe===qe&&Le)||Te)}),ne),!Te&&!!We&&t().createElement("div",Ie,Array.from({length:Math.ceil(D.length/ge)}).map((function(e,r){return t().createElement("button",v({type:"button",key:r,title:r},Xe,{className:"".concat(Xe.className||""," ").concat(r===Math.ceil((pe-ge)/ge)?De:""),onClick:function(){ot(Math.min(r*ge,D.length-1),Math.min(r*ge,D.length-1)>pe?"forward":"backward")}}))}))))}x.defaultProps={activeSlideProps:{},autoplay:!1,autoplayDirection:"forward",backwardBtnProps:{},children:null,containerProps:{},delay:0,disableNavIfAllVisible:!0,easing:"linear",forwardBtnProps:{},hideNavIfAllVisible:!0,innerProps:{},itemsListProps:{},itemsToScroll:1,itemsToShow:0,onAfterChange:null,responsiveProps:[],speed:0,updateOnItemClick:!1,centerMode:!1,infinite:!0,disableNavIfEdgeVisible:!0,disableNavIfEdgeActive:!0,dotsNav:{},dotsNavWrapperProps:{}};const C=(0,e.memo)(x)})(),o})()})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactSimplyCarousel=t(require("react")):e.ReactSimplyCarousel=t(e.React)}(this,(function(e){return(()=>{"use strict";var t={383:t=>{t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{default:()=>C});var e=n(383),t=n.n(e),r=["responsiveProps"],i=["minWidth","maxWidth"],a=["style","onClickCapture"],c=["style"],u=["style","onTouchStart","onMouseDown","onTransitionEnd"],l=["children","show"],s=["children","show"],d=["className","style"],f=["show","activeClassName"],m=["className","onClick","style"],p=["props"];function v(){return(v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function b(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)||E(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 h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){w(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}}(e,t)||E(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 E(e,t){if(e){if("string"==typeof e)return S(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(e,t):void 0}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function x(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function k(n){var o=n.responsiveProps,h=x(n,r),w=g((0,e.useState)(0),2),E=w[0],S=w[1],k=g((0,e.useState)(h.activeSlideIndex),2),C=k[0],O=k[1],P=(0,e.useRef)(null),T=(0,e.useRef)(null),j=(0,e.useRef)(null),M=(0,e.useRef)(null),L=(0,e.useRef)(!1),I=(0,e.useRef)(""),N=(0,e.useRef)(null),A=(0,e.useRef)(null),W=(0,e.useRef)(0),R=o.reduce((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minWidth,n=void 0===r?0:r,o=t.maxWidth,a=void 0===o?null:o,c=x(t,i);return E>n&&(!a||E<=a)?y(y({},e),c):e}),h),D=e.Children.toArray(R.children),X=E?y(y({},R),{},{activeSlideIndex:Math.max(0,Math.min(R.activeSlideIndex,D.length-1)),itemsToShow:Math.min(D.length,R.itemsToShow),itemsToScroll:Math.min(D.length,R.itemsToScroll)}):h,z=X.containerProps,V=z.style,B=z.onClickCapture,_=x(z,a),q=X.innerProps,F=q.style,U=x(q,c),$=X.itemsListProps,G=$.style,H=($.onTouchStart,$.onMouseDown,$.onTransitionEnd,x($,u)),J=X.backwardBtnProps,K=J.children,Q=void 0===K?null:K,Y=J.show,Z=void 0===Y||Y,ee=x(J,l),te=X.forwardBtnProps,re=te.children,ne=void 0===re?null:re,oe=te.show,ie=void 0===oe||oe,ae=x(te,s),ce=X.activeSlideProps,ue=ce.className,le=void 0===ue?"":ue,se=ce.style,de=void 0===se?{}:se,fe=x(ce,d),me=X.updateOnItemClick,pe=X.activeSlideIndex,ve=X.onRequestChange,be=X.speed,he=X.delay,ye=X.easing,we=X.itemsToShow,ge=X.itemsToScroll,Ee=X.children,Se=X.onAfterChange,xe=X.autoplay,ke=X.autoplayDirection,Ce=X.disableNavIfAllVisible,Oe=X.hideNavIfAllVisible,Pe=X.centerMode,Te=X.infinite,je=X.disableNavIfEdgeVisible,Me=X.disableNavIfEdgeActive,Le=X.dotsNav,Ie=X.dotsNavWrapperProps,Ne=Le||{},Ae=Ne.show,We=void 0!==Ae&&Ae,Re=Ne.activeClassName,De=void 0===Re?"":Re,Xe=x(Ne,f),ze=(0,e.useMemo)((function(){return E?Te?b(j.current.children).slice(D.length-C,D.length-C+D.length):b(j.current.children):[]}),[C,D.length,E,Te]),Ve=E?j.current.offsetWidth-T.current.offsetWidth:0,Be=function(e){var t=ze.reduce((function(t,r,n){return n>=e?t:t+(r.offsetWidth||0)}),0);return Te?t:Math.min(Ve,t)},_e=(0,e.useMemo)((function(){return E&&we?ze.reduce((function(e,t,r){return r>=pe&&r<pe+we||r<pe&&r<pe+we-ze.length?e+t.offsetWidth:e}),0):null}),[pe,we,ze,E]),qe=e.Children.count(Ee)-1,Fe=we===D.length,Ue=Oe&&Fe,$e=Ce&&Fe,Ge=pe-C!=0,He=E&&Ge&&Te?Be(C):0,Je=!E||!Ge&&Te?0:Be(pe),Ke=E?ze[pe].offsetWidth:0,Qe=E&&Pe&&Te?-(Math.min(_e||T.current.offsetWidth,T.current.offsetWidth)-Ke)/2:0,Ye=(0,e.useMemo)((function(){return Te&&E?j.current.offsetWidth/3:0}),[E,Te]),Ze=C-pe!=0&&j.current?"forward"===I.current.toLowerCase()&&pe<C?Ye:"backward"===I.current.toLowerCase()&&pe>C?-Ye:0:0,et=Ge&&(be||he)?"transform ".concat(be,"ms ").concat(ye," ").concat(he,"ms"):null,tt=$e||!E?0:Je-He+Qe+Ze+Ye,rt=E?"translateX(-".concat(tt,"px)"):null,nt=(0,e.useCallback)((function(e){if("forward"===e){var t=pe+ge;return t>qe?Te?t-qe-1:pe:t}if("backward"===e){var r=pe-ge;return r<0?Te?qe+1+r:pe:r}return pe}),[pe,ge,qe,Te]),ot=(0,e.useCallback)((function(e,t){I.current=t,j.current.style.transition=be||he?"transform ".concat(be,"ms ").concat(ye," ").concat(he,"ms"):null,e!==pe?(clearTimeout(N.current),ve(e)):(M.current=null,L.current=!1,j.current.style.transform="translateX(-".concat(Qe+Ye+(Te?0:tt),"px)"))}),[pe,Qe,he,ye,be,ve,Ye,Te,tt]),it=(0,e.useCallback)((function(){xe&&(clearTimeout(N.current),N.current=setTimeout((function(){ot(nt(ke),ke)}),he))}),[xe,ke,ot,nt,he]),at=(0,e.useCallback)((function(e){L.current&&(e.preventDefault(),e.stopPropagation(),B&&B(e))}),[B]),ct=(0,e.useCallback)((function(){ot(nt("backward"),"backward")}),[ot,nt]),ut=(0,e.useCallback)((function(e){L.current=!0;var t=e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX,r=M.current-t+Qe+Ye+(Te?0:tt),n=j.current.offsetWidth-T.current.offsetWidth,o=Math.max(Math.min(0,-r),-n);j.current.style.transition=null,j.current.style.transform="translateX(".concat(o,"px)")}),[Qe,Ye,Te,tt]),lt=(0,e.useCallback)((function(e){if(j.current.removeEventListener("mouseout",lt),j.current.removeEventListener("dragstart",lt),document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",lt),document.removeEventListener("touchmove",ut),document.removeEventListener("touchend",lt),L.current){var t=e.changedTouches&&e.changedTouches.length?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,r=M.current-t;r>Ke/2?ot(nt("forward"),"forward"):r<-Ke/2?ot(nt("backward"),"backward"):ot(pe,"forward")}}),[pe,Ke,ot,nt,ut]),st=(0,e.useCallback)((function(e){clearTimeout(N.current),L.current||(M.current=e.clientX,document.addEventListener("mousemove",ut),document.addEventListener("mouseup",lt),j.current.addEventListener("mouseout",lt),j.current.addEventListener("dragstart",lt))}),[ut,lt]),dt=(0,e.useCallback)((function(e){clearTimeout(N.current),L.current||(M.current=e.touches[0].clientX,document.addEventListener("touchmove",ut),document.addEventListener("touchend",lt))}),[ut,lt]),ft=(0,e.useCallback)((function(){O(pe)}),[pe]),mt=(0,e.useCallback)((function(){ot(nt("forward"),"forward")}),[ot,nt]),pt=function(e,t,r){return e.map((function(e,n){var o=e.props,i=(o=void 0===o?{}:o).className,a=void 0===i?"":i,c=o.onClick,u=o.style,l=void 0===u?{}:u,s=x(o,m),d=x(e,p),f=Te?W.current>=D.length?"forward":"backward":n>=pe?"forward":"backward",v=n+t===pe,b="".concat(a," ").concat(f," ").concat(v?le:""),h=y(y(y({},l),v?de:{}),{},{boxSizing:"border-box",margin:0}),w=y(y({role:"tabpanel",className:b,style:h,onClick:!r&&me?function(e){var t=e.direction,r=e.index,n=e.onClick;return function(e){ot(r,t||(pe<r?"forward":"")||(pe>r?"backward":"")),n&&n(e)}}({direction:f,index:n+t,onClick:c}):c},s),v?fe:{});return W.current+=1,y({props:w},d)}))};return(0,e.useEffect)((function(){return M.current=null,L.current=!1,I.current="",pe!==C?be||he||O(pe):(Se&&Se(pe,C),(Te||"forward"===ke&&pe!==qe||"backward"===ke&&0!==pe)&&it()),function(){clearTimeout(N.current)}}),[C,pe,Se,be,he,it,Te,qe,ke]),(0,e.useEffect)((function(){return E&&it(),function(){clearTimeout(N.current)}}),[E]),(0,e.useEffect)((function(){var e=j.current;function t(){clearTimeout(A.current),clearTimeout(N.current),A.current=setTimeout((function(){S(window.innerWidth)}),400)}return S(window.innerWidth),window.addEventListener("resize",t),function(){clearTimeout(A.current),window.removeEventListener("resize",t),document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",lt),document.removeEventListener("touchmove",ut),document.removeEventListener("touchend",lt),e.removeEventListener("mouseout",lt),e.removeEventListener("dragstart",lt)}}),[ut,lt]),W.current=0,E&&(j.current.style.transform=rt),t().createElement("div",v({onClickCapture:at,style:y({display:"flex",boxSizing:"border-box",justifyContent:"center"},V||{})},_,{ref:P}),Z&&!Ue&&t().createElement("button",v({},ee,{type:"button",onClick:(0===tt&&je||0===pe&&Me)&&!Te?null:ct,disabled:"boolean"==typeof ee.disabled?ee.disabled:!(!(0===tt&&je||0===pe&&Me)||Te)}),Q),t().createElement("div",v({},U,{style:y(y({},F||{}),{},{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:_e?"".concat(_e,"px"):"100%"}),ref:T}),t().createElement("div",v({},H,{style:y(y({},G||{}),{},{display:"flex",boxSizing:"border-box",outline:"none",transition:et,transform:rt}),"data-transform":rt,onTouchStart:$e?null:dt,onMouseDown:$e?null:st,onTransitionEnd:be||he?ft:null,tabIndex:"-1",role:"presentation",ref:j}),!$e&&Te&&pt(D.slice(C),C),pt(D,0,$e),!$e&&Te&&pt(D,0),!$e&&Te&&pt(D.slice(0,C),0))),ie&&!Ue&&t().createElement("button",v({},ae,{type:"button",onClick:(tt===Ve&&je||pe===qe&&Me)&&!Te?null:mt,disabled:"boolean"==typeof ae.disabled?ae.disabled:!(!(tt===Ve&&je||pe===qe&&Me)||Te)}),ne),!Te&&!!We&&t().createElement("div",Ie,Array.from({length:Math.ceil(D.length/ge)}).map((function(e,r){return t().createElement("button",v({type:"button",key:r,title:r},Xe,{className:"".concat(Xe.className||""," ").concat(r===Math.ceil(Math.max(0,pe-ge)/ge)?De:""),onClick:function(){ot(Math.min(r*ge,D.length-1),Math.min(r*ge,D.length-1)>pe?"forward":"backward")}}))}))))}k.defaultProps={activeSlideProps:{},autoplay:!1,autoplayDirection:"forward",backwardBtnProps:{},children:null,containerProps:{},delay:0,disableNavIfAllVisible:!0,easing:"linear",forwardBtnProps:{},hideNavIfAllVisible:!0,innerProps:{},itemsListProps:{},itemsToScroll:1,itemsToShow:0,onAfterChange:null,responsiveProps:[],speed:0,updateOnItemClick:!1,centerMode:!1,infinite:!0,disableNavIfEdgeVisible:!0,disableNavIfEdgeActive:!0,dotsNav:{},dotsNavWrapperProps:{}};const C=(0,e.memo)(k)})(),o})()})); |
{ | ||
"name": "react-simply-carousel", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"description": "Simple react.js carousel component", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
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
29788