najwer23morsels 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Slidermulti.js +1 -1
- package/package.json +1 -1
package/lib/Slidermulti.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as l,Fragment as i}from"react/jsx-runtime";import r,{useState as t,useRef as n,
|
|
1
|
+
import{jsx as e,jsxs as l,Fragment as i}from"react/jsx-runtime";import r,{useState as t,useRef as n,useLayoutEffect as o}from"react";import{s as d}from"./style-inject.es-BnTDb6vU.js";import{L as s}from"./Loader-CL-mm0LT.js";import{a,I as u}from"./IconArrowRight-Bs6HQ5lc.js";import{B as c}from"./Button-DP1hmI08.js";import{u as m}from"./useWindowSize-CAQRbyxi.js";import{S as h}from"./Slider-Dof_HMMd.js";import"./TextBox-B47QWA9m.js";var S={n23mSliderMulti:"SliderMulti-module_n23mSliderMulti__hsL9a",n23mSliderMultiContainerSlider:"SliderMulti-module_n23mSliderMultiContainerSlider__iu4xy",n23mSliderMultiSlideWrapper:"SliderMulti-module_n23mSliderMultiSlideWrapper__KPiK1",n23mSliderMultiSlide:"SliderMulti-module_n23mSliderMultiSlide__NDrCj",n23mSliderMultiControls:"SliderMulti-module_n23mSliderMultiControls__54jy-",n23mSliderMultiControlsButtons:"SliderMulti-module_n23mSliderMultiControlsButtons__JqcZ5"};d("@layer n23mSliderMulti{.SliderMulti-module_n23mSliderMulti__hsL9a{width:100%}.SliderMulti-module_n23mSliderMultiContainerSlider__iu4xy{display:flex;flex-direction:column;gap:10px;height:100%;position:relative;user-select:none;width:100%}.SliderMulti-module_n23mSliderMultiSlideWrapper__KPiK1{height:100%;overflow:hidden;position:relative;width:100%;will-change:transform}.SliderMulti-module_n23mSliderMultiSlide__NDrCj{height:100%;overflow:hidden;position:absolute;top:0;will-change:transform;&>*{height:100%;width:100%}}.SliderMulti-module_n23mSliderMultiControls__54jy-{align-items:center;display:flex;justify-content:flex-end;margin-left:20px;margin-right:20px}.SliderMulti-module_n23mSliderMultiControlsButtons__JqcZ5{display:flex;gap:10px;margin-top:10px}}");const p=(e,l,i=!1,t)=>(i?e.slice(0,l):e.slice(-l)).map((e,l)=>r.cloneElement(e,{key:`${i?"clone-first":"clone-last"}-${l} ${t}`,className:e.props.className})),g=({isCircular:d=!1,children:g,className:M,showControls:f=!0,loading:x=!1,loaderColor:_="black",slidesPerView:C=4,slideSpacingPx:w=10,slidesToScroll:v=4})=>{const b=r.Children.toArray(g).filter(r.isValidElement),{width:y}=m(),[j,E]=t(0),N=n(null),[F,k]=t(d?2*b.length:0),[T,B]=t(!1),L=n([]),[$,z]=t(null),[W,P]=t(0);o(()=>{let e;const l=()=>{N.current&&E(N.current.offsetWidth),k(d?2*b.length:0)},i=()=>{clearTimeout(e),e=window.setTimeout(l,150)};return l(),window.addEventListener("resize",i),()=>{clearTimeout(e),window.removeEventListener("resize",i)}},[x,d,C,b.length]);let D=C,K=v,A="transform 1.00s cubic-bezier(0.645, 0.045, 0.355, 1)",X=1100;y<767.98?(D=1,K=1,A="transform 0.4s cubic-bezier(.4,0,.2,1)",X=450):y<1199.98&&(D=2,K=2,A="transform 0.85s cubic-bezier(0.645, 0.045, 0.355, 1)",X=900);const q=D>0?(j-w*(D-1))/D:0;let I=d?[...p(b,b.length,!1,1),...p(b,b.length,!1,2),...b,...p(b,b.length,!0,3),...p(b,b.length,!0,4)]:b;o(()=>{L.current.forEach((e,l)=>{if(!e)return;let i=0,r=0;2==D?(i=20,r=20):4==D?(i=10,r=10):3==D&&(i=15,r=15);const t=(l-F)*(q+w-r)+(j-(q-i)*D-w*(D-1))/2;e.style.transition=T?A:"none",e.style.transform=`translateX(${t}px)`})},[F,j,T,I.length,D,q,w,x]),o(()=>{if(!T)return;let e;const l=()=>{let i=F;F<2*D&&d?i=F+2*b.length:F>=2*b.length+D&&d&&(i=F-2*b.length),i!==F&&d&&k(i),B(!1),L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)}),clearTimeout(e)};return L.current.forEach(e=>{e&&e.addEventListener("transitionend",l)}),e=window.setTimeout(()=>{B(!1),L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)})},X),()=>{L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)}),clearTimeout(e)}},[F,d,T,b.length,D,I.length,x]);const J=()=>{T||(B(!0),k(e=>e+K))},V=()=>{T||(B(!0),k(e=>e-K))};return L.current.length!==I.length&&(L.current=Array(I.length).fill(null)),y<767.98?e(h,{children:g,isCircular:d,loading:x}):l("div",{className:[S.n23mSliderMulti,"n23mSliderMulti",M].filter(Boolean).join(" "),style:{height:x?"calc(100% - 2px)":f?"calc(100% - 60px)":"100%"},onTouchStart:e=>{1===e.touches.length&&(z(e.touches[0].clientX),P(0))},onTouchMove:e=>{null!==$&&P(e.touches[0].clientX-$)},onTouchEnd:()=>{W>50?V():W<-50&&J(),z(null),P(0)},children:[x&&e(s,{loaderColor:_}),!x&&l(i,{children:[e("div",{className:[S.n23mSliderMultiContainerSlider].filter(Boolean).join(" "),children:e("div",{className:[S.n23mSliderMultiSlideWrapper,"n23mSliderMultiSlideWrapper"].join(" "),ref:N,style:{display:"flex",gap:`${w}px`,overflow:"hidden",width:"100%",boxSizing:"border-box"},children:I.map((l,i)=>e("div",{ref:e=>{L.current[i]=e},className:S.n23mSliderMultiSlide,style:{width:2==D?`calc(${q}px - 20px)`:3==D?`calc(${q}px - 15px)`:4==D?`calc(${q}px - 10px)`:`${q}px`},"aria-hidden":i<F||i>=F+D,children:l},l.key??i))})}),f&&e("div",{className:[S.n23mSliderMultiControls,"n23mSliderMultiControls"].join(" "),children:l("div",{className:[S.n23mSliderMultiControlsButtons,"n23mSliderMultiControlsButtons"].join(" "),children:[e(c,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Prev",onClick:V,borderColor:"black",backgroundColorDisabled:"#F2F0EF",disabled:T||!d&&0===F,children:e(a,{width:24,height:24})}),e(c,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Next",borderColor:"black",backgroundColorDisabled:"#F2F0EF",onClick:J,disabled:T||!d&&F+D>=b.length,children:e(u,{width:24,height:24})})]})})]})]})};g.displayName="SliderMulti";export{g as SliderMulti};
|