lazer-slider 1.1.6 → 1.1.7
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/dist/index.cjs +2 -2
- package/dist/index.d.cts +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +2 -2
- package/dist/lazer-slider.css +282 -243
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var O=e=>e===1?1:1-Math.pow(2,-10*e),
|
|
1
|
+
'use strict';var C={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},Ee="(min-width: 64rem)",O=()=>window.matchMedia(Ee).matches;var N=e=>e===1?1:1-Math.pow(2,-10*e),H=e=>1-Math.pow(1-e,3),ye=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Le=e=>1-(1-e)*(1-e),ge=e=>e;var Ae=()=>`slider-${Math.random().toString(36).substring(2,9)}`,ee=e=>{let{feed:t,prevSlideButton:o,nextSlideButton:l,thumbs:r,slides:a}=e;t.id||(t.id=Ae()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),a.forEach((i,s)=>{i.setAttribute("role","group"),i.setAttribute("aria-roledescription","slide"),i.setAttribute("aria-label",`Slide ${s+1} of ${a.length}`);}),o&&(o.setAttribute("aria-label","Previous slide"),o.setAttribute("aria-controls",t.id),o.setAttribute("tabindex","0"),o.tagName!=="BUTTON"&&o.setAttribute("role","button")),l&&(l.setAttribute("aria-label","Next slide"),l.setAttribute("aria-controls",t.id),l.setAttribute("tabindex","0"),l.tagName!=="BUTTON"&&l.setAttribute("role","button")),r?.length&&r.forEach((i,s)=>{i.tagName!=="BUTTON"&&i.setAttribute("role","button"),i.setAttribute("aria-label",`Go to slide ${s+1}`),i.setAttribute("tabindex","0"),i.setAttribute("aria-controls",t.id);});},z=(e,t,o)=>{if(!e)return;!t&&e===document.activeElement&&o&&o.focus();let l="opacity 0.3s ease",r=t?"1":"0";Object.assign(e.style,{opacity:r,transition:l,pointerEvents:t?"auto":"none"}),t?(e.removeAttribute("aria-hidden"),e.setAttribute("tabindex","0")):(e.setAttribute("aria-hidden","true"),e.setAttribute("tabindex","-1")),t?e.style.visibility="visible":setTimeout(()=>{e.style.opacity==="0"&&(e.style.visibility="hidden");},300);},F=(e,t,o="active")=>{e?.length&&e.forEach((l,r)=>{let a=r===t;l.classList.toggle(o,a),l.setAttribute("aria-selected",a.toString());});},te=(e,t,o,l,r="horizontal")=>{let a=r==="vertical",i=a?"ArrowUp":"ArrowLeft",s=a?"ArrowDown":"ArrowRight";e.addEventListener("keydown",m=>{switch(m.key){case i:m.preventDefault(),t();break;case s:m.preventDefault(),o();break}},{signal:l}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var g={FRICTION:.94,MIN_VELOCITY:.3,MOMENTUM_RATIO:.8,VELOCITY_SMOOTHING:.4,EDGE_RESISTANCE:.3,MAX_EDGE_OVERSCROLL:100,SHORT_SWIPE_VELOCITY:.5,BOUNCE_DURATION:400},Me=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),xe=()=>({...Me(),velocityHistory:[],dragDistance:0,dragStartTime:0}),$=(e,t,o="horizontal")=>{let l=e.getBoundingClientRect(),r=o==="vertical",a=r?l.top:l.left,i=null,s=1/0;for(let m of t){if(m.offsetParent===null)continue;let u=m.getBoundingClientRect(),h=r?u.top:u.left,n=Math.abs(a-h);n<s&&(s=n,i=m);}return i},Ie=(e,t,o,l="horizontal")=>{let r=e.getBoundingClientRect(),a=l==="vertical",i=a?r.top:r.left,s=t.filter(d=>d.offsetParent!==null);if(s.length===0)return null;let m=0,u=1/0;s.forEach((d,v)=>{let b=d.getBoundingClientRect(),P=a?b.top:b.left,I=Math.abs(i-P);I<u&&(u=I,m=v);});let h=2,n=m;return Math.abs(o)>h&&(o>0?n=Math.min(m+1,s.length-1):n=Math.max(m-1,0)),s[n]??null},De=e=>{if(e.length===0)return 0;let t=0,o=0;return e.forEach((l,r)=>{let a=r+1;t+=l*a,o+=a;}),t/o},Ce=(e,t,o,l,r,a="horizontal",i=false)=>{let s=a==="vertical",m=e.velocity*g.MOMENTUM_RATIO,u=()=>{if(Math.abs(m)<g.MIN_VELOCITY){e.momentumId=null;let v=$(t,o,a);if(v){let b=s?v.offsetTop:v.offsetLeft;l(b,H);}r?.(v);return}let h=s?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,d=(s?t.scrollTop:t.scrollLeft)+m;i||(d<0||d>h)&&(m*=.5),s?t.scrollTop=Math.max(0,Math.min(h,d)):t.scrollLeft=Math.max(0,Math.min(h,d)),m*=g.FRICTION,e.momentumId=requestAnimationFrame(u);};e.momentumId=requestAnimationFrame(u);},re=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,oe=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,He=(e,t)=>t==="vertical"?oe(e):re(e),le=e=>{let {feed:t,slides:o,abortSignal:l,smoothScrollTo:r,onDragEnd:a,direction:i="horizontal",loop:s=false,touchRatio:m=1,shortSwipeThreshold:u=300,swipeDistanceThreshold:h=10}=e,n=xe(),d=i==="vertical",v=0,P=()=>{v=d?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,d?t.clientHeight:t.clientWidth;},I=L=>{n.momentumId!==null&&(cancelAnimationFrame(n.momentumId),n.momentumId=null),P(),n.isDragging=true,n.startX=re(L),n.startY=oe(L),n.startScrollLeft=t.scrollLeft,n.startScrollTop=t.scrollTop,n.velocity=0,n.lastX=n.startX,n.lastY=n.startY,n.lastTime=performance.now(),n.velocityHistory=[],n.dragDistance=0,n.dragStartTime=performance.now(),t.style.userSelect="none",t.style.cursor="grabbing",t.classList.add("is-dragging"),L.type==="mousedown"&&L.preventDefault();},q=L=>{if(!n.isDragging)return;let A=He(L,i),R=d?n.startY:n.startX,E=d?n.lastY:n.lastX,M=d?n.startScrollTop:n.startScrollLeft,c=performance.now(),f=c-n.lastTime,T=(R-A)*m,S=M+T;if(n.dragDistance=Math.abs(T),!s){if(S<0){let p=Math.abs(S),y=1-Math.min(p/g.MAX_EDGE_OVERSCROLL,1)*(1-g.EDGE_RESISTANCE);S=-p*y;}else if(S>v){let p=S-v,y=1-Math.min(p/g.MAX_EDGE_OVERSCROLL,1)*(1-g.EDGE_RESISTANCE);S=v+p*y;}}if(d?t.scrollTop=S:t.scrollLeft=S,f>0){let p=(E-A)/f*16;if(n.velocityHistory.length>0){let y=n.velocity;n.velocity=y*(1-g.VELOCITY_SMOOTHING)+p*g.VELOCITY_SMOOTHING;}else n.velocity=p;n.velocityHistory.push(p),n.velocityHistory.length>5&&n.velocityHistory.shift();}d?n.lastY=A:n.lastX=A,n.lastTime=c,L.type==="touchmove"&&L.preventDefault();},w=()=>{if(!n.isDragging)return;n.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let A=performance.now()-n.dragStartTime<u&&n.dragDistance>h,R=De(n.velocityHistory);if(!s){let E=d?t.scrollTop:t.scrollLeft;if(E<0||E>v){let M=E<0?0:v,c=E,f=performance.now(),T=()=>{let S=performance.now()-f,p=Math.min(S/g.BOUNCE_DURATION,1),y=H(p),B=c+(M-c)*y;if(d?t.scrollTop=B:t.scrollLeft=B,p<1)requestAnimationFrame(T);else {let D=$(t,o,i);if(D){let x=d?D.offsetTop:D.offsetLeft;r(x,H);}a?.(D);}};requestAnimationFrame(T);return}}if(A||Math.abs(R)>g.SHORT_SWIPE_VELOCITY){let E=Ie(t,o,R,i);if(E){let M=d?E.offsetTop:E.offsetLeft;r(M,H),a?.(E);}else a?.(null);}else if(Math.abs(n.velocity)>1)Ce(n,t,o,r,a,i,s);else {let E=$(t,o,i);if(E){let M=d?E.offsetTop:E.offsetLeft;r(M,H);}a?.(E);}};return t.addEventListener("mousedown",I,{signal:l}),document.addEventListener("mousemove",q,{signal:l}),document.addEventListener("mouseup",w,{signal:l}),t.addEventListener("touchstart",I,{passive:true,signal:l}),t.addEventListener("touchmove",q,{passive:false,signal:l}),t.addEventListener("touchend",w,{signal:l}),t.addEventListener("touchcancel",w,{signal:l}),document.addEventListener("mouseleave",w,{signal:l}),t.style.cursor="grab",n},ie=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var G=({bulletsContainer:e,slides:t,bulletClass:o,bulletActiveClass:l,feedId:r})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid bulletsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!r||typeof r!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!o||typeof o!="string")throw new Error("Invalid bulletClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide navigation");let a=t.map((s,m)=>({slide:s,originalIndex:m})).filter(({slide:s})=>s.offsetParent!==null);return a.length===0?(console.warn("No visible slides found"),[]):a.map(({slide:s,originalIndex:m},u)=>{let h=document.createElement("button");return h.type="button",h.classList.add(o),u===0&&h.classList.add(l),h.setAttribute("role","tab"),h.setAttribute("aria-selected",u===0?"true":"false"),h.setAttribute("aria-controls",r),h.setAttribute("aria-label",`Go to slide ${u+1}`),h.setAttribute("data-slide-index",String(u)),e.appendChild(h),h})};var X=({thumbsContainer:e,slides:t,thumbClass:o,thumbActiveClass:l,feedId:r,thumbImageSelector:a="img",thumbSize:i})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid thumbsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!r||typeof r!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!o||typeof o!="string")throw new Error("Invalid thumbClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide thumbnails");let s=t.map((u,h)=>({slide:u,originalIndex:h})).filter(({slide:u})=>u.offsetParent!==null);return s.length===0?(console.warn("No visible slides found"),[]):s.map(({slide:u,originalIndex:h},n)=>{let d=document.createElement("button");d.type="button",d.classList.add(o),n===0&&d.classList.add(l);let v=u.querySelector(a);if(v?.src){let b=document.createElement("img");b.src=v.src,b.alt=v.alt||`Slide ${n+1} thumbnail`,b.draggable=false,i&&(b.style.width=`${i.width}px`,b.style.height=`${i.height}px`,b.style.objectFit="cover"),d.appendChild(b);}return d.setAttribute("role","tab"),d.setAttribute("aria-selected",n===0?"true":"false"),d.setAttribute("aria-controls",r),d.setAttribute("aria-label",`Go to slide ${n+1}`),d.setAttribute("data-slide-index",String(n)),e.appendChild(d),d})};var ne=()=>({initialized:false,clonedSlides:[],styleElement:null}),ae=()=>{let e=document.getElementById("lazer-marquee-keyframes");if(e)return e;let t=document.createElement("style");return t.id="lazer-marquee-keyframes",t.textContent=`
|
|
2
2
|
@keyframes lazer-marquee-scroll {
|
|
3
3
|
0% {
|
|
4
4
|
transform: translateX(0);
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
transform: translateX(-50%);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
`,document.head.appendChild(r),r},Le=(e,r)=>{r.initialized||(r.styleElement=oe(),e.feed.style.display="flex",e.feed.style.willChange="transform",e.slides.forEach(o=>{let t=o.cloneNode(true);t.setAttribute("data-lazer-marquee-clone","true"),t.setAttribute("aria-hidden","true"),e.feed.appendChild(t),r.clonedSlides.push(t);}),r.initialized=true);},ie=e=>{e.initialized&&(e.clonedSlides.forEach(r=>{r.remove();}),e.clonedSlides=[],e.initialized=false);},Ae=(e,r)=>{oe(),requestAnimationFrame(()=>{let o=e.feed.scrollWidth,t=e.marqueeSpeed??50,u=e.marqueeDirection??"left",n=o/2;if(n<=0||t<=0){console.warn("[lazer-slider] Invalid marquee values:",{distance:n,speed:t,scrollWidth:o});return}let S=`lazer-marquee-scroll ${n/t}s linear infinite ${u==="right"?"reverse":"normal"}`;e.feed.style.animation="none",e.feed.offsetWidth,e.feed.style.animation=S,e.feed.style.animationPlayState=r.marqueePaused?"paused":"running";});},F=(e,r)=>{Ae(e,r);},ne=(e,r)=>{r.feed.style.animation="",r.feed.style.animationPlayState="",r.feed.style.transform="",r.feed.style.willChange="";},R=(e,r)=>{e.marqueePaused=true,r.feed.style.animationPlayState="paused";},z=(e,r)=>{e.marqueePaused=false,r.feed.style.animationPlayState="running";},ae=(e,r,o)=>{e.marquee&&(Le(e,o),F(e,r));},de=(e,r,o)=>{!e.marquee||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>R(r,e),{signal:o}),e.feed.addEventListener("mouseleave",()=>z(r,e),{signal:o}),e.feed.addEventListener("touchstart",()=>R(r,e),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>z(r,e),{signal:o}));};var H={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},xe="(min-width: 64rem)",Me=e=>{if(!e.feed)throw new Error("lazer-slider: feed element is required");if(!e.slides?.length)throw new Error("lazer-slider: slides array is required and must not be empty");if(e.feed.id||(e.feed.id=`lazer-slider-feed-${Math.random().toString(36).substr(2,9)}`),e.bulletsContainer&&!e.thumbs){let l=k({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=l;}if(e.thumbsContainer&&!e.thumbs){let l=$({thumbsContainer:e.thumbsContainer,slides:e.slides,thumbClass:e.thumbsClass??"slider-thumb",thumbActiveClass:e.thumbsActiveClass??"active",feedId:e.feed.id,thumbImageSelector:e.thumbImageSelector??"img",thumbSize:e.thumbSize});e.thumbs=l;}let r=e.direction??"horizontal",o=r==="vertical",t={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,marqueePaused:false,isLoopRepositioning:false},u=null,n={initialized:false,clonedSlides:[],realSlides:[...e.slides],clonesPerSide:0},f=le(),i=e.easing??O,S=()=>{let l=o?e.feed.clientHeight:e.feed.clientWidth;return (!t.cachedFeedRect||t.lastWidth!==l)&&(t.cachedFeedRect=e.feed.getBoundingClientRect(),t.lastWidth=l),t.cachedFeedRect},h=()=>e.slides.filter(l=>l.offsetParent!==null),p=()=>window.matchMedia(xe).matches,b=()=>{let l=p()?e.desktopSlidesPerView:e.mobileSlidesPerView;return !l||l==="auto"?1:Math.ceil(l)},m=()=>{if(!e.loop||n.initialized)return;let l=n.realSlides,d=b();n.clonesPerSide=d;for(let c=l.length-d;c<l.length;c++){let a=l[c];if(!a)continue;let s=a.cloneNode(true);s.setAttribute("data-lazer-clone","prepend"),s.setAttribute("aria-hidden","true"),e.feed.insertBefore(s,e.feed.firstChild),n.clonedSlides.push(s);}for(let c=0;c<d;c++){let a=l[c];if(!a)continue;let s=a.cloneNode(true);s.setAttribute("data-lazer-clone","append"),s.setAttribute("aria-hidden","true"),e.feed.appendChild(s),n.clonedSlides.push(s);}requestAnimationFrame(()=>{let c=l[0];c&&(o?e.feed.scrollTop=c.offsetTop:e.feed.scrollLeft=c.offsetLeft);}),n.initialized=true;},T=l=>{if(!e.loop||!n.initialized)return;t.isLoopRepositioning=true;let d=n.realSlides,c=d.length;if(l==="next"){let a=d[0];a&&(o?e.feed.scrollTop=a.offsetTop:e.feed.scrollLeft=a.offsetLeft),t.currentSlideIndex=0;}else {let a=d[c-1];a&&(o?e.feed.scrollTop=a.offsetTop:e.feed.scrollLeft=a.offsetLeft),t.currentSlideIndex=c-1;}requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.isLoopRepositioning=false,q();});});},v=()=>{n.initialized&&(n.clonedSlides.forEach(l=>{l.remove();}),n.clonedSlides=[],n.initialized=false,n.clonesPerSide=0);},A=()=>{let l=p()?e.desktopSlidesPerView:e.mobileSlidesPerView,d=e.slideGap??0;if(d>0&&(e.feed.style.gap=`${d}px`),!l||l==="auto"){e.slides.forEach(s=>{s.style.flex="",s.style.minWidth="",s.style.minHeight="";});return}let a=`calc((100% - ${d*(l-1)}px) / ${l})`;o?e.slides.forEach(s=>{s.style.flex=`0 0 ${a}`,s.style.minHeight=a,s.style.minWidth="";}):e.slides.forEach(s=>{s.style.flex=`0 0 ${a}`,s.style.minWidth=a,s.style.minHeight="";});},E=()=>{if(!e.scrollbarThumb)return;let l=S();if(o){let d=l.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${d}%`,e.scrollbarThumb.style.width="";}else {let d=l.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${d}%`,e.scrollbarThumb.style.height="";}},x=()=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(o){let l=e.scrollbarTrack.getBoundingClientRect().height,d=e.scrollbarThumb.getBoundingClientRect().height,c=l-d,a=e.feed.scrollHeight-e.feed.clientHeight,s=a>0?e.feed.scrollTop/a:0;e.scrollbarThumb.style.transform=`translateY(${c*s}px)`;}else {let l=e.scrollbarTrack.getBoundingClientRect().width,d=e.scrollbarThumb.getBoundingClientRect().width,c=l-d,a=e.feed.scrollWidth-e.feed.clientWidth,s=a>0?e.feed.scrollLeft/a:0;e.scrollbarThumb.style.transform=`translateX(${c*s}px)`;}},q=()=>{if(t.isLoopRepositioning)return;let l=S(),d,c,a;if(o?(d=e.feed.scrollTop<=1,c=e.feed.scrollTop+l.height>=e.feed.scrollHeight-1,a=e.feed.scrollHeight<=l.height):(d=e.feed.scrollLeft<=1,c=e.feed.scrollLeft+l.width>=e.feed.scrollWidth-1,a=e.feed.scrollWidth<=l.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=a?"none":"block"),e.loop){C(e.prevSlideButton,!a,e.feed),C(e.nextSlideButton,!a,e.feed);return}C(e.prevSlideButton,!d&&!a,e.feed),C(e.nextSlideButton,!c&&!a,e.feed);},B=()=>{let l=S(),d=n.initialized?n.realSlides:h(),c=d.filter(a=>{let s=a.getBoundingClientRect(),y=20;return o?s.bottom>l.top+y&&s.top<l.bottom-y:s.right>l.left+y&&s.left<l.right-y});if(c.length&&c[0]){let a=d.indexOf(c[0]);if(a!==-1){t.currentSlideIndex=a;let s=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:s,currentSlideIndex:t.currentSlideIndex});}}},M=(l,d=i,c)=>{let a=o?e.feed.scrollTop:e.feed.scrollLeft,s=Math.abs(l-a),y=Math.min(H.MAX_DURATION,Math.max(H.MIN_DURATION,s/H.SPEED_FACTOR)),N=performance.now(),g=I=>{let w=(I-N)/y,G=Math.min(w,1),he=d(G),j=a+(l-a)*he;o?e.feed.scrollTop=j:e.feed.scrollLeft=j,G<1?requestAnimationFrame(g):(o?e.feed.scrollTop=l:e.feed.scrollLeft=l,c?.());};requestAnimationFrame(g);},se=l=>{if(!e.thumbs)return;let d=e.thumbs.indexOf(l);if(d===-1||!e.slides[d])return;t.currentSlideIndex=d,D(e.thumbs,d),t.isScrolling=true,t.updateThumbTimeout&&clearTimeout(t.updateThumbTimeout),t.updateThumbTimeout=setTimeout(()=>{t.isScrolling=false;},H.THUMB_UPDATE_DELAY);let c=o?e.slides[d].offsetTop:e.slides[d].offsetLeft;M(c);},L=l=>{let d=n.initialized?n.realSlides:h(),c=p()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,a=d.length;B();let s,y=false;if(l==="prev")if(e.loop&&n.initialized&&t.currentSlideIndex===0){let I=n.clonedSlides.filter(w=>w.getAttribute("data-lazer-clone")==="prepend");s=I[I.length-1],y=true;}else t.currentSlideIndex=Math.max(0,t.currentSlideIndex-c),s=d[t.currentSlideIndex];else e.loop&&n.initialized&&t.currentSlideIndex>=a-1?(s=n.clonedSlides.filter(w=>w.getAttribute("data-lazer-clone")==="append")[0],y=true):(t.currentSlideIndex=Math.min(a-1,t.currentSlideIndex+c),s=d[t.currentSlideIndex]);if(!s)return;let N=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:N,target:s,direction:l});let g=o?s.offsetTop:s.offsetLeft;y?M(g,i,()=>{T(l);}):M(g);},ce=()=>{x(),q(),B(),t.isScrolling||D(e.thumbs,t.currentSlideIndex),t.scrollEndTimeout&&clearTimeout(t.scrollEndTimeout),t.scrollEndTimeout=setTimeout(()=>{t.isScrolling=false;let l=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:l,currentSlideIndex:t.currentSlideIndex});},H.SCROLL_END_DELAY);},ue=()=>{t.ticking||(requestAnimationFrame(()=>{ce(),t.ticking=false;}),t.ticking=true);},W=()=>{t.cachedFeedRect=null,U();},fe=()=>{let{signal:l}=t.abortController;window.addEventListener("resize",W),e.feed.addEventListener("scroll",ue,{passive:true,signal:l}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>L("prev"),{signal:l}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>L("next"),{signal:l}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(d=>{d.addEventListener("click",()=>se(d),{signal:l});})),Q(e.feed,()=>L("prev"),()=>L("next"),l,r),e.enableDragToScroll!==false&&(u=te({feed:e.feed,slides:e.slides,abortSignal:l,smoothScrollTo:M,onDragEnd:()=>{B(),D(e.thumbs,t.currentSlideIndex);},direction:r})),e.autoplay&&e.pauseOnHover!==false&&(e.feed.addEventListener("mouseenter",Y,{signal:l}),e.feed.addEventListener("mouseleave",_,{signal:l}),e.feed.addEventListener("touchstart",Y,{passive:true,signal:l}),e.feed.addEventListener("touchend",_,{signal:l})),de(e,t,l);},V=()=>{if(t.autoplayIntervalId)return;let l=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||L("next");},l);},X=()=>{t.autoplayIntervalId&&(clearInterval(t.autoplayIntervalId),t.autoplayIntervalId=null);},Y=()=>{t.autoplayPaused=true;},_=()=>{t.autoplayPaused=false;},me=l=>{let d=n.initialized?n.realSlides:h(),c=Math.max(0,Math.min(l,d.length-1)),a=d[c];if(!a)return;t.currentSlideIndex=c,D(e.thumbs,c);let s=o?a.offsetTop:a.offsetLeft;M(s);},U=()=>{t.cachedFeedRect=null,A(),E(),q(),e.marquee&&!t.marqueePaused&&F(e,t);},pe=()=>{X(),ne(t,e),t.abortController.abort(),window.removeEventListener("resize",W),t.updateThumbTimeout&&clearTimeout(t.updateThumbTimeout),t.scrollEndTimeout&&clearTimeout(t.scrollEndTimeout),u&&re(u),v(),ie(f),t.cachedFeedRect=null;};return K(e),A(),e.marquee?ae(e,t,f):(m(),e.autoplay&&V()),q(),fe(),E(),{goToIndex:me,refresh:U,unload:pe,play:()=>{e.marquee?t.marqueePaused?z(t,e):F(e,t):e.autoplay&&V();},pause:()=>{e.marquee?R(t,e):X();},next:()=>L("next"),prev:()=>L("prev")}};exports.createSlider=Me;exports.easeInOutCubic=Se;exports.easeOutCubic=P;exports.easeOutExpo=O;exports.easeOutQuad=be;exports.generateBullets=k;exports.generateThumbs=$;exports.linear=ve;
|
|
10
|
+
`,document.head.appendChild(t),t},we=(e,t)=>{t.initialized||(t.styleElement=ae(),e.feed.style.display="flex",e.feed.style.willChange="transform",e.slides.forEach(o=>{let l=o.cloneNode(true);l.setAttribute("data-lazer-marquee-clone","true"),l.setAttribute("aria-hidden","true"),e.feed.appendChild(l),t.clonedSlides.push(l);}),t.initialized=true);},se=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false);},Re=(e,t)=>{ae(),requestAnimationFrame(()=>{let o=e.feed.scrollWidth,l=e.marqueeSpeed??50,r=e.marqueeDirection??"left",a=o/2;if(a<=0||l<=0){console.warn("[lazer-slider] Invalid marquee values:",{distance:a,speed:l,scrollWidth:o});return}let m=`lazer-marquee-scroll ${a/l}s linear infinite ${r==="right"?"reverse":"normal"}`;e.feed.style.animation="none",e.feed.offsetWidth,e.feed.style.animation=m,e.feed.style.animationPlayState=t.marqueePaused?"paused":"running";});},V=(e,t)=>{Re(e,t);},ce=(e,t)=>{t.feed.style.animation="",t.feed.style.animationPlayState="",t.feed.style.transform="",t.feed.style.willChange="";},_=(e,t)=>{e.marqueePaused=true,t.feed.style.animationPlayState="paused";},k=(e,t)=>{e.marqueePaused=false,t.feed.style.animationPlayState="running";},de=(e,t,o)=>{e.marquee&&(we(e,o),V(e,t));},ue=(e,t,o)=>{!e.marquee||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>_(t,e),{signal:o}),e.feed.addEventListener("mouseleave",()=>k(t,e),{signal:o}),e.feed.addEventListener("touchstart",()=>_(t,e),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>k(t,e),{signal:o}));};var me=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0}),Oe=e=>{let t=O()?e.desktopSlidesPerView:e.mobileSlidesPerView;return !t||t==="auto"?1:Math.ceil(t)},fe=(e,t,o)=>{if(!e.loop||t.initialized)return;let l=t.realSlides,r=Oe(e);t.clonesPerSide=r;for(let a=l.length-r;a<l.length;a++){let i=l[a];if(!i)continue;let s=i.cloneNode(true);s.setAttribute("data-lazer-clone","prepend"),s.setAttribute("aria-hidden","true"),e.feed.insertBefore(s,e.feed.firstChild),t.clonedSlides.push(s);}for(let a=0;a<r;a++){let i=l[a];if(!i)continue;let s=i.cloneNode(true);s.setAttribute("data-lazer-clone","append"),s.setAttribute("aria-hidden","true"),e.feed.appendChild(s),t.clonedSlides.push(s);}requestAnimationFrame(()=>{let a=l[0];a&&(o?e.feed.scrollTop=a.offsetTop:e.feed.scrollLeft=a.offsetLeft);}),t.initialized=true;},U=(e,t,o,l,r,a,i)=>{if(!t.loop||!o.initialized)return;a(true);let s=o.realSlides,m=s.length;if(e==="next"){let u=s[0];u&&(l?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),r(0);}else {let u=s[m-1];u&&(l?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),r(m-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{a(false),i();});});},pe=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0);};var j=(e,t,o)=>{if(t.autoplayIntervalId)return;let l=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||o("next");},l);},K=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},Se=e=>{e.autoplayPaused=true;},he=e=>{e.autoplayPaused=false;},be=(e,t,o)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>Se(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>he(t),{signal:o}),e.feed.addEventListener("touchstart",()=>Se(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>he(t),{signal:o}));};var Q=(e,t,o)=>{if(e.scrollbarThumb)if(o){let l=t.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${l}%`,e.scrollbarThumb.style.width="";}else {let l=t.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${l}%`,e.scrollbarThumb.style.height="";}},Te=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let o=e.scrollbarTrack.getBoundingClientRect().height,l=e.scrollbarThumb.getBoundingClientRect().height,r=o-l,a=e.feed.scrollHeight-e.feed.clientHeight,i=a>0?e.feed.scrollTop/a:0;e.scrollbarThumb.style.transform=`translateY(${r*i}px)`;}else {let o=e.scrollbarTrack.getBoundingClientRect().width,l=e.scrollbarThumb.getBoundingClientRect().width,r=o-l,a=e.feed.scrollWidth-e.feed.clientWidth,i=a>0?e.feed.scrollLeft/a:0;e.scrollbarThumb.style.transform=`translateX(${r*i}px)`;}};var J=(e,t,o,l=N,r)=>{let a=o?e.scrollTop:e.scrollLeft,i=Math.abs(t-a),s=Math.min(C.MAX_DURATION,Math.max(C.MIN_DURATION,i/C.SPEED_FACTOR)),m=performance.now(),u=h=>{let n=(h-m)/s,d=Math.min(n,1),v=l(d),b=a+(t-a)*v;o?e.scrollTop=b:e.scrollLeft=b,d<1?requestAnimationFrame(u):(o?e.scrollTop=t:e.scrollLeft=t,r?.());};requestAnimationFrame(u);},W=e=>e.filter(t=>t.offsetParent!==null),Z=(e,t,o)=>{let l=o?e.desktopSlidesPerView:e.mobileSlidesPerView,r=e.slideGap??0;if(r>0&&(e.feed.style.gap=`${r}px`),!l||l==="auto"){e.slides.forEach(s=>{s.style.flex="",s.style.minWidth="",s.style.minHeight="";});return}let i=`calc((100% - ${r*(l-1)}px) / ${l})`;t?e.slides.forEach(s=>{s.style.flex=`0 0 ${i}`,s.style.minHeight=i,s.style.minWidth="";}):e.slides.forEach(s=>{s.style.flex=`0 0 ${i}`,s.style.minWidth=i,s.style.minHeight="";});},ve=(e,t,o,l)=>{let r=l?e.clientHeight:e.clientWidth;return !t||o!==r?{rect:e.getBoundingClientRect(),size:r}:{rect:t,size:o}};var Pe=e=>{if(!e.feed)throw new Error("lazer-slider: feed element is required");if(!e.slides?.length)throw new Error("lazer-slider: slides array is required and must not be empty");if(e.feed.id||(e.feed.id=`lazer-slider-feed-${Math.random().toString(36).substr(2,9)}`),e.bulletsContainer&&!e.thumbs){let c=G({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=c;}if(e.thumbsContainer&&!e.thumbs){let c=X({thumbsContainer:e.thumbsContainer,slides:e.slides,thumbClass:e.thumbsClass??"slider-thumb",thumbActiveClass:e.thumbsActiveClass??"active",feedId:e.feed.id,thumbImageSelector:e.thumbImageSelector??"img",thumbSize:e.thumbSize});e.thumbs=c;}let t=e.direction??"horizontal",o=t==="vertical",l=e.easing??N,r={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,marqueePaused:false,isLoopRepositioning:false},a=null,i=me(e.slides),s=ne(),m=()=>{let c=ve(e.feed,r.cachedFeedRect,r.lastWidth,o);return r.cachedFeedRect=c.rect,r.lastWidth=c.size,c.rect},u=(c,f)=>{J(e.feed,c,o,l,f);},h=(c,f)=>{J(e.feed,c,o,f??l);},n=()=>{if(r.isLoopRepositioning)return;let c=m(),f,T,S;if(o?(f=e.feed.scrollTop<=1,T=e.feed.scrollTop+c.height>=e.feed.scrollHeight-1,S=e.feed.scrollHeight<=c.height):(f=e.feed.scrollLeft<=1,T=e.feed.scrollLeft+c.width>=e.feed.scrollWidth-1,S=e.feed.scrollWidth<=c.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=S?"none":"block"),e.loop){z(e.prevSlideButton,!S,e.feed),z(e.nextSlideButton,!S,e.feed);return}z(e.prevSlideButton,!f&&!S,e.feed),z(e.nextSlideButton,!T&&!S,e.feed);},d=()=>{let c=m(),f=i.initialized?i.realSlides:W(e.slides),T=f.filter(S=>{let p=S.getBoundingClientRect(),y=20;return o?p.bottom>c.top+y&&p.top<c.bottom-y:p.right>c.left+y&&p.left<c.right-y});if(T.length&&T[0]){let S=f.indexOf(T[0]);if(S!==-1){r.currentSlideIndex=S;let p=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:p,currentSlideIndex:r.currentSlideIndex});}}},v=c=>{if(!e.thumbs)return;let f=e.thumbs.indexOf(c);if(f===-1||!e.slides[f])return;r.currentSlideIndex=f,F(e.thumbs,f),r.isScrolling=true,r.updateThumbTimeout&&clearTimeout(r.updateThumbTimeout),r.updateThumbTimeout=setTimeout(()=>{r.isScrolling=false;},C.THUMB_UPDATE_DELAY);let T=o?e.slides[f].offsetTop:e.slides[f].offsetLeft;u(T);},b=c=>{let f=i.initialized?i.realSlides:W(e.slides),T=O()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,S=f.length;d();let p,y=false;if(c==="prev")if(e.loop&&i.initialized&&r.currentSlideIndex===0){let x=i.clonedSlides.filter(Y=>Y.getAttribute("data-lazer-clone")==="prepend");p=x[x.length-1],y=true;}else r.currentSlideIndex=Math.max(0,r.currentSlideIndex-T),p=f[r.currentSlideIndex];else e.loop&&i.initialized&&r.currentSlideIndex>=S-1?(p=i.clonedSlides.filter(Y=>Y.getAttribute("data-lazer-clone")==="append")[0],y=true):(r.currentSlideIndex=Math.min(S-1,r.currentSlideIndex+T),p=f[r.currentSlideIndex]);if(!p)return;let B=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:B,target:p,direction:c});let D=o?p.offsetTop:p.offsetLeft;y?u(D,()=>{U(c,e,i,o,x=>{r.currentSlideIndex=x;},x=>{r.isLoopRepositioning=x;},n);}):u(D);},P=()=>{Te(e,o),n(),d(),r.isScrolling||F(e.thumbs,r.currentSlideIndex),r.scrollEndTimeout&&clearTimeout(r.scrollEndTimeout),r.scrollEndTimeout=setTimeout(()=>{r.isScrolling=false;let c=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:c,currentSlideIndex:r.currentSlideIndex});},C.SCROLL_END_DELAY);},I=()=>{r.ticking||(requestAnimationFrame(()=>{P(),r.ticking=false;}),r.ticking=true);},q=()=>{r.cachedFeedRect=null,A();},w=()=>{let{signal:c}=r.abortController;window.addEventListener("resize",q),e.feed.addEventListener("scroll",I,{passive:true,signal:c}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>b("prev"),{signal:c}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>b("next"),{signal:c}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(f=>{f.addEventListener("click",()=>v(f),{signal:c});})),te(e.feed,()=>b("prev"),()=>b("next"),c,t),e.enableDragToScroll!==false&&(a=le({feed:e.feed,slides:e.slides,abortSignal:c,smoothScrollTo:h,onDragEnd:f=>{if(f&&e.loop&&i.initialized){let T=f.getAttribute("data-lazer-clone");if(T){let S=T==="append"?"next":"prev";setTimeout(()=>{U(S,e,i,o,p=>{r.currentSlideIndex=p;},p=>{r.isLoopRepositioning=p;},n);},50);}}d(),F(e.thumbs,r.currentSlideIndex);},direction:t,loop:e.loop})),be(e,r,c),ue(e,r,c);},L=c=>{let f=i.initialized?i.realSlides:W(e.slides),T=Math.max(0,Math.min(c,f.length-1)),S=f[T];if(!S)return;r.currentSlideIndex=T,F(e.thumbs,T);let p=o?S.offsetTop:S.offsetLeft;u(p);},A=()=>{r.cachedFeedRect=null,Z(e,o,O()),Q(e,m(),o),n(),e.marquee&&!r.marqueePaused&&V(e,r);},R=()=>{K(r),ce(r,e),r.abortController.abort(),window.removeEventListener("resize",q),r.updateThumbTimeout&&clearTimeout(r.updateThumbTimeout),r.scrollEndTimeout&&clearTimeout(r.scrollEndTimeout),a&&ie(a),pe(i),se(s),r.cachedFeedRect=null;},E=()=>{e.marquee?r.marqueePaused?k(r,e):V(e,r):e.autoplay&&j(e,r,b);},M=()=>{e.marquee?_(r,e):K(r);};return ee(e),Z(e,o,O()),e.marquee?de(e,r,s):(fe(e,i,o),e.autoplay&&j(e,r,b)),n(),w(),Q(e,m(),o),{goToIndex:L,refresh:A,unload:R,play:E,pause:M,next:()=>b("next"),prev:()=>b("prev")}};exports.createSlider=Pe;exports.easeInOutCubic=ye;exports.easeOutCubic=H;exports.easeOutExpo=N;exports.easeOutQuad=Le;exports.generateBullets=G;exports.generateThumbs=X;exports.linear=ge;
|
package/dist/index.d.cts
CHANGED
|
@@ -18,20 +18,15 @@ type MarqueeDirection = 'left' | 'right';
|
|
|
18
18
|
* Parameters passed to scroll start callback
|
|
19
19
|
*/
|
|
20
20
|
interface ScrollStartParams {
|
|
21
|
-
/** Current scroll position in pixels */
|
|
22
21
|
currentScroll: number;
|
|
23
|
-
/** Target slide element being scrolled to */
|
|
24
22
|
target: HTMLElement;
|
|
25
|
-
/** Direction of the scroll */
|
|
26
23
|
direction: SliderNavDirection;
|
|
27
24
|
}
|
|
28
25
|
/**
|
|
29
26
|
* Parameters passed to scroll and scroll end callbacks
|
|
30
27
|
*/
|
|
31
28
|
interface ScrollParams {
|
|
32
|
-
/** Current scroll position in pixels */
|
|
33
29
|
currentScroll: number;
|
|
34
|
-
/** Index of the current/active slide */
|
|
35
30
|
currentSlideIndex: number;
|
|
36
31
|
}
|
|
37
32
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -18,20 +18,15 @@ type MarqueeDirection = 'left' | 'right';
|
|
|
18
18
|
* Parameters passed to scroll start callback
|
|
19
19
|
*/
|
|
20
20
|
interface ScrollStartParams {
|
|
21
|
-
/** Current scroll position in pixels */
|
|
22
21
|
currentScroll: number;
|
|
23
|
-
/** Target slide element being scrolled to */
|
|
24
22
|
target: HTMLElement;
|
|
25
|
-
/** Direction of the scroll */
|
|
26
23
|
direction: SliderNavDirection;
|
|
27
24
|
}
|
|
28
25
|
/**
|
|
29
26
|
* Parameters passed to scroll and scroll end callbacks
|
|
30
27
|
*/
|
|
31
28
|
interface ScrollParams {
|
|
32
|
-
/** Current scroll position in pixels */
|
|
33
29
|
currentScroll: number;
|
|
34
|
-
/** Index of the current/active slide */
|
|
35
30
|
currentSlideIndex: number;
|
|
36
31
|
}
|
|
37
32
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var O=e=>e===1?1:1-Math.pow(2,-10*e),
|
|
1
|
+
var C={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},Ee="(min-width: 64rem)",O=()=>window.matchMedia(Ee).matches;var N=e=>e===1?1:1-Math.pow(2,-10*e),H=e=>1-Math.pow(1-e,3),ye=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Le=e=>1-(1-e)*(1-e),ge=e=>e;var Ae=()=>`slider-${Math.random().toString(36).substring(2,9)}`,ee=e=>{let{feed:t,prevSlideButton:o,nextSlideButton:l,thumbs:r,slides:a}=e;t.id||(t.id=Ae()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),a.forEach((i,s)=>{i.setAttribute("role","group"),i.setAttribute("aria-roledescription","slide"),i.setAttribute("aria-label",`Slide ${s+1} of ${a.length}`);}),o&&(o.setAttribute("aria-label","Previous slide"),o.setAttribute("aria-controls",t.id),o.setAttribute("tabindex","0"),o.tagName!=="BUTTON"&&o.setAttribute("role","button")),l&&(l.setAttribute("aria-label","Next slide"),l.setAttribute("aria-controls",t.id),l.setAttribute("tabindex","0"),l.tagName!=="BUTTON"&&l.setAttribute("role","button")),r?.length&&r.forEach((i,s)=>{i.tagName!=="BUTTON"&&i.setAttribute("role","button"),i.setAttribute("aria-label",`Go to slide ${s+1}`),i.setAttribute("tabindex","0"),i.setAttribute("aria-controls",t.id);});},z=(e,t,o)=>{if(!e)return;!t&&e===document.activeElement&&o&&o.focus();let l="opacity 0.3s ease",r=t?"1":"0";Object.assign(e.style,{opacity:r,transition:l,pointerEvents:t?"auto":"none"}),t?(e.removeAttribute("aria-hidden"),e.setAttribute("tabindex","0")):(e.setAttribute("aria-hidden","true"),e.setAttribute("tabindex","-1")),t?e.style.visibility="visible":setTimeout(()=>{e.style.opacity==="0"&&(e.style.visibility="hidden");},300);},F=(e,t,o="active")=>{e?.length&&e.forEach((l,r)=>{let a=r===t;l.classList.toggle(o,a),l.setAttribute("aria-selected",a.toString());});},te=(e,t,o,l,r="horizontal")=>{let a=r==="vertical",i=a?"ArrowUp":"ArrowLeft",s=a?"ArrowDown":"ArrowRight";e.addEventListener("keydown",m=>{switch(m.key){case i:m.preventDefault(),t();break;case s:m.preventDefault(),o();break}},{signal:l}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var g={FRICTION:.94,MIN_VELOCITY:.3,MOMENTUM_RATIO:.8,VELOCITY_SMOOTHING:.4,EDGE_RESISTANCE:.3,MAX_EDGE_OVERSCROLL:100,SHORT_SWIPE_VELOCITY:.5,BOUNCE_DURATION:400},Me=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),xe=()=>({...Me(),velocityHistory:[],dragDistance:0,dragStartTime:0}),$=(e,t,o="horizontal")=>{let l=e.getBoundingClientRect(),r=o==="vertical",a=r?l.top:l.left,i=null,s=1/0;for(let m of t){if(m.offsetParent===null)continue;let u=m.getBoundingClientRect(),h=r?u.top:u.left,n=Math.abs(a-h);n<s&&(s=n,i=m);}return i},Ie=(e,t,o,l="horizontal")=>{let r=e.getBoundingClientRect(),a=l==="vertical",i=a?r.top:r.left,s=t.filter(d=>d.offsetParent!==null);if(s.length===0)return null;let m=0,u=1/0;s.forEach((d,v)=>{let b=d.getBoundingClientRect(),P=a?b.top:b.left,I=Math.abs(i-P);I<u&&(u=I,m=v);});let h=2,n=m;return Math.abs(o)>h&&(o>0?n=Math.min(m+1,s.length-1):n=Math.max(m-1,0)),s[n]??null},De=e=>{if(e.length===0)return 0;let t=0,o=0;return e.forEach((l,r)=>{let a=r+1;t+=l*a,o+=a;}),t/o},Ce=(e,t,o,l,r,a="horizontal",i=false)=>{let s=a==="vertical",m=e.velocity*g.MOMENTUM_RATIO,u=()=>{if(Math.abs(m)<g.MIN_VELOCITY){e.momentumId=null;let v=$(t,o,a);if(v){let b=s?v.offsetTop:v.offsetLeft;l(b,H);}r?.(v);return}let h=s?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,d=(s?t.scrollTop:t.scrollLeft)+m;i||(d<0||d>h)&&(m*=.5),s?t.scrollTop=Math.max(0,Math.min(h,d)):t.scrollLeft=Math.max(0,Math.min(h,d)),m*=g.FRICTION,e.momentumId=requestAnimationFrame(u);};e.momentumId=requestAnimationFrame(u);},re=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,oe=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,He=(e,t)=>t==="vertical"?oe(e):re(e),le=e=>{let {feed:t,slides:o,abortSignal:l,smoothScrollTo:r,onDragEnd:a,direction:i="horizontal",loop:s=false,touchRatio:m=1,shortSwipeThreshold:u=300,swipeDistanceThreshold:h=10}=e,n=xe(),d=i==="vertical",v=0,P=()=>{v=d?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,d?t.clientHeight:t.clientWidth;},I=L=>{n.momentumId!==null&&(cancelAnimationFrame(n.momentumId),n.momentumId=null),P(),n.isDragging=true,n.startX=re(L),n.startY=oe(L),n.startScrollLeft=t.scrollLeft,n.startScrollTop=t.scrollTop,n.velocity=0,n.lastX=n.startX,n.lastY=n.startY,n.lastTime=performance.now(),n.velocityHistory=[],n.dragDistance=0,n.dragStartTime=performance.now(),t.style.userSelect="none",t.style.cursor="grabbing",t.classList.add("is-dragging"),L.type==="mousedown"&&L.preventDefault();},q=L=>{if(!n.isDragging)return;let A=He(L,i),R=d?n.startY:n.startX,E=d?n.lastY:n.lastX,M=d?n.startScrollTop:n.startScrollLeft,c=performance.now(),f=c-n.lastTime,T=(R-A)*m,S=M+T;if(n.dragDistance=Math.abs(T),!s){if(S<0){let p=Math.abs(S),y=1-Math.min(p/g.MAX_EDGE_OVERSCROLL,1)*(1-g.EDGE_RESISTANCE);S=-p*y;}else if(S>v){let p=S-v,y=1-Math.min(p/g.MAX_EDGE_OVERSCROLL,1)*(1-g.EDGE_RESISTANCE);S=v+p*y;}}if(d?t.scrollTop=S:t.scrollLeft=S,f>0){let p=(E-A)/f*16;if(n.velocityHistory.length>0){let y=n.velocity;n.velocity=y*(1-g.VELOCITY_SMOOTHING)+p*g.VELOCITY_SMOOTHING;}else n.velocity=p;n.velocityHistory.push(p),n.velocityHistory.length>5&&n.velocityHistory.shift();}d?n.lastY=A:n.lastX=A,n.lastTime=c,L.type==="touchmove"&&L.preventDefault();},w=()=>{if(!n.isDragging)return;n.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let A=performance.now()-n.dragStartTime<u&&n.dragDistance>h,R=De(n.velocityHistory);if(!s){let E=d?t.scrollTop:t.scrollLeft;if(E<0||E>v){let M=E<0?0:v,c=E,f=performance.now(),T=()=>{let S=performance.now()-f,p=Math.min(S/g.BOUNCE_DURATION,1),y=H(p),B=c+(M-c)*y;if(d?t.scrollTop=B:t.scrollLeft=B,p<1)requestAnimationFrame(T);else {let D=$(t,o,i);if(D){let x=d?D.offsetTop:D.offsetLeft;r(x,H);}a?.(D);}};requestAnimationFrame(T);return}}if(A||Math.abs(R)>g.SHORT_SWIPE_VELOCITY){let E=Ie(t,o,R,i);if(E){let M=d?E.offsetTop:E.offsetLeft;r(M,H),a?.(E);}else a?.(null);}else if(Math.abs(n.velocity)>1)Ce(n,t,o,r,a,i,s);else {let E=$(t,o,i);if(E){let M=d?E.offsetTop:E.offsetLeft;r(M,H);}a?.(E);}};return t.addEventListener("mousedown",I,{signal:l}),document.addEventListener("mousemove",q,{signal:l}),document.addEventListener("mouseup",w,{signal:l}),t.addEventListener("touchstart",I,{passive:true,signal:l}),t.addEventListener("touchmove",q,{passive:false,signal:l}),t.addEventListener("touchend",w,{signal:l}),t.addEventListener("touchcancel",w,{signal:l}),document.addEventListener("mouseleave",w,{signal:l}),t.style.cursor="grab",n},ie=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var G=({bulletsContainer:e,slides:t,bulletClass:o,bulletActiveClass:l,feedId:r})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid bulletsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!r||typeof r!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!o||typeof o!="string")throw new Error("Invalid bulletClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide navigation");let a=t.map((s,m)=>({slide:s,originalIndex:m})).filter(({slide:s})=>s.offsetParent!==null);return a.length===0?(console.warn("No visible slides found"),[]):a.map(({slide:s,originalIndex:m},u)=>{let h=document.createElement("button");return h.type="button",h.classList.add(o),u===0&&h.classList.add(l),h.setAttribute("role","tab"),h.setAttribute("aria-selected",u===0?"true":"false"),h.setAttribute("aria-controls",r),h.setAttribute("aria-label",`Go to slide ${u+1}`),h.setAttribute("data-slide-index",String(u)),e.appendChild(h),h})};var X=({thumbsContainer:e,slides:t,thumbClass:o,thumbActiveClass:l,feedId:r,thumbImageSelector:a="img",thumbSize:i})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid thumbsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!r||typeof r!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!o||typeof o!="string")throw new Error("Invalid thumbClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide thumbnails");let s=t.map((u,h)=>({slide:u,originalIndex:h})).filter(({slide:u})=>u.offsetParent!==null);return s.length===0?(console.warn("No visible slides found"),[]):s.map(({slide:u,originalIndex:h},n)=>{let d=document.createElement("button");d.type="button",d.classList.add(o),n===0&&d.classList.add(l);let v=u.querySelector(a);if(v?.src){let b=document.createElement("img");b.src=v.src,b.alt=v.alt||`Slide ${n+1} thumbnail`,b.draggable=false,i&&(b.style.width=`${i.width}px`,b.style.height=`${i.height}px`,b.style.objectFit="cover"),d.appendChild(b);}return d.setAttribute("role","tab"),d.setAttribute("aria-selected",n===0?"true":"false"),d.setAttribute("aria-controls",r),d.setAttribute("aria-label",`Go to slide ${n+1}`),d.setAttribute("data-slide-index",String(n)),e.appendChild(d),d})};var ne=()=>({initialized:false,clonedSlides:[],styleElement:null}),ae=()=>{let e=document.getElementById("lazer-marquee-keyframes");if(e)return e;let t=document.createElement("style");return t.id="lazer-marquee-keyframes",t.textContent=`
|
|
2
2
|
@keyframes lazer-marquee-scroll {
|
|
3
3
|
0% {
|
|
4
4
|
transform: translateX(0);
|
|
@@ -7,4 +7,4 @@ var O=e=>e===1?1:1-Math.pow(2,-10*e),P=e=>1-Math.pow(1-e,3),Se=e=>e<.5?4*e*e*e:1
|
|
|
7
7
|
transform: translateX(-50%);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
`,document.head.appendChild(r),r},Le=(e,r)=>{r.initialized||(r.styleElement=oe(),e.feed.style.display="flex",e.feed.style.willChange="transform",e.slides.forEach(o=>{let t=o.cloneNode(true);t.setAttribute("data-lazer-marquee-clone","true"),t.setAttribute("aria-hidden","true"),e.feed.appendChild(t),r.clonedSlides.push(t);}),r.initialized=true);},ie=e=>{e.initialized&&(e.clonedSlides.forEach(r=>{r.remove();}),e.clonedSlides=[],e.initialized=false);},Ae=(e,r)=>{oe(),requestAnimationFrame(()=>{let o=e.feed.scrollWidth,t=e.marqueeSpeed??50,u=e.marqueeDirection??"left",n=o/2;if(n<=0||t<=0){console.warn("[lazer-slider] Invalid marquee values:",{distance:n,speed:t,scrollWidth:o});return}let S=`lazer-marquee-scroll ${n/t}s linear infinite ${u==="right"?"reverse":"normal"}`;e.feed.style.animation="none",e.feed.offsetWidth,e.feed.style.animation=S,e.feed.style.animationPlayState=r.marqueePaused?"paused":"running";});},F=(e,r)=>{Ae(e,r);},ne=(e,r)=>{r.feed.style.animation="",r.feed.style.animationPlayState="",r.feed.style.transform="",r.feed.style.willChange="";},R=(e,r)=>{e.marqueePaused=true,r.feed.style.animationPlayState="paused";},z=(e,r)=>{e.marqueePaused=false,r.feed.style.animationPlayState="running";},ae=(e,r,o)=>{e.marquee&&(Le(e,o),F(e,r));},de=(e,r,o)=>{!e.marquee||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>R(r,e),{signal:o}),e.feed.addEventListener("mouseleave",()=>z(r,e),{signal:o}),e.feed.addEventListener("touchstart",()=>R(r,e),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>z(r,e),{signal:o}));};var H={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},xe="(min-width: 64rem)",Me=e=>{if(!e.feed)throw new Error("lazer-slider: feed element is required");if(!e.slides?.length)throw new Error("lazer-slider: slides array is required and must not be empty");if(e.feed.id||(e.feed.id=`lazer-slider-feed-${Math.random().toString(36).substr(2,9)}`),e.bulletsContainer&&!e.thumbs){let l=k({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=l;}if(e.thumbsContainer&&!e.thumbs){let l=$({thumbsContainer:e.thumbsContainer,slides:e.slides,thumbClass:e.thumbsClass??"slider-thumb",thumbActiveClass:e.thumbsActiveClass??"active",feedId:e.feed.id,thumbImageSelector:e.thumbImageSelector??"img",thumbSize:e.thumbSize});e.thumbs=l;}let r=e.direction??"horizontal",o=r==="vertical",t={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,marqueePaused:false,isLoopRepositioning:false},u=null,n={initialized:false,clonedSlides:[],realSlides:[...e.slides],clonesPerSide:0},f=le(),i=e.easing??O,S=()=>{let l=o?e.feed.clientHeight:e.feed.clientWidth;return (!t.cachedFeedRect||t.lastWidth!==l)&&(t.cachedFeedRect=e.feed.getBoundingClientRect(),t.lastWidth=l),t.cachedFeedRect},h=()=>e.slides.filter(l=>l.offsetParent!==null),p=()=>window.matchMedia(xe).matches,b=()=>{let l=p()?e.desktopSlidesPerView:e.mobileSlidesPerView;return !l||l==="auto"?1:Math.ceil(l)},m=()=>{if(!e.loop||n.initialized)return;let l=n.realSlides,d=b();n.clonesPerSide=d;for(let c=l.length-d;c<l.length;c++){let a=l[c];if(!a)continue;let s=a.cloneNode(true);s.setAttribute("data-lazer-clone","prepend"),s.setAttribute("aria-hidden","true"),e.feed.insertBefore(s,e.feed.firstChild),n.clonedSlides.push(s);}for(let c=0;c<d;c++){let a=l[c];if(!a)continue;let s=a.cloneNode(true);s.setAttribute("data-lazer-clone","append"),s.setAttribute("aria-hidden","true"),e.feed.appendChild(s),n.clonedSlides.push(s);}requestAnimationFrame(()=>{let c=l[0];c&&(o?e.feed.scrollTop=c.offsetTop:e.feed.scrollLeft=c.offsetLeft);}),n.initialized=true;},T=l=>{if(!e.loop||!n.initialized)return;t.isLoopRepositioning=true;let d=n.realSlides,c=d.length;if(l==="next"){let a=d[0];a&&(o?e.feed.scrollTop=a.offsetTop:e.feed.scrollLeft=a.offsetLeft),t.currentSlideIndex=0;}else {let a=d[c-1];a&&(o?e.feed.scrollTop=a.offsetTop:e.feed.scrollLeft=a.offsetLeft),t.currentSlideIndex=c-1;}requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.isLoopRepositioning=false,q();});});},v=()=>{n.initialized&&(n.clonedSlides.forEach(l=>{l.remove();}),n.clonedSlides=[],n.initialized=false,n.clonesPerSide=0);},A=()=>{let l=p()?e.desktopSlidesPerView:e.mobileSlidesPerView,d=e.slideGap??0;if(d>0&&(e.feed.style.gap=`${d}px`),!l||l==="auto"){e.slides.forEach(s=>{s.style.flex="",s.style.minWidth="",s.style.minHeight="";});return}let a=`calc((100% - ${d*(l-1)}px) / ${l})`;o?e.slides.forEach(s=>{s.style.flex=`0 0 ${a}`,s.style.minHeight=a,s.style.minWidth="";}):e.slides.forEach(s=>{s.style.flex=`0 0 ${a}`,s.style.minWidth=a,s.style.minHeight="";});},E=()=>{if(!e.scrollbarThumb)return;let l=S();if(o){let d=l.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${d}%`,e.scrollbarThumb.style.width="";}else {let d=l.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${d}%`,e.scrollbarThumb.style.height="";}},x=()=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(o){let l=e.scrollbarTrack.getBoundingClientRect().height,d=e.scrollbarThumb.getBoundingClientRect().height,c=l-d,a=e.feed.scrollHeight-e.feed.clientHeight,s=a>0?e.feed.scrollTop/a:0;e.scrollbarThumb.style.transform=`translateY(${c*s}px)`;}else {let l=e.scrollbarTrack.getBoundingClientRect().width,d=e.scrollbarThumb.getBoundingClientRect().width,c=l-d,a=e.feed.scrollWidth-e.feed.clientWidth,s=a>0?e.feed.scrollLeft/a:0;e.scrollbarThumb.style.transform=`translateX(${c*s}px)`;}},q=()=>{if(t.isLoopRepositioning)return;let l=S(),d,c,a;if(o?(d=e.feed.scrollTop<=1,c=e.feed.scrollTop+l.height>=e.feed.scrollHeight-1,a=e.feed.scrollHeight<=l.height):(d=e.feed.scrollLeft<=1,c=e.feed.scrollLeft+l.width>=e.feed.scrollWidth-1,a=e.feed.scrollWidth<=l.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=a?"none":"block"),e.loop){C(e.prevSlideButton,!a,e.feed),C(e.nextSlideButton,!a,e.feed);return}C(e.prevSlideButton,!d&&!a,e.feed),C(e.nextSlideButton,!c&&!a,e.feed);},B=()=>{let l=S(),d=n.initialized?n.realSlides:h(),c=d.filter(a=>{let s=a.getBoundingClientRect(),y=20;return o?s.bottom>l.top+y&&s.top<l.bottom-y:s.right>l.left+y&&s.left<l.right-y});if(c.length&&c[0]){let a=d.indexOf(c[0]);if(a!==-1){t.currentSlideIndex=a;let s=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:s,currentSlideIndex:t.currentSlideIndex});}}},M=(l,d=i,c)=>{let a=o?e.feed.scrollTop:e.feed.scrollLeft,s=Math.abs(l-a),y=Math.min(H.MAX_DURATION,Math.max(H.MIN_DURATION,s/H.SPEED_FACTOR)),N=performance.now(),g=I=>{let w=(I-N)/y,G=Math.min(w,1),he=d(G),j=a+(l-a)*he;o?e.feed.scrollTop=j:e.feed.scrollLeft=j,G<1?requestAnimationFrame(g):(o?e.feed.scrollTop=l:e.feed.scrollLeft=l,c?.());};requestAnimationFrame(g);},se=l=>{if(!e.thumbs)return;let d=e.thumbs.indexOf(l);if(d===-1||!e.slides[d])return;t.currentSlideIndex=d,D(e.thumbs,d),t.isScrolling=true,t.updateThumbTimeout&&clearTimeout(t.updateThumbTimeout),t.updateThumbTimeout=setTimeout(()=>{t.isScrolling=false;},H.THUMB_UPDATE_DELAY);let c=o?e.slides[d].offsetTop:e.slides[d].offsetLeft;M(c);},L=l=>{let d=n.initialized?n.realSlides:h(),c=p()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,a=d.length;B();let s,y=false;if(l==="prev")if(e.loop&&n.initialized&&t.currentSlideIndex===0){let I=n.clonedSlides.filter(w=>w.getAttribute("data-lazer-clone")==="prepend");s=I[I.length-1],y=true;}else t.currentSlideIndex=Math.max(0,t.currentSlideIndex-c),s=d[t.currentSlideIndex];else e.loop&&n.initialized&&t.currentSlideIndex>=a-1?(s=n.clonedSlides.filter(w=>w.getAttribute("data-lazer-clone")==="append")[0],y=true):(t.currentSlideIndex=Math.min(a-1,t.currentSlideIndex+c),s=d[t.currentSlideIndex]);if(!s)return;let N=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:N,target:s,direction:l});let g=o?s.offsetTop:s.offsetLeft;y?M(g,i,()=>{T(l);}):M(g);},ce=()=>{x(),q(),B(),t.isScrolling||D(e.thumbs,t.currentSlideIndex),t.scrollEndTimeout&&clearTimeout(t.scrollEndTimeout),t.scrollEndTimeout=setTimeout(()=>{t.isScrolling=false;let l=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:l,currentSlideIndex:t.currentSlideIndex});},H.SCROLL_END_DELAY);},ue=()=>{t.ticking||(requestAnimationFrame(()=>{ce(),t.ticking=false;}),t.ticking=true);},W=()=>{t.cachedFeedRect=null,U();},fe=()=>{let{signal:l}=t.abortController;window.addEventListener("resize",W),e.feed.addEventListener("scroll",ue,{passive:true,signal:l}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>L("prev"),{signal:l}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>L("next"),{signal:l}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(d=>{d.addEventListener("click",()=>se(d),{signal:l});})),Q(e.feed,()=>L("prev"),()=>L("next"),l,r),e.enableDragToScroll!==false&&(u=te({feed:e.feed,slides:e.slides,abortSignal:l,smoothScrollTo:M,onDragEnd:()=>{B(),D(e.thumbs,t.currentSlideIndex);},direction:r})),e.autoplay&&e.pauseOnHover!==false&&(e.feed.addEventListener("mouseenter",Y,{signal:l}),e.feed.addEventListener("mouseleave",_,{signal:l}),e.feed.addEventListener("touchstart",Y,{passive:true,signal:l}),e.feed.addEventListener("touchend",_,{signal:l})),de(e,t,l);},V=()=>{if(t.autoplayIntervalId)return;let l=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||L("next");},l);},X=()=>{t.autoplayIntervalId&&(clearInterval(t.autoplayIntervalId),t.autoplayIntervalId=null);},Y=()=>{t.autoplayPaused=true;},_=()=>{t.autoplayPaused=false;},me=l=>{let d=n.initialized?n.realSlides:h(),c=Math.max(0,Math.min(l,d.length-1)),a=d[c];if(!a)return;t.currentSlideIndex=c,D(e.thumbs,c);let s=o?a.offsetTop:a.offsetLeft;M(s);},U=()=>{t.cachedFeedRect=null,A(),E(),q(),e.marquee&&!t.marqueePaused&&F(e,t);},pe=()=>{X(),ne(t,e),t.abortController.abort(),window.removeEventListener("resize",W),t.updateThumbTimeout&&clearTimeout(t.updateThumbTimeout),t.scrollEndTimeout&&clearTimeout(t.scrollEndTimeout),u&&re(u),v(),ie(f),t.cachedFeedRect=null;};return K(e),A(),e.marquee?ae(e,t,f):(m(),e.autoplay&&V()),q(),fe(),E(),{goToIndex:me,refresh:U,unload:pe,play:()=>{e.marquee?t.marqueePaused?z(t,e):F(e,t):e.autoplay&&V();},pause:()=>{e.marquee?R(t,e):X();},next:()=>L("next"),prev:()=>L("prev")}};export{Me as createSlider,Se as easeInOutCubic,P as easeOutCubic,O as easeOutExpo,be as easeOutQuad,k as generateBullets,$ as generateThumbs,ve as linear};
|
|
10
|
+
`,document.head.appendChild(t),t},we=(e,t)=>{t.initialized||(t.styleElement=ae(),e.feed.style.display="flex",e.feed.style.willChange="transform",e.slides.forEach(o=>{let l=o.cloneNode(true);l.setAttribute("data-lazer-marquee-clone","true"),l.setAttribute("aria-hidden","true"),e.feed.appendChild(l),t.clonedSlides.push(l);}),t.initialized=true);},se=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false);},Re=(e,t)=>{ae(),requestAnimationFrame(()=>{let o=e.feed.scrollWidth,l=e.marqueeSpeed??50,r=e.marqueeDirection??"left",a=o/2;if(a<=0||l<=0){console.warn("[lazer-slider] Invalid marquee values:",{distance:a,speed:l,scrollWidth:o});return}let m=`lazer-marquee-scroll ${a/l}s linear infinite ${r==="right"?"reverse":"normal"}`;e.feed.style.animation="none",e.feed.offsetWidth,e.feed.style.animation=m,e.feed.style.animationPlayState=t.marqueePaused?"paused":"running";});},V=(e,t)=>{Re(e,t);},ce=(e,t)=>{t.feed.style.animation="",t.feed.style.animationPlayState="",t.feed.style.transform="",t.feed.style.willChange="";},_=(e,t)=>{e.marqueePaused=true,t.feed.style.animationPlayState="paused";},k=(e,t)=>{e.marqueePaused=false,t.feed.style.animationPlayState="running";},de=(e,t,o)=>{e.marquee&&(we(e,o),V(e,t));},ue=(e,t,o)=>{!e.marquee||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>_(t,e),{signal:o}),e.feed.addEventListener("mouseleave",()=>k(t,e),{signal:o}),e.feed.addEventListener("touchstart",()=>_(t,e),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>k(t,e),{signal:o}));};var me=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0}),Oe=e=>{let t=O()?e.desktopSlidesPerView:e.mobileSlidesPerView;return !t||t==="auto"?1:Math.ceil(t)},fe=(e,t,o)=>{if(!e.loop||t.initialized)return;let l=t.realSlides,r=Oe(e);t.clonesPerSide=r;for(let a=l.length-r;a<l.length;a++){let i=l[a];if(!i)continue;let s=i.cloneNode(true);s.setAttribute("data-lazer-clone","prepend"),s.setAttribute("aria-hidden","true"),e.feed.insertBefore(s,e.feed.firstChild),t.clonedSlides.push(s);}for(let a=0;a<r;a++){let i=l[a];if(!i)continue;let s=i.cloneNode(true);s.setAttribute("data-lazer-clone","append"),s.setAttribute("aria-hidden","true"),e.feed.appendChild(s),t.clonedSlides.push(s);}requestAnimationFrame(()=>{let a=l[0];a&&(o?e.feed.scrollTop=a.offsetTop:e.feed.scrollLeft=a.offsetLeft);}),t.initialized=true;},U=(e,t,o,l,r,a,i)=>{if(!t.loop||!o.initialized)return;a(true);let s=o.realSlides,m=s.length;if(e==="next"){let u=s[0];u&&(l?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),r(0);}else {let u=s[m-1];u&&(l?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),r(m-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{a(false),i();});});},pe=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0);};var j=(e,t,o)=>{if(t.autoplayIntervalId)return;let l=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||o("next");},l);},K=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},Se=e=>{e.autoplayPaused=true;},he=e=>{e.autoplayPaused=false;},be=(e,t,o)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>Se(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>he(t),{signal:o}),e.feed.addEventListener("touchstart",()=>Se(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>he(t),{signal:o}));};var Q=(e,t,o)=>{if(e.scrollbarThumb)if(o){let l=t.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${l}%`,e.scrollbarThumb.style.width="";}else {let l=t.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${l}%`,e.scrollbarThumb.style.height="";}},Te=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let o=e.scrollbarTrack.getBoundingClientRect().height,l=e.scrollbarThumb.getBoundingClientRect().height,r=o-l,a=e.feed.scrollHeight-e.feed.clientHeight,i=a>0?e.feed.scrollTop/a:0;e.scrollbarThumb.style.transform=`translateY(${r*i}px)`;}else {let o=e.scrollbarTrack.getBoundingClientRect().width,l=e.scrollbarThumb.getBoundingClientRect().width,r=o-l,a=e.feed.scrollWidth-e.feed.clientWidth,i=a>0?e.feed.scrollLeft/a:0;e.scrollbarThumb.style.transform=`translateX(${r*i}px)`;}};var J=(e,t,o,l=N,r)=>{let a=o?e.scrollTop:e.scrollLeft,i=Math.abs(t-a),s=Math.min(C.MAX_DURATION,Math.max(C.MIN_DURATION,i/C.SPEED_FACTOR)),m=performance.now(),u=h=>{let n=(h-m)/s,d=Math.min(n,1),v=l(d),b=a+(t-a)*v;o?e.scrollTop=b:e.scrollLeft=b,d<1?requestAnimationFrame(u):(o?e.scrollTop=t:e.scrollLeft=t,r?.());};requestAnimationFrame(u);},W=e=>e.filter(t=>t.offsetParent!==null),Z=(e,t,o)=>{let l=o?e.desktopSlidesPerView:e.mobileSlidesPerView,r=e.slideGap??0;if(r>0&&(e.feed.style.gap=`${r}px`),!l||l==="auto"){e.slides.forEach(s=>{s.style.flex="",s.style.minWidth="",s.style.minHeight="";});return}let i=`calc((100% - ${r*(l-1)}px) / ${l})`;t?e.slides.forEach(s=>{s.style.flex=`0 0 ${i}`,s.style.minHeight=i,s.style.minWidth="";}):e.slides.forEach(s=>{s.style.flex=`0 0 ${i}`,s.style.minWidth=i,s.style.minHeight="";});},ve=(e,t,o,l)=>{let r=l?e.clientHeight:e.clientWidth;return !t||o!==r?{rect:e.getBoundingClientRect(),size:r}:{rect:t,size:o}};var Pe=e=>{if(!e.feed)throw new Error("lazer-slider: feed element is required");if(!e.slides?.length)throw new Error("lazer-slider: slides array is required and must not be empty");if(e.feed.id||(e.feed.id=`lazer-slider-feed-${Math.random().toString(36).substr(2,9)}`),e.bulletsContainer&&!e.thumbs){let c=G({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=c;}if(e.thumbsContainer&&!e.thumbs){let c=X({thumbsContainer:e.thumbsContainer,slides:e.slides,thumbClass:e.thumbsClass??"slider-thumb",thumbActiveClass:e.thumbsActiveClass??"active",feedId:e.feed.id,thumbImageSelector:e.thumbImageSelector??"img",thumbSize:e.thumbSize});e.thumbs=c;}let t=e.direction??"horizontal",o=t==="vertical",l=e.easing??N,r={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,marqueePaused:false,isLoopRepositioning:false},a=null,i=me(e.slides),s=ne(),m=()=>{let c=ve(e.feed,r.cachedFeedRect,r.lastWidth,o);return r.cachedFeedRect=c.rect,r.lastWidth=c.size,c.rect},u=(c,f)=>{J(e.feed,c,o,l,f);},h=(c,f)=>{J(e.feed,c,o,f??l);},n=()=>{if(r.isLoopRepositioning)return;let c=m(),f,T,S;if(o?(f=e.feed.scrollTop<=1,T=e.feed.scrollTop+c.height>=e.feed.scrollHeight-1,S=e.feed.scrollHeight<=c.height):(f=e.feed.scrollLeft<=1,T=e.feed.scrollLeft+c.width>=e.feed.scrollWidth-1,S=e.feed.scrollWidth<=c.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=S?"none":"block"),e.loop){z(e.prevSlideButton,!S,e.feed),z(e.nextSlideButton,!S,e.feed);return}z(e.prevSlideButton,!f&&!S,e.feed),z(e.nextSlideButton,!T&&!S,e.feed);},d=()=>{let c=m(),f=i.initialized?i.realSlides:W(e.slides),T=f.filter(S=>{let p=S.getBoundingClientRect(),y=20;return o?p.bottom>c.top+y&&p.top<c.bottom-y:p.right>c.left+y&&p.left<c.right-y});if(T.length&&T[0]){let S=f.indexOf(T[0]);if(S!==-1){r.currentSlideIndex=S;let p=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:p,currentSlideIndex:r.currentSlideIndex});}}},v=c=>{if(!e.thumbs)return;let f=e.thumbs.indexOf(c);if(f===-1||!e.slides[f])return;r.currentSlideIndex=f,F(e.thumbs,f),r.isScrolling=true,r.updateThumbTimeout&&clearTimeout(r.updateThumbTimeout),r.updateThumbTimeout=setTimeout(()=>{r.isScrolling=false;},C.THUMB_UPDATE_DELAY);let T=o?e.slides[f].offsetTop:e.slides[f].offsetLeft;u(T);},b=c=>{let f=i.initialized?i.realSlides:W(e.slides),T=O()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,S=f.length;d();let p,y=false;if(c==="prev")if(e.loop&&i.initialized&&r.currentSlideIndex===0){let x=i.clonedSlides.filter(Y=>Y.getAttribute("data-lazer-clone")==="prepend");p=x[x.length-1],y=true;}else r.currentSlideIndex=Math.max(0,r.currentSlideIndex-T),p=f[r.currentSlideIndex];else e.loop&&i.initialized&&r.currentSlideIndex>=S-1?(p=i.clonedSlides.filter(Y=>Y.getAttribute("data-lazer-clone")==="append")[0],y=true):(r.currentSlideIndex=Math.min(S-1,r.currentSlideIndex+T),p=f[r.currentSlideIndex]);if(!p)return;let B=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:B,target:p,direction:c});let D=o?p.offsetTop:p.offsetLeft;y?u(D,()=>{U(c,e,i,o,x=>{r.currentSlideIndex=x;},x=>{r.isLoopRepositioning=x;},n);}):u(D);},P=()=>{Te(e,o),n(),d(),r.isScrolling||F(e.thumbs,r.currentSlideIndex),r.scrollEndTimeout&&clearTimeout(r.scrollEndTimeout),r.scrollEndTimeout=setTimeout(()=>{r.isScrolling=false;let c=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:c,currentSlideIndex:r.currentSlideIndex});},C.SCROLL_END_DELAY);},I=()=>{r.ticking||(requestAnimationFrame(()=>{P(),r.ticking=false;}),r.ticking=true);},q=()=>{r.cachedFeedRect=null,A();},w=()=>{let{signal:c}=r.abortController;window.addEventListener("resize",q),e.feed.addEventListener("scroll",I,{passive:true,signal:c}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>b("prev"),{signal:c}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>b("next"),{signal:c}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(f=>{f.addEventListener("click",()=>v(f),{signal:c});})),te(e.feed,()=>b("prev"),()=>b("next"),c,t),e.enableDragToScroll!==false&&(a=le({feed:e.feed,slides:e.slides,abortSignal:c,smoothScrollTo:h,onDragEnd:f=>{if(f&&e.loop&&i.initialized){let T=f.getAttribute("data-lazer-clone");if(T){let S=T==="append"?"next":"prev";setTimeout(()=>{U(S,e,i,o,p=>{r.currentSlideIndex=p;},p=>{r.isLoopRepositioning=p;},n);},50);}}d(),F(e.thumbs,r.currentSlideIndex);},direction:t,loop:e.loop})),be(e,r,c),ue(e,r,c);},L=c=>{let f=i.initialized?i.realSlides:W(e.slides),T=Math.max(0,Math.min(c,f.length-1)),S=f[T];if(!S)return;r.currentSlideIndex=T,F(e.thumbs,T);let p=o?S.offsetTop:S.offsetLeft;u(p);},A=()=>{r.cachedFeedRect=null,Z(e,o,O()),Q(e,m(),o),n(),e.marquee&&!r.marqueePaused&&V(e,r);},R=()=>{K(r),ce(r,e),r.abortController.abort(),window.removeEventListener("resize",q),r.updateThumbTimeout&&clearTimeout(r.updateThumbTimeout),r.scrollEndTimeout&&clearTimeout(r.scrollEndTimeout),a&&ie(a),pe(i),se(s),r.cachedFeedRect=null;},E=()=>{e.marquee?r.marqueePaused?k(r,e):V(e,r):e.autoplay&&j(e,r,b);},M=()=>{e.marquee?_(r,e):K(r);};return ee(e),Z(e,o,O()),e.marquee?de(e,r,s):(fe(e,i,o),e.autoplay&&j(e,r,b)),n(),w(),Q(e,m(),o),{goToIndex:L,refresh:A,unload:R,play:E,pause:M,next:()=>b("next"),prev:()=>b("prev")}};export{Pe as createSlider,ye as easeInOutCubic,H as easeOutCubic,N as easeOutExpo,Le as easeOutQuad,G as generateBullets,X as generateThumbs,ge as linear};
|
package/dist/lazer-slider.css
CHANGED
|
@@ -14,246 +14,285 @@
|
|
|
14
14
|
/* ============================================
|
|
15
15
|
CSS Custom Properties (Easy to Override)
|
|
16
16
|
============================================ */
|
|
17
|
-
:root {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* ============================================
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.lazer-feed {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.lazer-feed::-webkit-scrollbar {
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* Vertical slider variant */
|
|
71
|
-
.lazer-feed.lazer-vertical {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* ============================================
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.lazer-slide {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.lazer-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
17
|
+
:root {
|
|
18
|
+
/* Bullets / Dots */
|
|
19
|
+
--lazer-bullet-size: 12px;
|
|
20
|
+
--lazer-bullet-gap: 8px;
|
|
21
|
+
--lazer-bullet-color: #cbd5e1;
|
|
22
|
+
--lazer-bullet-active-color: #1e293b;
|
|
23
|
+
--lazer-bullet-hover-scale: 1.2;
|
|
24
|
+
|
|
25
|
+
/* Thumbnails */
|
|
26
|
+
--lazer-thumb-gap: 8px;
|
|
27
|
+
--lazer-thumb-opacity: 0.6;
|
|
28
|
+
--lazer-thumb-hover-opacity: 0.8;
|
|
29
|
+
--lazer-thumb-active-opacity: 1;
|
|
30
|
+
--lazer-thumb-border-width: 2px;
|
|
31
|
+
--lazer-thumb-border-color: transparent;
|
|
32
|
+
--lazer-thumb-active-border-color: #3b82f6;
|
|
33
|
+
--lazer-thumb-border-radius: 4px;
|
|
34
|
+
|
|
35
|
+
/* Scrollbar */
|
|
36
|
+
--lazer-track-height: 4px;
|
|
37
|
+
--lazer-track-color: #e2e8f0;
|
|
38
|
+
--lazer-thumb-color: #1e293b;
|
|
39
|
+
--lazer-track-radius: 2px;
|
|
40
|
+
|
|
41
|
+
/* Navigation Buttons */
|
|
42
|
+
--lazer-nav-size: 40px;
|
|
43
|
+
--lazer-nav-offset: 12px;
|
|
44
|
+
--lazer-nav-bg: rgba(255, 255, 255, 0.9);
|
|
45
|
+
--lazer-nav-hover-bg: white;
|
|
46
|
+
--lazer-nav-radius: 50%;
|
|
47
|
+
--lazer-nav-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
48
|
+
|
|
49
|
+
/* Transitions */
|
|
50
|
+
--lazer-duration: 0.3s;
|
|
51
|
+
--lazer-easing: ease;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* ============================================
|
|
55
|
+
Feed (Scrollable Container)
|
|
56
|
+
============================================ */
|
|
57
|
+
.lazer-feed {
|
|
58
|
+
position: relative;
|
|
59
|
+
display: flex;
|
|
60
|
+
overflow-x: auto;
|
|
61
|
+
overflow-y: hidden;
|
|
62
|
+
-webkit-overflow-scrolling: touch;
|
|
63
|
+
scrollbar-width: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.lazer-feed::-webkit-scrollbar {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Vertical slider variant */
|
|
71
|
+
.lazer-feed.lazer-vertical {
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
overflow-x: hidden;
|
|
74
|
+
overflow-y: auto;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* ============================================
|
|
78
|
+
Slides
|
|
79
|
+
============================================ */
|
|
80
|
+
.lazer-slide {
|
|
81
|
+
flex: 0 0 calc(100% / var(--slides-per-view, 1));
|
|
82
|
+
scroll-snap-align: start;
|
|
83
|
+
scroll-snap-stop: always;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* ============================================
|
|
87
|
+
Drag State
|
|
88
|
+
============================================ */
|
|
89
|
+
.lazer-feed.lazer-draggable {
|
|
90
|
+
cursor: grab;
|
|
91
|
+
/* Hint for GPU acceleration during drag */
|
|
92
|
+
will-change: scroll-position;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.lazer-feed.lazer-draggable.is-dragging {
|
|
96
|
+
cursor: grabbing;
|
|
97
|
+
user-select: none;
|
|
98
|
+
/* Disable scroll snapping during drag for smoother experience */
|
|
99
|
+
scroll-snap-type: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.lazer-feed.lazer-draggable.is-dragging .lazer-slide {
|
|
103
|
+
scroll-snap-align: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Restore scroll snapping after drag ends */
|
|
107
|
+
.lazer-feed.lazer-draggable:not(.is-dragging) {
|
|
108
|
+
scroll-behavior: smooth;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* ============================================
|
|
112
|
+
Bullets / Dots Navigation
|
|
113
|
+
============================================ */
|
|
114
|
+
.lazer-bullets {
|
|
115
|
+
display: flex;
|
|
116
|
+
gap: var(--lazer-bullet-gap);
|
|
117
|
+
justify-content: center;
|
|
118
|
+
align-items: center;
|
|
119
|
+
padding: 16px 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.lazer-bullet {
|
|
123
|
+
width: var(--lazer-bullet-size);
|
|
124
|
+
height: var(--lazer-bullet-size);
|
|
125
|
+
padding: 0;
|
|
126
|
+
border: none;
|
|
127
|
+
border-radius: 50%;
|
|
128
|
+
background: var(--lazer-bullet-color);
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
transition:
|
|
131
|
+
background var(--lazer-duration) var(--lazer-easing),
|
|
132
|
+
transform var(--lazer-duration) var(--lazer-easing);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.lazer-bullet:hover {
|
|
136
|
+
transform: scale(var(--lazer-bullet-hover-scale));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.lazer-bullet:focus-visible {
|
|
140
|
+
outline: 2px solid var(--lazer-bullet-active-color);
|
|
141
|
+
outline-offset: 2px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.lazer-bullet.active {
|
|
145
|
+
background: var(--lazer-bullet-active-color);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* ============================================
|
|
149
|
+
Thumbnails Gallery
|
|
150
|
+
============================================ */
|
|
151
|
+
.lazer-thumbs {
|
|
152
|
+
display: flex;
|
|
153
|
+
gap: var(--lazer-thumb-gap);
|
|
154
|
+
justify-content: center;
|
|
155
|
+
align-items: center;
|
|
156
|
+
padding: 16px 0;
|
|
157
|
+
flex-wrap: wrap;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.lazer-thumb {
|
|
161
|
+
padding: 0;
|
|
162
|
+
border: var(--lazer-thumb-border-width) solid var(--lazer-thumb-border-color);
|
|
163
|
+
border-radius: var(--lazer-thumb-border-radius);
|
|
164
|
+
background: none;
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
opacity: var(--lazer-thumb-opacity);
|
|
167
|
+
transition:
|
|
168
|
+
opacity var(--lazer-duration) var(--lazer-easing),
|
|
169
|
+
border-color var(--lazer-duration) var(--lazer-easing);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.lazer-thumb:hover {
|
|
173
|
+
opacity: var(--lazer-thumb-hover-opacity);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.lazer-thumb:focus-visible {
|
|
177
|
+
outline: 2px solid var(--lazer-thumb-active-border-color);
|
|
178
|
+
outline-offset: 2px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.lazer-thumb.active {
|
|
182
|
+
opacity: var(--lazer-thumb-active-opacity);
|
|
183
|
+
border-color: var(--lazer-thumb-active-border-color);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.lazer-thumb img {
|
|
187
|
+
display: block;
|
|
188
|
+
border-radius: calc(var(--lazer-thumb-border-radius) - 2px);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* ============================================
|
|
192
|
+
Custom Scrollbar
|
|
193
|
+
============================================ */
|
|
194
|
+
.lazer-track {
|
|
195
|
+
position: relative;
|
|
196
|
+
width: 100%;
|
|
197
|
+
height: var(--lazer-track-height);
|
|
198
|
+
background-color: var(--lazer-track-color);
|
|
199
|
+
border-radius: var(--lazer-track-radius);
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
margin-top: 16px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.lazer-scrollbar {
|
|
205
|
+
position: absolute;
|
|
206
|
+
top: 0;
|
|
207
|
+
left: 0;
|
|
208
|
+
height: 100%;
|
|
209
|
+
width: 100%;
|
|
210
|
+
transition: transform 0.1s linear;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* Scrollbar thumb indicator - override thumbnail styles */
|
|
214
|
+
.lazer-track .lazer-thumb,
|
|
215
|
+
.lazer-scrollbar .lazer-thumb {
|
|
216
|
+
position: absolute;
|
|
217
|
+
top: 0;
|
|
218
|
+
left: 0;
|
|
219
|
+
height: 100%;
|
|
220
|
+
min-width: 32px;
|
|
221
|
+
background-color: var(--lazer-thumb-color);
|
|
222
|
+
border-radius: var(--lazer-track-radius);
|
|
223
|
+
border: none;
|
|
224
|
+
opacity: 1;
|
|
225
|
+
cursor: grab;
|
|
226
|
+
transition: width 0.2s ease;
|
|
227
|
+
pointer-events: auto;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.lazer-track .lazer-thumb:active,
|
|
231
|
+
.lazer-scrollbar .lazer-thumb:active {
|
|
232
|
+
cursor: grabbing;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* ============================================
|
|
236
|
+
Navigation Buttons
|
|
237
|
+
============================================ */
|
|
238
|
+
.lazer-nav {
|
|
239
|
+
position: absolute;
|
|
240
|
+
top: 50%;
|
|
241
|
+
transform: translateY(-50%);
|
|
242
|
+
z-index: 10;
|
|
243
|
+
display: flex;
|
|
244
|
+
align-items: center;
|
|
245
|
+
justify-content: center;
|
|
246
|
+
width: var(--lazer-nav-size);
|
|
247
|
+
height: var(--lazer-nav-size);
|
|
248
|
+
border: none;
|
|
249
|
+
border-radius: var(--lazer-nav-radius);
|
|
250
|
+
background: var(--lazer-nav-bg);
|
|
251
|
+
box-shadow: var(--lazer-nav-shadow);
|
|
252
|
+
cursor: pointer;
|
|
253
|
+
transition:
|
|
254
|
+
opacity var(--lazer-duration) var(--lazer-easing),
|
|
255
|
+
background var(--lazer-duration) var(--lazer-easing);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.lazer-nav:hover {
|
|
259
|
+
background: var(--lazer-nav-hover-bg);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.lazer-nav:focus-visible {
|
|
263
|
+
outline: 2px solid var(--lazer-bullet-active-color);
|
|
264
|
+
outline-offset: 2px;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.lazer-nav[aria-hidden="true"] {
|
|
268
|
+
opacity: 0;
|
|
269
|
+
pointer-events: none;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.lazer-prev {
|
|
273
|
+
left: var(--lazer-nav-offset);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.lazer-next {
|
|
277
|
+
right: var(--lazer-nav-offset);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/* ============================================
|
|
281
|
+
Slider Container (Optional wrapper)
|
|
282
|
+
============================================ */
|
|
283
|
+
.lazer-slider {
|
|
284
|
+
position: relative;
|
|
285
|
+
width: 100%;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* ============================================
|
|
289
|
+
Marquee Specific
|
|
290
|
+
============================================ */
|
|
291
|
+
.lazer-feed.lazer-marquee {
|
|
292
|
+
scroll-snap-type: none;
|
|
293
|
+
cursor: default;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.lazer-feed.lazer-marquee:not(.is-dragging) {
|
|
297
|
+
cursor: default;
|
|
298
|
+
}
|
package/package.json
CHANGED