najwer23morsels 0.10.1 → 0.10.2
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/Sliderscroll.js +1 -1
- package/package.json +1 -1
package/lib/Sliderscroll.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as r,jsx as e}from"react/jsx-runtime";import{useRef as l,Children as t,cloneElement as o,useLayoutEffect as n,useEffect as c}from"react";import{B as i}from"./Button-BdJvyN9u.js";import{s}from"./style-inject.es-BnTDb6vU.js";import{u}from"./useWindowSize-CAQRbyxi.js";import{a,I as d}from"./IconArrowRight-Bs6HQ5lc.js";import"./Loader-CL-mm0LT.js";import"./TextBox-B47QWA9m.js";var m={n23mSliderScrollWrapper:"SliderScroll-module_n23mSliderScrollWrapper__MqXIk",n23mSliderScrollTrack:"SliderScroll-module_n23mSliderScrollTrack__FcsTl",dragging:"SliderScroll-module_dragging__iE4mo",n23mSliderScrollControls:"SliderScroll-module_n23mSliderScrollControls__i64nM",n23mSliderScrollControlsButtons:"SliderScroll-module_n23mSliderScrollControlsButtons__W-5rb"};s("@layer n23mSliderScroll{.SliderScroll-module_n23mSliderScrollWrapper__MqXIk{display:grid;position:relative}.SliderScroll-module_n23mSliderScrollTrack__FcsTl{-ms-overflow-style:none;-webkit-overflow-scrolling:touch;display:flex;flex-wrap:nowrap;gap:var(--sliderscroll-gap);overflow-x:scroll;scrollbar-width:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;will-change:scroll-position;&::-webkit-scrollbar{display:none}&>*{flex-shrink:0}&.SliderScroll-module_dragging__iE4mo,&.SliderScroll-module_dragging__iE4mo a{cursor:grabbing}}.SliderScroll-module_n23mSliderScrollControls__i64nM{align-items:center;display:flex;justify-content:flex-end;margin-left:20px;margin-right:20px}.SliderScroll-module_n23mSliderScrollControlsButtons__W-5rb{display:flex;gap:10px;margin-top:10px}}");const f=({children:s,className:f,gap:S="5px",isCircular:p=!1})=>{const g=l(null),h=l(null),_=l(null),w=l(!1),b=l(!1),v=l(!1),x=l(!1),C=t.toArray(s),k=C.length,L=p?C.map((r,e)=>o(r,{key:`clone-before-${e}`})):[],M=p?C.map((r,e)=>o(r,{key:`clone-after-${e}`})):[],F=()=>{if(!g.current||!g.current.firstElementChild)return 0;const r=g.current.firstElementChild,e=getComputedStyle(r);return r.offsetWidth+parseInt(e.marginLeft||"0")+parseInt(e.marginRight||"0")+Number(S.slice(0,-2))},y=()=>{if(g.current){if(p)w.current=!0,b.current=!0;else{const r=g.current.scrollLeft,e=g.current.scrollWidth-g.current.clientWidth;w.current=r>0,b.current=r<e}W(v.current)}},W=r=>{h.current&&(h.current.disabled=r||!w.current),_.current&&(_.current.disabled=r||!b.current)},{width:j}=u();n(()=>{if(p){const r=F();g.current&&r&&(g.current.scrollLeft=r*k-20)}y()},[j,k,S,s,p]);const D=(r,e,l=300)=>{if(v.current)return;v.current=!0,W(!0);const t=r.scrollLeft,o=e-t,n=performance.now(),c=e=>{const i=e-n,s=Math.min(i/l,1);var u;r.scrollLeft=t+o*((u=s)<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2),s<1?requestAnimationFrame(c):(v.current=!1,W(!1),y())};requestAnimationFrame(c)},B=l({isDown:!1,startX:0,scrollLeft:0,isMove:!1}),E=()=>{g.current&&(x.current?g.current.classList.add(m.dragging):g.current.classList.remove(m.dragging))};return c(()=>{W(!1)},[]),
|
|
1
|
+
import{jsxs as r,jsx as e}from"react/jsx-runtime";import{useRef as l,Children as t,cloneElement as o,useLayoutEffect as n,useEffect as c}from"react";import{B as i}from"./Button-BdJvyN9u.js";import{s}from"./style-inject.es-BnTDb6vU.js";import{u}from"./useWindowSize-CAQRbyxi.js";import{a,I as d}from"./IconArrowRight-Bs6HQ5lc.js";import"./Loader-CL-mm0LT.js";import"./TextBox-B47QWA9m.js";var m={n23mSliderScrollWrapper:"SliderScroll-module_n23mSliderScrollWrapper__MqXIk",n23mSliderScrollTrack:"SliderScroll-module_n23mSliderScrollTrack__FcsTl",dragging:"SliderScroll-module_dragging__iE4mo",n23mSliderScrollControls:"SliderScroll-module_n23mSliderScrollControls__i64nM",n23mSliderScrollControlsButtons:"SliderScroll-module_n23mSliderScrollControlsButtons__W-5rb"};s("@layer n23mSliderScroll{.SliderScroll-module_n23mSliderScrollWrapper__MqXIk{display:grid;position:relative}.SliderScroll-module_n23mSliderScrollTrack__FcsTl{-ms-overflow-style:none;-webkit-overflow-scrolling:touch;display:flex;flex-wrap:nowrap;gap:var(--sliderscroll-gap);overflow-x:scroll;scrollbar-width:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;will-change:scroll-position;&::-webkit-scrollbar{display:none}&>*{flex-shrink:0}&.SliderScroll-module_dragging__iE4mo,&.SliderScroll-module_dragging__iE4mo a{cursor:grabbing}}.SliderScroll-module_n23mSliderScrollControls__i64nM{align-items:center;display:flex;justify-content:flex-end;margin-left:20px;margin-right:20px}.SliderScroll-module_n23mSliderScrollControlsButtons__W-5rb{display:flex;gap:10px;margin-top:10px}}");const f=({children:s,className:f,gap:S="5px",isCircular:p=!1})=>{const g=l(null),h=l(null),_=l(null),w=l(!1),b=l(!1),v=l(!1),x=l(!1),C=t.toArray(s),k=C.length,L=p?C.map((r,e)=>o(r,{key:`clone-before-${e}`})):[],M=p?C.map((r,e)=>o(r,{key:`clone-after-${e}`})):[],F=()=>{if(!g.current||!g.current.firstElementChild)return 0;const r=g.current.firstElementChild,e=getComputedStyle(r);return r.offsetWidth+parseInt(e.marginLeft||"0")+parseInt(e.marginRight||"0")+Number(S.slice(0,-2))},y=()=>{if(g.current){if(p)w.current=!0,b.current=!0;else{const r=g.current.scrollLeft,e=g.current.scrollWidth-g.current.clientWidth;w.current=r>0,b.current=r<e}W(v.current)}},W=r=>{h.current&&(h.current.disabled=r||!w.current),_.current&&(_.current.disabled=r||!b.current)},{width:j}=u();n(()=>{if(p){const r=F();g.current&&r&&(g.current.scrollLeft=r*k-20)}y()},[j,k,S,s,p]);const D=(r,e,l=300)=>{if(v.current)return;v.current=!0,W(!0);const t=r.scrollLeft,o=e-t,n=performance.now(),c=e=>{const i=e-n,s=Math.min(i/l,1);var u;r.scrollLeft=t+o*((u=s)<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2),s<1?requestAnimationFrame(c):(v.current=!1,W(!1),y())};requestAnimationFrame(c)},B=l({isDown:!1,startX:0,scrollLeft:0,isMove:!1}),E=()=>{g.current&&(x.current?g.current.classList.add(m.dragging):g.current.classList.remove(m.dragging))};return c(()=>{W(!1)},[]),r("div",{className:["n23mSliderScroll",f].filter(Boolean).join(" "),style:{"--sliderscroll-gap":S,height:"calc(100% - 60px)"},children:[e("div",{className:[m.n23mSliderScrollWrapper,"n23mSliderScrollWrapper"].join(" "),children:r("div",{className:m.n23mSliderScrollTrack,ref:g,onClick:r=>{B.current.isMove&&(r.preventDefault(),r.stopPropagation())},onScroll:()=>{if(g.current){if(p){const r=F();if(!r)return;const e=r*(k+C.length),l=r*k,t=g.current.scrollLeft;t<l-r/2?g.current.scrollLeft=t+r*C.length:t>e+r/2&&(g.current.scrollLeft=t-r*C.length)}y()}},onMouseDown:r=>{B.current.isDown=!0,B.current.startX=r.pageX-(g.current?.offsetLeft||0),B.current.scrollLeft=g.current?.scrollLeft||0,x.current=!0,E()},onMouseLeave:()=>{B.current.isDown&&(B.current.isDown=!1,x.current=!1,E())},onMouseUp:()=>{B.current.isDown=!1,x.current=!1,E()},onMouseMove:r=>{if(!B.current.isDown)return void(B.current.isMove=!1);r.preventDefault();var e;const l=("pageX"in(e=r)?e.pageX:"touches"in e?e.touches[0].pageX:0)-(g.current?.offsetLeft||0)-B.current.startX;Math.abs(l)>5&&(B.current.isMove=!0),g.current&&(g.current.scrollLeft=B.current.scrollLeft-l,y())},children:[p&&L,C,p&&M]})}),e("div",{className:[m.n23mSliderScrollControls,"n23mSliderScrollControls"].join(" "),children:r("div",{className:[m.n23mSliderScrollControlsButtons,"n23mSliderScrollControlsButtons"].join(" "),children:[e(i,{ref:h,height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Prev",onClick:()=>{if(!g.current)return;const r=F();if(0===r)return;const e=Math.floor(g.current.offsetWidth/r)*r;let l=g.current.scrollLeft-e;p||(l=Math.max(l,0)),D(g.current,l,600)},borderColor:"black",backgroundColorDisabled:"#F2F0EF",children:e(a,{width:24,height:24})}),e(i,{ref:_,height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Next",onClick:()=>{if(!g.current)return;const r=F();if(0===r)return;const e=Math.floor(g.current.offsetWidth/r)*r;let l=g.current.scrollLeft+e;if(!p){const r=g.current.scrollWidth-g.current.clientWidth;l=Math.min(l,r)}D(g.current,l,600)},borderColor:"black",backgroundColorDisabled:"#F2F0EF",children:e(d,{width:24,height:24})})]})})]})};f.displayName="SliderScroll";export{f as SliderScroll};
|