-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 1.98 KB
/
index.js
1
import e,{useCallback as t,useMemo as n,Fragment as a}from"react";var r=function(r){var c,i,l,o,m,s=r.data,u=r.widthSize,g=r.heightSize,d=r.controls,f=r.duration,v=e.useState(0),C=v[0],E=v[1],x=e.useState(!1),b=x[0],h=x[1],p=e.useState(!1),y=p[0],S=p[1];c=s?Object.assign(s):Object.assign(["Please pass data props! ..."]),u&&(i=Object.assign(u)),g&&(l=Object.assign(u)),o=d||{enabled:!1,styled:"arrows",customStyle:"NA"},m=f?1e3*f:6e4;var N=t((function(){return C===c.length-1?E(0):E(C+1)}),[E,C,c]),_=t((function(e){return setInterval((function(){N()}),e)}),[N]);return e.useEffect((function(){return o.enabled?0===C&&(h(!1),S(!0),1===s.length?h(!0):h(!1)):_(m),function(){o.enabled||clearInterval(_(m))}}),[S,o,C,_,m,s]),e.createElement("div",{className:"mine-container"},e.createElement((function(t){var r,o=t.data,m=t.config,s=n((function(){return o}),[o]),u={prev:"mine-bts _controls-prev",next:"mine-bts _controls-next"};return r=(m.styled,u),e.createElement(a,null,s.map((function(t,n){var o=!y&&e.createElement("div",{onClick:function(){return E(C-1)},className:"".concat(r.prev)}),s=!b&&e.createElement("div",{onClick:function(){return C+1===c.length-1&&h(!0),S(!1),E(C+1)},className:"".concat(r.next)}),u=t.imgContent&&t.textContent||t.imgContent&&!t.textContent?"mine-item_img":!t.imgContent&&t.textContent?t.style:"";return e.createElement("div",{className:"".concat("mine-item"," ").concat(u),style:{transform:"translate(-".concat(100*C,"%)"),width:i||"auto",height:l||"auto"},key:n},m.enabled&&o,t.textContent&&t.imgContent?e.createElement(a,null,e.createElement("div",{className:"mine-item_text-inner_img ".concat(t.innerStyle?t.innerStyle:"")},t.text),e.createElement("img",{src:t.imgUrl,alt:t.alt})):t.textContent&&!t.imgContent?e.createElement("div",{className:t.innerStyle?t.innerStyle:""},t.text):t.imgContent&&!t.textContent?e.createElement("img",{src:t.imgUrl,alt:t.alt}):e.createElement(a,null,e.createElement("p",null,"No data to fetch ...")),m.enabled&&s)})))}),{data:c,config:o}))};export{r as Carousel};