lazer-slider 1.1.10 → 1.2.0

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/README.md CHANGED
@@ -10,7 +10,7 @@ A lightweight, accessible slider with smooth scroll-to-snap animations, drag-to-
10
10
  - **Vertical & Horizontal** - Support for both horizontal and vertical slider directions
11
11
  - **Loop Mode** - Infinite loop navigation
12
12
  - **Autoplay** - Automatic slide advancement with pause on hover
13
- - **Marquee Mode** - Continuous smooth scrolling with seamless infinite loop
13
+ - **Auto-Scroll** - Continuous smooth scrolling with drag interaction and seamless infinite loop
14
14
  - **Automatic Bullets** - Auto-generate navigation bullets from slides
15
15
  - **Thumbs Gallery** - Auto-generate thumbnail navigation from slide images
16
16
  - **Accessible** - Full ARIA support, keyboard navigation (arrow keys)
@@ -130,12 +130,16 @@ slider.unload()
130
130
  | `autoplay` | `boolean` | `false` | Enable automatic slide advancement |
131
131
  | `autoplayInterval` | `number` | `3000` | Autoplay interval in milliseconds |
132
132
  | `pauseOnHover` | `boolean` | `true` | Pause autoplay on hover/touch |
133
- | `marquee` | `boolean` | `false` | Enable marquee mode (continuous scroll, overrides autoplay/loop) |
134
- | `marqueeSpeed` | `number` | `50` | Marquee scroll speed in pixels per second |
135
- | `marqueeDirection` | `'left' \| 'right'` | `'left'` | Marquee scroll direction |
133
+ | `autoScroll` | `boolean` | `false` | Enable auto-scroll (continuous scrolling, implicitly enables loop) |
134
+ | `autoScrollSpeed` | `number` | `50` | Auto-scroll speed in pixels per second |
135
+ | `autoScrollDirection` | `'forward' \| 'backward'` | `'forward'` | Auto-scroll direction |
136
+ | `autoScrollStartDelay` | `number` | `0` | Delay in ms before auto-scroll starts or resumes after interaction |
137
+ | `stopOnInteraction` | `boolean` | `false` | Permanently stop auto-scroll after user drag (call `play()` to restart) |
138
+ | `stopOnMouseEnter` | `boolean` | `true` | Pause auto-scroll when mouse hovers over the slider |
139
+ | `stopOnFocusIn` | `boolean` | `true` | Pause auto-scroll when a slide receives keyboard focus |
136
140
  | `easing` | `EasingFunction` | `easeOutExpo` | Custom easing function |
137
141
 
138
- > **Note:** When `marquee` is enabled, it takes precedence over `loop` and `autoplay` settings. Marquee mode provides continuous smooth scrolling suitable for ticker-style content displays.
142
+ > **Note:** When `autoScroll` is enabled, loop mode is automatically enabled. Auto-scroll integrates with drag-to-scroll: dragging pauses the scroll, and it resumes after the drag ends (unless `stopOnInteraction` is `true`).
139
143
 
140
144
  ### Scrollbar (Optional)
141
145
 
@@ -181,9 +185,9 @@ slider.goToIndex(2)
181
185
  slider.next()
182
186
  slider.prev()
183
187
 
184
- // Autoplay/Marquee control
185
- slider.play() // Start autoplay or marquee
186
- slider.pause() // Stop autoplay or marquee
188
+ // Autoplay/Auto-scroll control
189
+ slider.play() // Start autoplay or auto-scroll
190
+ slider.pause() // Stop autoplay or auto-scroll
187
191
 
188
192
  // Recalculate dimensions (call after DOM changes)
189
193
  slider.refresh()
@@ -273,34 +277,38 @@ const slider = createSlider({
273
277
  })
274
278
  ```
275
279
 
276
- ### Marquee Mode
280
+ ### Auto-Scroll
277
281
 
278
- Create a continuous scrolling marquee effect with seamless infinite loop. Perfect for ticker-style content, logos, or announcements.
282
+ Create a continuous scrolling effect with seamless infinite loop. Perfect for ticker-style content, logos, or announcements. Integrates with drag-to-scroll for smooth user interaction.
279
283
 
280
284
  ```typescript
281
- const marquee = createSlider({
282
- feed: document.querySelector('.marquee-feed'),
283
- slides: [...document.querySelectorAll('.marquee-item')],
284
- marquee: true,
285
- marqueeSpeed: 80, // 80 pixels per second
286
- marqueeDirection: 'left', // or 'right'
287
- pauseOnHover: true // Pause on hover (default: true)
285
+ const ticker = createSlider({
286
+ feed: document.querySelector('.ticker-feed'),
287
+ slides: [...document.querySelectorAll('.ticker-item')],
288
+ autoScroll: true,
289
+ autoScrollSpeed: 80, // 80 pixels per second
290
+ autoScrollDirection: 'forward', // or 'backward'
291
+ enableDragToScroll: true, // Users can drag to interact
292
+ autoScrollStartDelay: 1000, // Resume 1s after interaction
293
+ stopOnMouseEnter: true // Pause on hover (default)
288
294
  })
289
295
 
290
296
  // Control programmatically
291
- marquee.pause() // Stop marquee
292
- marquee.play() // Resume marquee
297
+ ticker.pause() // Stop auto-scroll
298
+ ticker.play() // Resume auto-scroll
293
299
  ```
294
300
 
295
301
  **Key Features:**
296
- - Continuous smooth scrolling (not slide-by-slide)
297
- - Frame-rate independent animation for consistent speed
298
- - Automatic content cloning for seamless infinite loop
299
- - Pause on hover/touch support
300
- - Works with any number of slides
301
-
302
- **When to use Marquee vs Autoplay:**
303
- - **Marquee**: For continuous ticker-style scrolling (news tickers, logo carousels, announcements)
302
+ - Continuous smooth scrolling using `requestAnimationFrame` (not CSS animations)
303
+ - Frame-rate independent animation for consistent speed across devices
304
+ - Automatic loop clone management for seamless infinite scrolling
305
+ - Drag interaction support: dragging pauses auto-scroll, resumes after release
306
+ - Pause on hover, touch, and keyboard focus
307
+ - Configurable resume delay after user interaction
308
+ - `stopOnInteraction` mode for one-time auto-scroll that stops after user engagement
309
+
310
+ **When to use Auto-Scroll vs Autoplay:**
311
+ - **Auto-Scroll**: For continuous ticker-style scrolling (news tickers, logo carousels, announcements)
304
312
  - **Autoplay**: For slide-by-slide carousel navigation (image galleries, product showcases)
305
313
 
306
314
  ### Vertical Slider
@@ -696,7 +704,7 @@ import {
696
704
  type ScrollParams,
697
705
  type ScrollStartParams,
698
706
  type SliderDirection,
699
- type MarqueeDirection
707
+ type AutoScrollDirection
700
708
  } from 'lazer-slider'
701
709
  ```
702
710
 
package/dist/index.cjs CHANGED
@@ -1,10 +1 @@
1
- 'use strict';var O={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},Le="(min-width: 64rem)",z=()=>window.matchMedia(Le).matches;var B=e=>e===1?1:1-Math.pow(2,-10*e),N=e=>1-Math.pow(1-e,3),ge=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Ae=e=>1-(1-e)*(1-e),Me=e=>e;var xe=()=>`slider-${Math.random().toString(36).substring(2,9)}`,te=e=>{let{feed:t,prevSlideButton:o,nextSlideButton:l,thumbs:r,slides:s}=e;t.id||(t.id=xe()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),s.forEach((i,a)=>{i.setAttribute("role","group"),i.setAttribute("aria-roledescription","slide"),i.setAttribute("aria-label",`Slide ${a+1} of ${s.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,a)=>{i.tagName!=="BUTTON"&&i.setAttribute("role","button"),i.setAttribute("aria-label",`Go to slide ${a+1}`),i.setAttribute("tabindex","0"),i.setAttribute("aria-controls",t.id);});},_=(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 s=r===t;l.classList.toggle(o,s),l.setAttribute("aria-selected",s.toString());});},re=(e,t,o,l,r="horizontal")=>{let s=r==="vertical",i=s?"ArrowUp":"ArrowLeft",a=s?"ArrowDown":"ArrowRight";e.addEventListener("keydown",p=>{switch(p.key){case i:p.preventDefault(),t();break;case a:p.preventDefault(),o();break}},{signal:l}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var C={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},Ie=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),De=()=>({...Ie(),velocityHistory:[],dragDistance:0,dragStartTime:0}),U=(e,t,o="horizontal")=>{let l=e.getBoundingClientRect(),r=o==="vertical",s=r?l.top:l.left,i=null,a=1/0;for(let p of t){if(p.offsetParent===null)continue;let u=p.getBoundingClientRect(),b=r?u.top:u.left,n=Math.abs(s-b);n<a&&(a=n,i=p);}return i},Ce=(e,t,o,l="horizontal")=>{let r=e.getBoundingClientRect(),s=l==="vertical",i=s?r.top:r.left,a=t.filter(f=>f.offsetParent!==null);if(a.length===0)return null;let p=0,u=1/0;a.forEach((f,v)=>{let T=f.getBoundingClientRect(),R=s?T.top:T.left,A=Math.abs(i-R);A<u&&(u=A,p=v);});let b=2,n=p;return Math.abs(o)>b&&(o>0?n=Math.min(p+1,a.length-1):n=Math.max(p-1,0)),a[n]??null},He=e=>{if(e.length===0)return 0;let t=0,o=0;return e.forEach((l,r)=>{let s=r+1;t+=l*s,o+=s;}),t/o},we=(e,t,o,l,r,s="horizontal",i=false)=>{let a=s==="vertical",p=e.velocity*C.MOMENTUM_RATIO,u=()=>{if(Math.abs(p)<C.MIN_VELOCITY){e.momentumId=null;let v=U(t,o,s);if(v){let T=a?v.offsetTop:v.offsetLeft;l(T,N);}r?.(v);return}let b=a?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,f=(a?t.scrollTop:t.scrollLeft)+p;i||(f<0||f>b)&&(p*=.5),a?t.scrollTop=Math.max(0,Math.min(b,f)):t.scrollLeft=Math.max(0,Math.min(b,f)),p*=C.FRICTION,e.momentumId=requestAnimationFrame(u);};e.momentumId=requestAnimationFrame(u);},oe=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,le=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,Re=(e,t)=>t==="vertical"?le(e):oe(e),ie=e=>{let {feed:t,slides:o,abortSignal:l,smoothScrollTo:r,onDragEnd:s,direction:i="horizontal",loop:a=false,touchRatio:p=1,shortSwipeThreshold:u=300,swipeDistanceThreshold:b=10}=e,n=De(),f=i==="vertical",v=()=>{if(!a)return o;let y=[],I=t.children;for(let D=0;D<I.length;D++){let M=I[D];(o.includes(M)||M.hasAttribute("data-lazer-clone"))&&y.push(M);}return y.length>0?y:o},T=0,A=()=>{T=f?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,f?t.clientHeight:t.clientWidth;},V=y=>{n.momentumId!==null&&(cancelAnimationFrame(n.momentumId),n.momentumId=null),A(),n.isDragging=true,n.startX=oe(y),n.startY=le(y),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"),y.type==="mousedown"&&y.preventDefault();},W=y=>{if(!n.isDragging)return;let I=Re(y,i),D=f?n.startY:n.startX,M=f?n.lastY:n.lastX,E=f?n.startScrollTop:n.startScrollLeft,H=performance.now(),c=H-n.lastTime,d=(D-I)*p,S=E+d;if(n.dragDistance=Math.abs(d),!a){if(S<0){let m=Math.abs(S),h=1-Math.min(m/C.MAX_EDGE_OVERSCROLL,1)*(1-C.EDGE_RESISTANCE);S=-m*h;}else if(S>T){let m=S-T,h=1-Math.min(m/C.MAX_EDGE_OVERSCROLL,1)*(1-C.EDGE_RESISTANCE);S=T+m*h;}}if(f?t.scrollTop=S:t.scrollLeft=S,c>0){let m=(M-I)/c*16;if(n.velocityHistory.length>0){let h=n.velocity;n.velocity=h*(1-C.VELOCITY_SMOOTHING)+m*C.VELOCITY_SMOOTHING;}else n.velocity=m;n.velocityHistory.push(m),n.velocityHistory.length>5&&n.velocityHistory.shift();}f?n.lastY=I:n.lastX=I,n.lastTime=H,y.type==="touchmove"&&y.preventDefault();},P=()=>{if(!n.isDragging)return;n.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let I=performance.now()-n.dragStartTime<u&&n.dragDistance>b,D=He(n.velocityHistory),M=v();if(!a){let E=f?t.scrollTop:t.scrollLeft;if(E<0||E>T){let H=E<0?0:T,c=E,d=performance.now(),S=()=>{let m=performance.now()-d,h=Math.min(m/C.BOUNCE_DURATION,1),L=N(h),w=c+(H-c)*L;if(f?t.scrollTop=w:t.scrollLeft=w,h<1)requestAnimationFrame(S);else {let x=U(t,M,i);if(x){let g=f?x.offsetTop:x.offsetLeft;r(g,N);}s?.(x);}};requestAnimationFrame(S);return}}if(I||Math.abs(D)>C.SHORT_SWIPE_VELOCITY){let E=Ce(t,M,D,i);if(E){let H=f?E.offsetTop:E.offsetLeft;r(H,N),s?.(E);}else s?.(null);}else if(Math.abs(n.velocity)>1&&!n.isLoopDragHandled)we(n,t,M,r,s,i,a);else {let E=U(t,M,i);if(!n.isLoopDragHandled){if(E){let H=f?E.offsetTop:E.offsetLeft;r(H,N);}s?.(E);}}};return t.addEventListener("mousedown",V,{signal:l}),document.addEventListener("mousemove",W,{signal:l}),document.addEventListener("mouseup",P,{signal:l}),t.addEventListener("touchstart",V,{passive:true,signal:l}),t.addEventListener("touchmove",W,{passive:false,signal:l}),t.addEventListener("touchend",P,{signal:l}),t.addEventListener("touchcancel",P,{signal:l}),document.addEventListener("mouseleave",P,{signal:l}),t.style.cursor="grab",n},ne=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var X=({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 s=t.map((a,p)=>({slide:a,originalIndex:p})).filter(({slide:a})=>a.offsetParent!==null);return s.length===0?(console.warn("No visible slides found"),[]):s.map(({slide:a,originalIndex:p},u)=>{let b=document.createElement("button");return b.type="button",b.classList.add(o),u===0&&b.classList.add(l),b.setAttribute("role","tab"),b.setAttribute("aria-selected",u===0?"true":"false"),b.setAttribute("aria-controls",r),b.setAttribute("aria-label",`Go to slide ${u+1}`),b.setAttribute("data-slide-index",String(u)),e.appendChild(b),b})};var j=({thumbsContainer:e,slides:t,thumbClass:o,thumbActiveClass:l,feedId:r,thumbImageSelector:s="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 a=t.map((u,b)=>({slide:u,originalIndex:b})).filter(({slide:u})=>u.offsetParent!==null);return a.length===0?(console.warn("No visible slides found"),[]):a.map(({slide:u,originalIndex:b},n)=>{let f=document.createElement("button");f.type="button",f.classList.add(o),n===0&&f.classList.add(l);let v=u.querySelector(s);if(v?.src){let T=document.createElement("img");T.src=v.src,T.alt=v.alt||`Slide ${n+1} thumbnail`,T.draggable=false,i&&(T.style.width=`${i.width}px`,T.style.height=`${i.height}px`,T.style.objectFit="cover"),f.appendChild(T);}return f.setAttribute("role","tab"),f.setAttribute("aria-selected",n===0?"true":"false"),f.setAttribute("aria-controls",r),f.setAttribute("aria-label",`Go to slide ${n+1}`),f.setAttribute("data-slide-index",String(n)),e.appendChild(f),f})};var ae=()=>({initialized:false,clonedSlides:[],styleElement:null}),se=()=>{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
- @keyframes lazer-marquee-scroll {
3
- 0% {
4
- transform: translateX(0);
5
- }
6
- 100% {
7
- transform: translateX(-50%);
8
- }
9
- }
10
- `,document.head.appendChild(t),t},Oe=(e,t)=>{t.initialized||(t.styleElement=se(),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);},ce=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false);},Pe=(e,t)=>{se(),requestAnimationFrame(()=>{let o=e.feed.scrollWidth,l=e.marqueeSpeed??50,r=e.marqueeDirection??"left",s=o/2;if(s<=0||l<=0){console.warn("[lazer-slider] Invalid marquee values:",{distance:s,speed:l,scrollWidth:o});return}let p=`lazer-marquee-scroll ${s/l}s linear infinite ${r==="right"?"reverse":"normal"}`;e.feed.style.animation="none",e.feed.offsetWidth,e.feed.style.animation=p,e.feed.style.animationPlayState=t.marqueePaused?"paused":"running";});},G=(e,t)=>{Pe(e,t);},de=(e,t)=>{t.feed.style.animation="",t.feed.style.animationPlayState="",t.feed.style.transform="",t.feed.style.willChange="";},Y=(e,t)=>{e.marqueePaused=true,t.feed.style.animationPlayState="paused";},$=(e,t)=>{e.marqueePaused=false,t.feed.style.animationPlayState="running";},ue=(e,t,o)=>{e.marquee&&(Oe(e,o),G(e,t));},fe=(e,t,o)=>{!e.marquee||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>Y(t,e),{signal:o}),e.feed.addEventListener("mouseleave",()=>$(t,e),{signal:o}),e.feed.addEventListener("touchstart",()=>Y(t,e),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>$(t,e),{signal:o}));};var me=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0}),qe=e=>{let t=z()?e.desktopSlidesPerView:e.mobileSlidesPerView;return !t||t==="auto"?1:Math.ceil(t)},pe=(e,t,o)=>{if(!e.loop||t.initialized)return;let l=t.realSlides,r=qe(e);t.clonesPerSide=r;for(let s=l.length-r;s<l.length;s++){let i=l[s];if(!i)continue;let a=i.cloneNode(true);a.setAttribute("data-lazer-clone","prepend"),a.setAttribute("aria-hidden","true"),e.feed.insertBefore(a,e.feed.firstChild),t.clonedSlides.push(a);}for(let s=0;s<r;s++){let i=l[s];if(!i)continue;let a=i.cloneNode(true);a.setAttribute("data-lazer-clone","append"),a.setAttribute("aria-hidden","true"),e.feed.appendChild(a),t.clonedSlides.push(a);}requestAnimationFrame(()=>{let s=l[0];s&&(o?e.feed.scrollTop=s.offsetTop:e.feed.scrollLeft=s.offsetLeft);}),t.initialized=true;},Se=(e,t,o,l,r,s,i)=>{if(!t.loop||!o.initialized)return;s(true);let a=o.realSlides,p=a.length;if(e==="next"){let u=a[0];u&&(l?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),r(0);}else {let u=a[p-1];u&&(l?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),r(p-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{s(false),i();});});},he=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0);};var K=(e,t,o)=>{if(t.autoplayIntervalId)return;let l=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||o("next");},l);},Q=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},be=e=>{e.autoplayPaused=true;},Te=e=>{e.autoplayPaused=false;},ve=(e,t,o)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>be(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>Te(t),{signal:o}),e.feed.addEventListener("touchstart",()=>be(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>Te(t),{signal:o}));};var J=(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="";}},Ee=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let o=e.scrollbarTrack.getBoundingClientRect().height,l=e.scrollbarThumb.getBoundingClientRect().height,r=o-l,s=e.feed.scrollHeight-e.feed.clientHeight,i=s>0?e.feed.scrollTop/s:0;e.scrollbarThumb.style.transform=`translateY(${r*i}px)`;}else {let o=e.scrollbarTrack.getBoundingClientRect().width,l=e.scrollbarThumb.getBoundingClientRect().width,r=o-l,s=e.feed.scrollWidth-e.feed.clientWidth,i=s>0?e.feed.scrollLeft/s:0;e.scrollbarThumb.style.transform=`translateX(${r*i}px)`;}};var Z=(e,t,o,l=B,r,s)=>{let i=o?e.scrollTop:e.scrollLeft,a=Math.abs(t-i),p=Math.min(O.MAX_DURATION,Math.max(O.MIN_DURATION,a/O.SPEED_FACTOR)),u=performance.now(),b=n=>{if(s?.cancelled)return;let f=(n-u)/p,v=Math.min(f,1),T=l(v),R=i+(t-i)*T;o?e.scrollTop=R:e.scrollLeft=R,v<1?requestAnimationFrame(b):(o?e.scrollTop=t:e.scrollLeft=t,r?.());};requestAnimationFrame(b);},k=e=>e.filter(t=>t.offsetParent!==null),ee=(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(a=>{a.style.flex="",a.style.minWidth="",a.style.minHeight="";});return}let i=`calc((100% - ${r*(l-1)}px) / ${l})`;t?e.slides.forEach(a=>{a.style.flex=`0 0 ${i}`,a.style.minHeight=i,a.style.minWidth="";}):e.slides.forEach(a=>{a.style.flex=`0 0 ${i}`,a.style.minWidth=i,a.style.minHeight="";});},ye=(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 Ne=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=X({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=j({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??B,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},s=null,i=me(e.slides),a=ae(),p={cancelled:false},u=null,b=()=>{let c=ye(e.feed,r.cachedFeedRect,r.lastWidth,o);return r.cachedFeedRect=c.rect,r.lastWidth=c.size,c.rect},n=(c,d)=>{Z(e.feed,c,o,l,d);},f=(c,d)=>{p.cancelled=true,p={cancelled:false},Z(e.feed,c,o,d??l,void 0,p);},v=()=>{if(r.isLoopRepositioning)return;let c=b(),d,S,m;if(o?(d=e.feed.scrollTop<=1,S=e.feed.scrollTop+c.height>=e.feed.scrollHeight-1,m=e.feed.scrollHeight<=c.height):(d=e.feed.scrollLeft<=1,S=e.feed.scrollLeft+c.width>=e.feed.scrollWidth-1,m=e.feed.scrollWidth<=c.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=m?"none":"block"),e.loop){_(e.prevSlideButton,!m,e.feed),_(e.nextSlideButton,!m,e.feed);return}_(e.prevSlideButton,!d&&!m,e.feed),_(e.nextSlideButton,!S&&!m,e.feed);},T=()=>{let c=b(),d=i.initialized?i.realSlides:k(e.slides),S=d.filter(m=>{let h=m.getBoundingClientRect(),L=20;return o?h.bottom>c.top+L&&h.top<c.bottom-L:h.right>c.left+L&&h.left<c.right-L});if(S.length&&S[0]){let m=d.indexOf(S[0]);if(m!==-1){r.currentSlideIndex=m;let h=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:h,currentSlideIndex:r.currentSlideIndex});}}},R=c=>{if(!e.thumbs)return;let d=e.thumbs.indexOf(c);if(d===-1||!e.slides[d])return;r.currentSlideIndex=d,F(e.thumbs,d),r.isScrolling=true,r.updateThumbTimeout&&clearTimeout(r.updateThumbTimeout),r.updateThumbTimeout=setTimeout(()=>{r.isScrolling=false;},O.THUMB_UPDATE_DELAY);let S=o?e.slides[d].offsetTop:e.slides[d].offsetLeft;n(S);},A=c=>{let d=i.initialized?i.realSlides:k(e.slides),S=z()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,m=d.length;T();let h,L=false;if(c==="prev")if(e.loop&&i.initialized&&r.currentSlideIndex===0){let g=i.clonedSlides.filter(q=>q.getAttribute("data-lazer-clone")==="prepend");h=g[g.length-1],L=true;}else r.currentSlideIndex=Math.max(0,r.currentSlideIndex-S),h=d[r.currentSlideIndex];else e.loop&&i.initialized&&r.currentSlideIndex>=m-1?(h=i.clonedSlides.filter(q=>q.getAttribute("data-lazer-clone")==="append")[0],L=true):(r.currentSlideIndex=Math.min(m-1,r.currentSlideIndex+S),h=d[r.currentSlideIndex]);if(!h)return;let w=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:w,target:h,direction:c});let x=o?h.offsetTop:h.offsetLeft;L?n(x,()=>{Se(c,e,i,o,g=>{r.currentSlideIndex=g;},g=>{r.isLoopRepositioning=g;},v);}):n(x);},V=()=>{Ee(e,o),v(),T(),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});},O.SCROLL_END_DELAY);},W=()=>{r.ticking||(requestAnimationFrame(()=>{V(),r.ticking=false;}),r.ticking=true);},P=()=>{let c=r.currentSlideIndex;r.cachedFeedRect=null;let d=()=>{let m=(i.initialized?i.realSlides:k(e.slides))[c];if(m){let h=o?m.offsetTop:m.offsetLeft;o?e.feed.scrollTop=h:e.feed.scrollLeft=h;}};d(),u&&clearTimeout(u),u=setTimeout(()=>{D(),d();},150);},y=()=>{let{signal:c}=r.abortController;window.addEventListener("resize",P),e.feed.addEventListener("scroll",W,{passive:true,signal:c}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>A("prev"),{signal:c}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>A("next"),{signal:c}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(d=>{d.addEventListener("click",()=>R(d),{signal:c});})),re(e.feed,()=>A("prev"),()=>A("next"),c,t),e.enableDragToScroll!==false&&(s=ie({feed:e.feed,slides:e.slides,abortSignal:c,smoothScrollTo:f,onDragEnd:d=>{let S=d?.getAttribute("data-lazer-clone");if(!!(S&&e.loop&&i.initialized)&&d){let h=i.realSlides,L=0,w;if(S==="prepend"){let g=i.clonedSlides.filter(q=>q.getAttribute("data-lazer-clone")==="prepend").indexOf(d);L=h.length-i.clonesPerSide+g,w=h[L];}else if(S==="append"){let g=i.clonedSlides.filter(q=>q.getAttribute("data-lazer-clone")==="append").indexOf(d);L=g,w=h[g];}if(w){r.currentSlideIndex=L;let x=o?w.offsetTop:w.offsetLeft;setTimeout(()=>{p.cancelled=true,o?e.feed.scrollTop=x:e.feed.scrollLeft=x;},O.MIN_DURATION),F(e.thumbs,r.currentSlideIndex);}}else T(),F(e.thumbs,r.currentSlideIndex);},direction:t,loop:e.loop})),ve(e,r,c),fe(e,r,c);},I=c=>{let d=i.initialized?i.realSlides:k(e.slides),S=Math.max(0,Math.min(c,d.length-1)),m=d[S];if(!m)return;r.currentSlideIndex=S,F(e.thumbs,S);let h=o?m.offsetTop:m.offsetLeft;n(h);},D=()=>{r.cachedFeedRect=null,ee(e,o,z()),J(e,b(),o),v(),e.marquee&&!r.marqueePaused&&G(e,r);},M=()=>{Q(r),de(r,e),r.abortController.abort(),window.removeEventListener("resize",P),r.updateThumbTimeout&&clearTimeout(r.updateThumbTimeout),r.scrollEndTimeout&&clearTimeout(r.scrollEndTimeout),u&&clearTimeout(u),s&&ne(s),he(i),ce(a),r.cachedFeedRect=null;},E=()=>{e.marquee?r.marqueePaused?$(r,e):G(e,r):e.autoplay&&K(e,r,A);},H=()=>{e.marquee?Y(r,e):Q(r);};return te(e),ee(e,o,z()),e.marquee?ue(e,r,a):(pe(e,i,o),e.autoplay&&K(e,r,A)),v(),y(),J(e,b(),o),{goToIndex:I,refresh:D,unload:M,play:E,pause:H,next:()=>A("next"),prev:()=>A("prev")}};exports.createSlider=Ne;exports.easeInOutCubic=ge;exports.easeOutCubic=N;exports.easeOutExpo=B;exports.easeOutQuad=Ae;exports.generateBullets=X;exports.generateThumbs=j;exports.linear=Me;
1
+ 'use strict';var H={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},ve="(min-width: 64rem)",N=()=>window.matchMedia(ve).matches;var k=e=>e===1?1:1-Math.pow(2,-10*e),w=e=>1-Math.pow(1-e,3),Ee=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Le=e=>1-(1-e)*(1-e),Ae=e=>e;var ye=()=>`slider-${Math.random().toString(36).substring(2,9)}`,le=e=>{let{feed:t,prevSlideButton:l,nextSlideButton:i,thumbs:o,slides:c}=e;t.id||(t.id=ye()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),c.forEach((r,a)=>{r.setAttribute("role","group"),r.setAttribute("aria-roledescription","slide"),r.setAttribute("aria-label",`Slide ${a+1} of ${c.length}`);}),l&&(l.setAttribute("aria-label","Previous slide"),l.setAttribute("aria-controls",t.id),l.setAttribute("tabindex","0"),l.tagName!=="BUTTON"&&l.setAttribute("role","button")),i&&(i.setAttribute("aria-label","Next slide"),i.setAttribute("aria-controls",t.id),i.setAttribute("tabindex","0"),i.tagName!=="BUTTON"&&i.setAttribute("role","button")),o?.length&&o.forEach((r,a)=>{r.tagName!=="BUTTON"&&r.setAttribute("role","button"),r.setAttribute("aria-label",`Go to slide ${a+1}`),r.setAttribute("tabindex","0"),r.setAttribute("aria-controls",t.id);});},W=(e,t,l)=>{if(!e)return;!t&&e===document.activeElement&&l&&l.focus();let i="opacity 0.3s ease",o=t?"1":"0";Object.assign(e.style,{opacity:o,transition:i,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,l="active")=>{e?.length&&e.forEach((i,o)=>{let c=o===t;i.classList.toggle(l,c),i.setAttribute("aria-selected",c.toString());});},re=(e,t,l,i,o="horizontal")=>{let c=o==="vertical",r=c?"ArrowUp":"ArrowLeft",a=c?"ArrowDown":"ArrowRight";e.addEventListener("keydown",u=>{switch(u.key){case r:u.preventDefault(),t();break;case a:u.preventDefault(),l();break}},{signal:i}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var D={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},ge=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),xe=()=>({...ge(),velocityHistory:[],dragDistance:0,dragStartTime:0}),$=(e,t,l="horizontal")=>{let i=e.getBoundingClientRect(),o=l==="vertical",c=o?i.top:i.left,r=null,a=1/0;for(let u of t){if(u.offsetParent===null)continue;let f=u.getBoundingClientRect(),p=o?f.top:f.left,E=Math.abs(c-p);E<a&&(a=E,r=u);}return r},Ie=(e,t,l,i="horizontal")=>{let o=e.getBoundingClientRect(),c=i==="vertical",r=c?o.top:o.left,a=t.filter(n=>n.offsetParent!==null);if(a.length===0)return null;let u=0,f=1/0;a.forEach((n,S)=>{let L=n.getBoundingClientRect(),v=c?L.top:L.left,O=Math.abs(r-v);O<f&&(f=O,u=S);});let p=2,E=u;return Math.abs(l)>p&&(l>0?E=Math.min(u+1,a.length-1):E=Math.max(u-1,0)),a[E]??null},Me=e=>{if(e.length===0)return 0;let t=0,l=0;return e.forEach((i,o)=>{let c=o+1;t+=i*c,l+=c;}),t/l},De=(e,t,l,i,o,c="horizontal",r=false)=>{let a=c==="vertical",u=e.velocity*D.MOMENTUM_RATIO,f=()=>{if(Math.abs(u)<D.MIN_VELOCITY){e.momentumId=null;let S=$(t,l,c);if(S){let L=a?S.offsetTop:S.offsetLeft;i(L,w);}o?.(S);return}let p=a?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,n=(a?t.scrollTop:t.scrollLeft)+u;r||(n<0||n>p)&&(u*=.5),a?t.scrollTop=Math.max(0,Math.min(p,n)):t.scrollLeft=Math.max(0,Math.min(p,n)),u*=D.FRICTION,e.momentumId=requestAnimationFrame(f);};e.momentumId=requestAnimationFrame(f);},ie=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,ne=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,Ce=(e,t)=>t==="vertical"?ne(e):ie(e),ae=e=>{let {feed:t,slides:l,abortSignal:i,smoothScrollTo:o,onDragStart:c,onDragEnd:r,direction:a="horizontal",loop:u=false,touchRatio:f=1,shortSwipeThreshold:p=300,swipeDistanceThreshold:E=10}=e,n=xe(),S=a==="vertical",L=()=>{if(!u)return l;let A=[],M=t.children;for(let C=0;C<M.length;C++){let x=M[C];(l.includes(x)||x.hasAttribute("data-lazer-clone"))&&A.push(x);}return A.length>0?A:l},v=0,U=()=>{v=S?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,S?t.clientHeight:t.clientWidth;},B=A=>{n.momentumId!==null&&(cancelAnimationFrame(n.momentumId),n.momentumId=null),U(),c?.(),n.isDragging=true,n.startX=ie(A),n.startY=ne(A),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"),A.type==="mousedown"&&A.preventDefault();},X=A=>{if(!n.isDragging)return;let M=Ce(A,a),C=S?n.startY:n.startX,x=S?n.lastY:n.lastX,s=S?n.startScrollTop:n.startScrollLeft,d=performance.now(),b=d-n.lastTime,h=(C-M)*f,m=s+h;if(n.dragDistance=Math.abs(h),!u){if(m<0){let T=Math.abs(m),y=1-Math.min(T/D.MAX_EDGE_OVERSCROLL,1)*(1-D.EDGE_RESISTANCE);m=-T*y;}else if(m>v){let T=m-v,y=1-Math.min(T/D.MAX_EDGE_OVERSCROLL,1)*(1-D.EDGE_RESISTANCE);m=v+T*y;}}if(S?t.scrollTop=m:t.scrollLeft=m,b>0){let T=(x-M)/b*16;if(n.velocityHistory.length>0){let y=n.velocity;n.velocity=y*(1-D.VELOCITY_SMOOTHING)+T*D.VELOCITY_SMOOTHING;}else n.velocity=T;n.velocityHistory.push(T),n.velocityHistory.length>5&&n.velocityHistory.shift();}S?n.lastY=M:n.lastX=M,n.lastTime=d,A.type==="touchmove"&&A.preventDefault();},P=()=>{if(!n.isDragging)return;n.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let M=performance.now()-n.dragStartTime<p&&n.dragDistance>E,C=Me(n.velocityHistory),x=L();if(!u){let s=S?t.scrollTop:t.scrollLeft;if(s<0||s>v){let d=s<0?0:v,b=s,h=performance.now(),m=()=>{let T=performance.now()-h,y=Math.min(T/D.BOUNCE_DURATION,1),R=w(y),g=b+(d-b)*R;if(S?t.scrollTop=g:t.scrollLeft=g,y<1)requestAnimationFrame(m);else {let I=$(t,x,a);if(I){let Te=S?I.offsetTop:I.offsetLeft;o(Te,w);}r?.(I);}};requestAnimationFrame(m);return}}if(M||Math.abs(C)>D.SHORT_SWIPE_VELOCITY){let s=Ie(t,x,C,a);if(s){let d=S?s.offsetTop:s.offsetLeft;o(d,w),r?.(s);}else r?.(null);}else if(Math.abs(n.velocity)>1&&!n.isLoopDragHandled)De(n,t,x,o,r,a,u);else {let s=$(t,x,a);if(!n.isLoopDragHandled){if(s){let d=S?s.offsetTop:s.offsetLeft;o(d,w);}r?.(s);}}};return t.addEventListener("mousedown",B,{signal:i}),document.addEventListener("mousemove",X,{signal:i}),document.addEventListener("mouseup",P,{signal:i}),t.addEventListener("touchstart",B,{passive:true,signal:i}),t.addEventListener("touchmove",X,{passive:false,signal:i}),t.addEventListener("touchend",P,{signal:i}),t.addEventListener("touchcancel",P,{signal:i}),document.addEventListener("mouseleave",P,{signal:i}),t.style.cursor="grab",n},ce=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var q=({bulletsContainer:e,slides:t,bulletClass:l,bulletActiveClass:i,feedId:o})=>{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(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="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 c=t.map((a,u)=>({slide:a,originalIndex:u})).filter(({slide:a})=>a.offsetParent!==null);return c.length===0?(console.warn("No visible slides found"),[]):c.map(({slide:a,originalIndex:u},f)=>{let p=document.createElement("button");return p.type="button",p.classList.add(l),f===0&&p.classList.add(i),p.setAttribute("role","tab"),p.setAttribute("aria-selected",f===0?"true":"false"),p.setAttribute("aria-controls",o),p.setAttribute("aria-label",`Go to slide ${f+1}`),p.setAttribute("data-slide-index",String(f)),e.appendChild(p),p})};var j=({thumbsContainer:e,slides:t,thumbClass:l,thumbActiveClass:i,feedId:o,thumbImageSelector:c="img",thumbSize:r})=>{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(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="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 a=t.map((f,p)=>({slide:f,originalIndex:p})).filter(({slide:f})=>f.offsetParent!==null);return a.length===0?(console.warn("No visible slides found"),[]):a.map(({slide:f,originalIndex:p},E)=>{let n=document.createElement("button");n.type="button",n.classList.add(l),E===0&&n.classList.add(i);let S=f.querySelector(c);if(S?.src){let L=document.createElement("img");L.src=S.src,L.alt=S.alt||`Slide ${E+1} thumbnail`,L.draggable=false,r&&(L.style.width=`${r.width}px`,L.style.height=`${r.height}px`,L.style.objectFit="cover"),n.appendChild(L);}return n.setAttribute("role","tab"),n.setAttribute("aria-selected",E===0?"true":"false"),n.setAttribute("aria-controls",o),n.setAttribute("aria-label",`Go to slide ${E+1}`),n.setAttribute("data-slide-index",String(E)),e.appendChild(n),n})};var _=(e,t,l,i)=>{if(t.autoScrollAnimationId!==null)return;t.autoScrollPaused=false,t.autoScrollStopped=false,t.autoScrollLastTimestamp=performance.now();let o=e.autoScrollSpeed??50,c=e.autoScrollDirection??"forward",r=a=>{if(t.autoScrollPaused||t.autoScrollStopped){t.autoScrollAnimationId=null;return}let u=a-t.autoScrollLastTimestamp;t.autoScrollLastTimestamp=a,u>100&&(u=100);let f=o*(u/1e3);c==="backward"&&(f=-f),i?e.feed.scrollTop+=f:e.feed.scrollLeft+=f,Re(e,l,i,c),t.autoScrollAnimationId=requestAnimationFrame(r);};t.autoScrollAnimationId=requestAnimationFrame(r);},Re=(e,t,l,i)=>{if(!t.initialized||t.realSlides.length===0)return;let o=e.feed;if(i==="forward"){let c=l?o.scrollHeight-o.clientHeight:o.scrollWidth-o.clientWidth;if((l?o.scrollTop:o.scrollLeft)>=c-1){let a=t.realSlides[0];a&&(l?o.scrollTop=a.offsetTop:o.scrollLeft=a.offsetLeft);}}else if((l?o.scrollTop:o.scrollLeft)<=1){let r=t.realSlides[t.realSlides.length-1];r&&(l?o.scrollTop=r.offsetTop:o.scrollLeft=r.offsetLeft);}},K=e=>{e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null),e.autoScrollResumeTimeout!==null&&(clearTimeout(e.autoScrollResumeTimeout),e.autoScrollResumeTimeout=null);},z=e=>{e.autoScrollPaused=true,e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null);},G=(e,t,l,i)=>{t.autoScrollStopped||(t.autoScrollLastTimestamp=performance.now(),t.autoScrollPaused=false,t.autoScrollAnimationId===null&&_(e,t,l,i));},Y=(e,t,l,i)=>{if(t.autoScrollStopped)return;t.autoScrollResumeTimeout!==null&&clearTimeout(t.autoScrollResumeTimeout);let o=e.autoScrollStartDelay??0;o>0?t.autoScrollResumeTimeout=setTimeout(()=>{t.autoScrollResumeTimeout=null,G(e,t,l,i);},o):G(e,t,l,i);},se=(e,t,l,i,o)=>{if(!e.autoScroll)return;let c=e.stopOnMouseEnter!==false,r=e.stopOnFocusIn!==false;c&&(e.feed.addEventListener("mouseenter",()=>z(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>Y(e,t,l,i),{signal:o})),r&&(e.feed.addEventListener("focusin",()=>z(t),{signal:o}),e.feed.addEventListener("focusout",()=>Y(e,t,l,i),{signal:o})),e.feed.addEventListener("touchstart",()=>z(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>Y(e,t,l,i),{signal:o});};var de=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0}),He=e=>{let t=N()?e.desktopSlidesPerView:e.mobileSlidesPerView;if(e.autoScroll){let l=!t||t==="auto"?3:Math.ceil(t)+1;return Math.min(l,e.slides.length)}return !t||t==="auto"?1:Math.ceil(t)},Q=(e,t,l)=>{if(!e.loop||t.initialized)return;let i=t.realSlides,o=He(e);t.clonesPerSide=o;for(let c=i.length-o;c<i.length;c++){let r=i[c];if(!r)continue;let a=r.cloneNode(true);a.setAttribute("data-lazer-clone","prepend"),a.setAttribute("aria-hidden","true"),e.feed.insertBefore(a,e.feed.firstChild),t.clonedSlides.push(a);}for(let c=0;c<o;c++){let r=i[c];if(!r)continue;let a=r.cloneNode(true);a.setAttribute("data-lazer-clone","append"),a.setAttribute("aria-hidden","true"),e.feed.appendChild(a),t.clonedSlides.push(a);}requestAnimationFrame(()=>{let c=i[0];c&&(l?e.feed.scrollTop=c.offsetTop:e.feed.scrollLeft=c.offsetLeft);}),t.initialized=true;},ue=(e,t,l,i,o,c,r)=>{if(!t.loop||!l.initialized)return;c(true);let a=l.realSlides,u=a.length;if(e==="next"){let f=a[0];f&&(i?t.feed.scrollTop=f.offsetTop:t.feed.scrollLeft=f.offsetLeft),o(0);}else {let f=a[u-1];f&&(i?t.feed.scrollTop=f.offsetTop:t.feed.scrollLeft=f.offsetLeft),o(u-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(false),r();});});},fe=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0);};var J=(e,t,l)=>{if(t.autoplayIntervalId)return;let i=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||l("next");},i);},Z=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},me=e=>{e.autoplayPaused=true;},pe=e=>{e.autoplayPaused=false;},Se=(e,t,l)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>me(t),{signal:l}),e.feed.addEventListener("mouseleave",()=>pe(t),{signal:l}),e.feed.addEventListener("touchstart",()=>me(t),{passive:true,signal:l}),e.feed.addEventListener("touchend",()=>pe(t),{signal:l}));};var ee=(e,t,l)=>{if(e.scrollbarThumb)if(l){let i=t.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${i}%`,e.scrollbarThumb.style.width="";}else {let i=t.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${i}%`,e.scrollbarThumb.style.height="";}},he=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let l=e.scrollbarTrack.getBoundingClientRect().height,i=e.scrollbarThumb.getBoundingClientRect().height,o=l-i,c=e.feed.scrollHeight-e.feed.clientHeight,r=c>0?e.feed.scrollTop/c:0;e.scrollbarThumb.style.transform=`translateY(${o*r}px)`;}else {let l=e.scrollbarTrack.getBoundingClientRect().width,i=e.scrollbarThumb.getBoundingClientRect().width,o=l-i,c=e.feed.scrollWidth-e.feed.clientWidth,r=c>0?e.feed.scrollLeft/c:0;e.scrollbarThumb.style.transform=`translateX(${o*r}px)`;}};var te=(e,t,l,i=k,o,c)=>{let r=l?e.scrollTop:e.scrollLeft,a=Math.abs(t-r),u=Math.min(H.MAX_DURATION,Math.max(H.MIN_DURATION,a/H.SPEED_FACTOR)),f=performance.now(),p=E=>{if(c?.cancelled)return;let n=(E-f)/u,S=Math.min(n,1),L=i(S),v=r+(t-r)*L;l?e.scrollTop=v:e.scrollLeft=v,S<1?requestAnimationFrame(p):(l?e.scrollTop=t:e.scrollLeft=t,o?.());};requestAnimationFrame(p);},V=e=>e.filter(t=>t.offsetParent!==null),oe=(e,t,l)=>{let i=l?e.desktopSlidesPerView:e.mobileSlidesPerView,o=e.slideGap??0;if(o>0&&(e.feed.style.gap=`${o}px`),!i||i==="auto"){e.slides.forEach(a=>{a.style.flex="",a.style.minWidth="",a.style.minHeight="";});return}let r=`calc((100% - ${o*(i-1)}px) / ${i})`;t?e.slides.forEach(a=>{a.style.flex=`0 0 ${r}`,a.style.minHeight=r,a.style.minWidth="";}):e.slides.forEach(a=>{a.style.flex=`0 0 ${r}`,a.style.minWidth=r,a.style.minHeight="";});},be=(e,t,l,i)=>{let o=i?e.clientHeight:e.clientWidth;return !t||l!==o?{rect:e.getBoundingClientRect(),size:o}:{rect:t,size:l}};var we=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 s=q({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=s;}if(e.thumbsContainer&&!e.thumbs){let s=j({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=s;}let t=e.direction??"horizontal",l=t==="vertical",i=e.easing??k,o={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,autoScrollAnimationId:null,autoScrollPaused:false,autoScrollLastTimestamp:0,autoScrollStopped:false,autoScrollResumeTimeout:null,isLoopRepositioning:false},c=null,r=de(e.slides),a={cancelled:false},u=null,f=()=>{let s=be(e.feed,o.cachedFeedRect,o.lastWidth,l);return o.cachedFeedRect=s.rect,o.lastWidth=s.size,s.rect},p=(s,d)=>{te(e.feed,s,l,i,d);},E=(s,d)=>{a.cancelled=true,a={cancelled:false},te(e.feed,s,l,d??i,void 0,a);},n=()=>{if(o.isLoopRepositioning)return;let s=f(),d,b,h;if(l?(d=e.feed.scrollTop<=1,b=e.feed.scrollTop+s.height>=e.feed.scrollHeight-1,h=e.feed.scrollHeight<=s.height):(d=e.feed.scrollLeft<=1,b=e.feed.scrollLeft+s.width>=e.feed.scrollWidth-1,h=e.feed.scrollWidth<=s.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=h?"none":"block"),e.loop){W(e.prevSlideButton,!h,e.feed),W(e.nextSlideButton,!h,e.feed);return}W(e.prevSlideButton,!d&&!h,e.feed),W(e.nextSlideButton,!b&&!h,e.feed);},S=()=>{let s=f(),d=r.initialized?r.realSlides:V(e.slides),b=d.filter(h=>{let m=h.getBoundingClientRect(),T=20;return l?m.bottom>s.top+T&&m.top<s.bottom-T:m.right>s.left+T&&m.left<s.right-T});if(b.length&&b[0]){let h=d.indexOf(b[0]);if(h!==-1){o.currentSlideIndex=h;let m=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:m,currentSlideIndex:o.currentSlideIndex});}}},L=s=>{if(!e.thumbs)return;let d=e.thumbs.indexOf(s);if(d===-1||!e.slides[d])return;o.currentSlideIndex=d,F(e.thumbs,d),o.isScrolling=true,o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.updateThumbTimeout=setTimeout(()=>{o.isScrolling=false;},H.THUMB_UPDATE_DELAY);let b=l?e.slides[d].offsetTop:e.slides[d].offsetLeft;p(b);},v=s=>{let d=r.initialized?r.realSlides:V(e.slides),b=N()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,h=d.length;S();let m,T=false;if(s==="prev")if(e.loop&&r.initialized&&o.currentSlideIndex===0){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="prepend");m=g[g.length-1],T=true;}else o.currentSlideIndex=Math.max(0,o.currentSlideIndex-b),m=d[o.currentSlideIndex];else e.loop&&r.initialized&&o.currentSlideIndex>=h-1?(m=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="append")[0],T=true):(o.currentSlideIndex=Math.min(h-1,o.currentSlideIndex+b),m=d[o.currentSlideIndex]);if(!m)return;let y=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:y,target:m,direction:s});let R=l?m.offsetTop:m.offsetLeft;T?p(R,()=>{ue(s,e,r,l,g=>{o.currentSlideIndex=g;},g=>{o.isLoopRepositioning=g;},n);}):p(R);},O=()=>{he(e,l),n(),S(),o.isScrolling||F(e.thumbs,o.currentSlideIndex),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),o.scrollEndTimeout=setTimeout(()=>{o.isScrolling=false;let s=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:s,currentSlideIndex:o.currentSlideIndex});},H.SCROLL_END_DELAY);},U=()=>{o.ticking||(requestAnimationFrame(()=>{O(),o.ticking=false;}),o.ticking=true);},B=()=>{let s=o.currentSlideIndex;o.cachedFeedRect=null;let d=()=>{let h=(r.initialized?r.realSlides:V(e.slides))[s];if(h){let m=l?h.offsetTop:h.offsetLeft;l?e.feed.scrollTop=m:e.feed.scrollLeft=m;}};d(),u&&clearTimeout(u),u=setTimeout(()=>{A(),d();},150);},X=()=>{let{signal:s}=o.abortController;window.addEventListener("resize",B),e.feed.addEventListener("scroll",U,{passive:true,signal:s}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>v("prev"),{signal:s}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>v("next"),{signal:s}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(d=>{d.addEventListener("click",()=>L(d),{signal:s});})),re(e.feed,()=>v("prev"),()=>v("next"),s,t),e.enableDragToScroll!==false&&(c=ae({feed:e.feed,slides:e.slides,abortSignal:s,smoothScrollTo:E,onDragStart:()=>{e.autoScroll&&z(o);},onDragEnd:d=>{let b=d?.getAttribute("data-lazer-clone");if(!!(b&&e.loop&&r.initialized)&&d){let m=r.realSlides,T=0,y;if(b==="prepend"){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="prepend").indexOf(d);T=m.length-r.clonesPerSide+g,y=m[T];}else if(b==="append"){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="append").indexOf(d);T=g,y=m[g];}if(y){o.currentSlideIndex=T;let R=l?y.offsetTop:y.offsetLeft;setTimeout(()=>{a.cancelled=true,l?e.feed.scrollTop=R:e.feed.scrollLeft=R;},H.MIN_DURATION),F(e.thumbs,o.currentSlideIndex);}}else S(),F(e.thumbs,o.currentSlideIndex);e.autoScroll&&!o.autoScrollStopped&&(e.stopOnInteraction?o.autoScrollStopped=true:Y(e,o,r,l));},direction:t,loop:e.loop})),Se(e,o,s),se(e,o,r,l,s);},P=s=>{let d=r.initialized?r.realSlides:V(e.slides),b=Math.max(0,Math.min(s,d.length-1)),h=d[b];if(!h)return;o.currentSlideIndex=b,F(e.thumbs,b);let m=l?h.offsetTop:h.offsetLeft;p(m);},A=()=>{o.cachedFeedRect=null,oe(e,l,N()),ee(e,f(),l),n(),e.autoScroll&&!o.autoScrollPaused&&!o.autoScrollStopped&&(K(o),_(e,o,r,l));},M=()=>{Z(o),K(o),o.abortController.abort(),window.removeEventListener("resize",B),o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),u&&clearTimeout(u),c&&ce(c),fe(r),o.cachedFeedRect=null;},C=()=>{e.autoScroll?(o.autoScrollStopped=false,o.autoScrollPaused?G(e,o,r,l):_(e,o,r,l)):e.autoplay&&J(e,o,v);},x=()=>{e.autoScroll?z(o):Z(o);};if(le(e),oe(e,l,N()),e.autoScroll){e.loop=true,Q(e,r,l);let s=e.autoScrollStartDelay??0;s>0?o.autoScrollResumeTimeout=setTimeout(()=>{o.autoScrollResumeTimeout=null,_(e,o,r,l);},s):requestAnimationFrame(()=>{requestAnimationFrame(()=>{_(e,o,r,l);});});}else Q(e,r,l),e.autoplay&&J(e,o,v);return n(),X(),ee(e,f(),l),{goToIndex:P,refresh:A,unload:M,play:C,pause:x,next:()=>v("next"),prev:()=>v("prev")}};exports.createSlider=we;exports.easeInOutCubic=Ee;exports.easeOutCubic=w;exports.easeOutExpo=k;exports.easeOutQuad=Le;exports.generateBullets=q;exports.generateThumbs=j;exports.linear=Ae;
package/dist/index.d.cts CHANGED
@@ -11,9 +11,9 @@ type SliderNavDirection = 'prev' | 'next';
11
11
  */
12
12
  type SliderDirection = 'horizontal' | 'vertical';
13
13
  /**
14
- * Direction of marquee scroll
14
+ * Direction of auto-scroll
15
15
  */
16
- type MarqueeDirection = 'left' | 'right';
16
+ type AutoScrollDirection = 'forward' | 'backward';
17
17
  /**
18
18
  * Parameters passed to scroll start callback
19
19
  */
@@ -51,9 +51,13 @@ interface SliderSettings {
51
51
  autoplay?: boolean;
52
52
  autoplayInterval?: number;
53
53
  pauseOnHover?: boolean;
54
- marquee?: boolean;
55
- marqueeSpeed?: number;
56
- marqueeDirection?: MarqueeDirection;
54
+ autoScroll?: boolean;
55
+ autoScrollSpeed?: number;
56
+ autoScrollDirection?: AutoScrollDirection;
57
+ autoScrollStartDelay?: number;
58
+ stopOnInteraction?: boolean;
59
+ stopOnMouseEnter?: boolean;
60
+ stopOnFocusIn?: boolean;
57
61
  easing?: EasingFunction;
58
62
  onScrollStart?: (params: ScrollStartParams) => void;
59
63
  onScroll?: (params: ScrollParams) => void;
@@ -84,9 +88,11 @@ interface SliderState {
84
88
  abortController: AbortController;
85
89
  autoplayIntervalId: ReturnType<typeof setInterval> | null;
86
90
  autoplayPaused: boolean;
87
- marqueeAnimationId: number | null;
88
- marqueePaused: boolean;
89
- marqueeLastTimestamp: number;
91
+ autoScrollAnimationId: number | null;
92
+ autoScrollPaused: boolean;
93
+ autoScrollLastTimestamp: number;
94
+ autoScrollStopped: boolean;
95
+ autoScrollResumeTimeout: ReturnType<typeof setTimeout> | null;
90
96
  isLoopRepositioning: boolean;
91
97
  }
92
98
  /**
@@ -164,4 +170,4 @@ interface GenerateThumbsParams {
164
170
  }
165
171
  declare const generateThumbs: ({ thumbsContainer, slides, thumbClass, thumbActiveClass, feedId, thumbImageSelector, thumbSize }: GenerateThumbsParams) => HTMLElement[];
166
172
 
167
- export { type DragState, type EasingFunction, type MarqueeDirection, type ScrollParams, type ScrollStartParams, type Slider, type SliderDirection, type SliderNavDirection, type SliderSettings, type SliderState, createSlider, easeInOutCubic, easeOutCubic, easeOutExpo, easeOutQuad, generateBullets, generateThumbs, linear };
173
+ export { type AutoScrollDirection, type DragState, type EasingFunction, type ScrollParams, type ScrollStartParams, type Slider, type SliderDirection, type SliderNavDirection, type SliderSettings, type SliderState, createSlider, easeInOutCubic, easeOutCubic, easeOutExpo, easeOutQuad, generateBullets, generateThumbs, linear };
package/dist/index.d.ts CHANGED
@@ -11,9 +11,9 @@ type SliderNavDirection = 'prev' | 'next';
11
11
  */
12
12
  type SliderDirection = 'horizontal' | 'vertical';
13
13
  /**
14
- * Direction of marquee scroll
14
+ * Direction of auto-scroll
15
15
  */
16
- type MarqueeDirection = 'left' | 'right';
16
+ type AutoScrollDirection = 'forward' | 'backward';
17
17
  /**
18
18
  * Parameters passed to scroll start callback
19
19
  */
@@ -51,9 +51,13 @@ interface SliderSettings {
51
51
  autoplay?: boolean;
52
52
  autoplayInterval?: number;
53
53
  pauseOnHover?: boolean;
54
- marquee?: boolean;
55
- marqueeSpeed?: number;
56
- marqueeDirection?: MarqueeDirection;
54
+ autoScroll?: boolean;
55
+ autoScrollSpeed?: number;
56
+ autoScrollDirection?: AutoScrollDirection;
57
+ autoScrollStartDelay?: number;
58
+ stopOnInteraction?: boolean;
59
+ stopOnMouseEnter?: boolean;
60
+ stopOnFocusIn?: boolean;
57
61
  easing?: EasingFunction;
58
62
  onScrollStart?: (params: ScrollStartParams) => void;
59
63
  onScroll?: (params: ScrollParams) => void;
@@ -84,9 +88,11 @@ interface SliderState {
84
88
  abortController: AbortController;
85
89
  autoplayIntervalId: ReturnType<typeof setInterval> | null;
86
90
  autoplayPaused: boolean;
87
- marqueeAnimationId: number | null;
88
- marqueePaused: boolean;
89
- marqueeLastTimestamp: number;
91
+ autoScrollAnimationId: number | null;
92
+ autoScrollPaused: boolean;
93
+ autoScrollLastTimestamp: number;
94
+ autoScrollStopped: boolean;
95
+ autoScrollResumeTimeout: ReturnType<typeof setTimeout> | null;
90
96
  isLoopRepositioning: boolean;
91
97
  }
92
98
  /**
@@ -164,4 +170,4 @@ interface GenerateThumbsParams {
164
170
  }
165
171
  declare const generateThumbs: ({ thumbsContainer, slides, thumbClass, thumbActiveClass, feedId, thumbImageSelector, thumbSize }: GenerateThumbsParams) => HTMLElement[];
166
172
 
167
- export { type DragState, type EasingFunction, type MarqueeDirection, type ScrollParams, type ScrollStartParams, type Slider, type SliderDirection, type SliderNavDirection, type SliderSettings, type SliderState, createSlider, easeInOutCubic, easeOutCubic, easeOutExpo, easeOutQuad, generateBullets, generateThumbs, linear };
173
+ export { type AutoScrollDirection, type DragState, type EasingFunction, type ScrollParams, type ScrollStartParams, type Slider, type SliderDirection, type SliderNavDirection, type SliderSettings, type SliderState, createSlider, easeInOutCubic, easeOutCubic, easeOutExpo, easeOutQuad, generateBullets, generateThumbs, linear };
package/dist/index.js CHANGED
@@ -1,10 +1 @@
1
- var O={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},Le="(min-width: 64rem)",z=()=>window.matchMedia(Le).matches;var B=e=>e===1?1:1-Math.pow(2,-10*e),N=e=>1-Math.pow(1-e,3),ge=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Ae=e=>1-(1-e)*(1-e),Me=e=>e;var xe=()=>`slider-${Math.random().toString(36).substring(2,9)}`,te=e=>{let{feed:t,prevSlideButton:o,nextSlideButton:l,thumbs:r,slides:s}=e;t.id||(t.id=xe()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),s.forEach((i,a)=>{i.setAttribute("role","group"),i.setAttribute("aria-roledescription","slide"),i.setAttribute("aria-label",`Slide ${a+1} of ${s.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,a)=>{i.tagName!=="BUTTON"&&i.setAttribute("role","button"),i.setAttribute("aria-label",`Go to slide ${a+1}`),i.setAttribute("tabindex","0"),i.setAttribute("aria-controls",t.id);});},_=(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 s=r===t;l.classList.toggle(o,s),l.setAttribute("aria-selected",s.toString());});},re=(e,t,o,l,r="horizontal")=>{let s=r==="vertical",i=s?"ArrowUp":"ArrowLeft",a=s?"ArrowDown":"ArrowRight";e.addEventListener("keydown",p=>{switch(p.key){case i:p.preventDefault(),t();break;case a:p.preventDefault(),o();break}},{signal:l}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var C={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},Ie=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),De=()=>({...Ie(),velocityHistory:[],dragDistance:0,dragStartTime:0}),U=(e,t,o="horizontal")=>{let l=e.getBoundingClientRect(),r=o==="vertical",s=r?l.top:l.left,i=null,a=1/0;for(let p of t){if(p.offsetParent===null)continue;let u=p.getBoundingClientRect(),b=r?u.top:u.left,n=Math.abs(s-b);n<a&&(a=n,i=p);}return i},Ce=(e,t,o,l="horizontal")=>{let r=e.getBoundingClientRect(),s=l==="vertical",i=s?r.top:r.left,a=t.filter(f=>f.offsetParent!==null);if(a.length===0)return null;let p=0,u=1/0;a.forEach((f,v)=>{let T=f.getBoundingClientRect(),R=s?T.top:T.left,A=Math.abs(i-R);A<u&&(u=A,p=v);});let b=2,n=p;return Math.abs(o)>b&&(o>0?n=Math.min(p+1,a.length-1):n=Math.max(p-1,0)),a[n]??null},He=e=>{if(e.length===0)return 0;let t=0,o=0;return e.forEach((l,r)=>{let s=r+1;t+=l*s,o+=s;}),t/o},we=(e,t,o,l,r,s="horizontal",i=false)=>{let a=s==="vertical",p=e.velocity*C.MOMENTUM_RATIO,u=()=>{if(Math.abs(p)<C.MIN_VELOCITY){e.momentumId=null;let v=U(t,o,s);if(v){let T=a?v.offsetTop:v.offsetLeft;l(T,N);}r?.(v);return}let b=a?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,f=(a?t.scrollTop:t.scrollLeft)+p;i||(f<0||f>b)&&(p*=.5),a?t.scrollTop=Math.max(0,Math.min(b,f)):t.scrollLeft=Math.max(0,Math.min(b,f)),p*=C.FRICTION,e.momentumId=requestAnimationFrame(u);};e.momentumId=requestAnimationFrame(u);},oe=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,le=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,Re=(e,t)=>t==="vertical"?le(e):oe(e),ie=e=>{let {feed:t,slides:o,abortSignal:l,smoothScrollTo:r,onDragEnd:s,direction:i="horizontal",loop:a=false,touchRatio:p=1,shortSwipeThreshold:u=300,swipeDistanceThreshold:b=10}=e,n=De(),f=i==="vertical",v=()=>{if(!a)return o;let y=[],I=t.children;for(let D=0;D<I.length;D++){let M=I[D];(o.includes(M)||M.hasAttribute("data-lazer-clone"))&&y.push(M);}return y.length>0?y:o},T=0,A=()=>{T=f?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,f?t.clientHeight:t.clientWidth;},V=y=>{n.momentumId!==null&&(cancelAnimationFrame(n.momentumId),n.momentumId=null),A(),n.isDragging=true,n.startX=oe(y),n.startY=le(y),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"),y.type==="mousedown"&&y.preventDefault();},W=y=>{if(!n.isDragging)return;let I=Re(y,i),D=f?n.startY:n.startX,M=f?n.lastY:n.lastX,E=f?n.startScrollTop:n.startScrollLeft,H=performance.now(),c=H-n.lastTime,d=(D-I)*p,S=E+d;if(n.dragDistance=Math.abs(d),!a){if(S<0){let m=Math.abs(S),h=1-Math.min(m/C.MAX_EDGE_OVERSCROLL,1)*(1-C.EDGE_RESISTANCE);S=-m*h;}else if(S>T){let m=S-T,h=1-Math.min(m/C.MAX_EDGE_OVERSCROLL,1)*(1-C.EDGE_RESISTANCE);S=T+m*h;}}if(f?t.scrollTop=S:t.scrollLeft=S,c>0){let m=(M-I)/c*16;if(n.velocityHistory.length>0){let h=n.velocity;n.velocity=h*(1-C.VELOCITY_SMOOTHING)+m*C.VELOCITY_SMOOTHING;}else n.velocity=m;n.velocityHistory.push(m),n.velocityHistory.length>5&&n.velocityHistory.shift();}f?n.lastY=I:n.lastX=I,n.lastTime=H,y.type==="touchmove"&&y.preventDefault();},P=()=>{if(!n.isDragging)return;n.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let I=performance.now()-n.dragStartTime<u&&n.dragDistance>b,D=He(n.velocityHistory),M=v();if(!a){let E=f?t.scrollTop:t.scrollLeft;if(E<0||E>T){let H=E<0?0:T,c=E,d=performance.now(),S=()=>{let m=performance.now()-d,h=Math.min(m/C.BOUNCE_DURATION,1),L=N(h),w=c+(H-c)*L;if(f?t.scrollTop=w:t.scrollLeft=w,h<1)requestAnimationFrame(S);else {let x=U(t,M,i);if(x){let g=f?x.offsetTop:x.offsetLeft;r(g,N);}s?.(x);}};requestAnimationFrame(S);return}}if(I||Math.abs(D)>C.SHORT_SWIPE_VELOCITY){let E=Ce(t,M,D,i);if(E){let H=f?E.offsetTop:E.offsetLeft;r(H,N),s?.(E);}else s?.(null);}else if(Math.abs(n.velocity)>1&&!n.isLoopDragHandled)we(n,t,M,r,s,i,a);else {let E=U(t,M,i);if(!n.isLoopDragHandled){if(E){let H=f?E.offsetTop:E.offsetLeft;r(H,N);}s?.(E);}}};return t.addEventListener("mousedown",V,{signal:l}),document.addEventListener("mousemove",W,{signal:l}),document.addEventListener("mouseup",P,{signal:l}),t.addEventListener("touchstart",V,{passive:true,signal:l}),t.addEventListener("touchmove",W,{passive:false,signal:l}),t.addEventListener("touchend",P,{signal:l}),t.addEventListener("touchcancel",P,{signal:l}),document.addEventListener("mouseleave",P,{signal:l}),t.style.cursor="grab",n},ne=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var X=({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 s=t.map((a,p)=>({slide:a,originalIndex:p})).filter(({slide:a})=>a.offsetParent!==null);return s.length===0?(console.warn("No visible slides found"),[]):s.map(({slide:a,originalIndex:p},u)=>{let b=document.createElement("button");return b.type="button",b.classList.add(o),u===0&&b.classList.add(l),b.setAttribute("role","tab"),b.setAttribute("aria-selected",u===0?"true":"false"),b.setAttribute("aria-controls",r),b.setAttribute("aria-label",`Go to slide ${u+1}`),b.setAttribute("data-slide-index",String(u)),e.appendChild(b),b})};var j=({thumbsContainer:e,slides:t,thumbClass:o,thumbActiveClass:l,feedId:r,thumbImageSelector:s="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 a=t.map((u,b)=>({slide:u,originalIndex:b})).filter(({slide:u})=>u.offsetParent!==null);return a.length===0?(console.warn("No visible slides found"),[]):a.map(({slide:u,originalIndex:b},n)=>{let f=document.createElement("button");f.type="button",f.classList.add(o),n===0&&f.classList.add(l);let v=u.querySelector(s);if(v?.src){let T=document.createElement("img");T.src=v.src,T.alt=v.alt||`Slide ${n+1} thumbnail`,T.draggable=false,i&&(T.style.width=`${i.width}px`,T.style.height=`${i.height}px`,T.style.objectFit="cover"),f.appendChild(T);}return f.setAttribute("role","tab"),f.setAttribute("aria-selected",n===0?"true":"false"),f.setAttribute("aria-controls",r),f.setAttribute("aria-label",`Go to slide ${n+1}`),f.setAttribute("data-slide-index",String(n)),e.appendChild(f),f})};var ae=()=>({initialized:false,clonedSlides:[],styleElement:null}),se=()=>{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
- @keyframes lazer-marquee-scroll {
3
- 0% {
4
- transform: translateX(0);
5
- }
6
- 100% {
7
- transform: translateX(-50%);
8
- }
9
- }
10
- `,document.head.appendChild(t),t},Oe=(e,t)=>{t.initialized||(t.styleElement=se(),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);},ce=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false);},Pe=(e,t)=>{se(),requestAnimationFrame(()=>{let o=e.feed.scrollWidth,l=e.marqueeSpeed??50,r=e.marqueeDirection??"left",s=o/2;if(s<=0||l<=0){console.warn("[lazer-slider] Invalid marquee values:",{distance:s,speed:l,scrollWidth:o});return}let p=`lazer-marquee-scroll ${s/l}s linear infinite ${r==="right"?"reverse":"normal"}`;e.feed.style.animation="none",e.feed.offsetWidth,e.feed.style.animation=p,e.feed.style.animationPlayState=t.marqueePaused?"paused":"running";});},G=(e,t)=>{Pe(e,t);},de=(e,t)=>{t.feed.style.animation="",t.feed.style.animationPlayState="",t.feed.style.transform="",t.feed.style.willChange="";},Y=(e,t)=>{e.marqueePaused=true,t.feed.style.animationPlayState="paused";},$=(e,t)=>{e.marqueePaused=false,t.feed.style.animationPlayState="running";},ue=(e,t,o)=>{e.marquee&&(Oe(e,o),G(e,t));},fe=(e,t,o)=>{!e.marquee||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>Y(t,e),{signal:o}),e.feed.addEventListener("mouseleave",()=>$(t,e),{signal:o}),e.feed.addEventListener("touchstart",()=>Y(t,e),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>$(t,e),{signal:o}));};var me=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0}),qe=e=>{let t=z()?e.desktopSlidesPerView:e.mobileSlidesPerView;return !t||t==="auto"?1:Math.ceil(t)},pe=(e,t,o)=>{if(!e.loop||t.initialized)return;let l=t.realSlides,r=qe(e);t.clonesPerSide=r;for(let s=l.length-r;s<l.length;s++){let i=l[s];if(!i)continue;let a=i.cloneNode(true);a.setAttribute("data-lazer-clone","prepend"),a.setAttribute("aria-hidden","true"),e.feed.insertBefore(a,e.feed.firstChild),t.clonedSlides.push(a);}for(let s=0;s<r;s++){let i=l[s];if(!i)continue;let a=i.cloneNode(true);a.setAttribute("data-lazer-clone","append"),a.setAttribute("aria-hidden","true"),e.feed.appendChild(a),t.clonedSlides.push(a);}requestAnimationFrame(()=>{let s=l[0];s&&(o?e.feed.scrollTop=s.offsetTop:e.feed.scrollLeft=s.offsetLeft);}),t.initialized=true;},Se=(e,t,o,l,r,s,i)=>{if(!t.loop||!o.initialized)return;s(true);let a=o.realSlides,p=a.length;if(e==="next"){let u=a[0];u&&(l?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),r(0);}else {let u=a[p-1];u&&(l?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),r(p-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{s(false),i();});});},he=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0);};var K=(e,t,o)=>{if(t.autoplayIntervalId)return;let l=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||o("next");},l);},Q=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},be=e=>{e.autoplayPaused=true;},Te=e=>{e.autoplayPaused=false;},ve=(e,t,o)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>be(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>Te(t),{signal:o}),e.feed.addEventListener("touchstart",()=>be(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>Te(t),{signal:o}));};var J=(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="";}},Ee=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let o=e.scrollbarTrack.getBoundingClientRect().height,l=e.scrollbarThumb.getBoundingClientRect().height,r=o-l,s=e.feed.scrollHeight-e.feed.clientHeight,i=s>0?e.feed.scrollTop/s:0;e.scrollbarThumb.style.transform=`translateY(${r*i}px)`;}else {let o=e.scrollbarTrack.getBoundingClientRect().width,l=e.scrollbarThumb.getBoundingClientRect().width,r=o-l,s=e.feed.scrollWidth-e.feed.clientWidth,i=s>0?e.feed.scrollLeft/s:0;e.scrollbarThumb.style.transform=`translateX(${r*i}px)`;}};var Z=(e,t,o,l=B,r,s)=>{let i=o?e.scrollTop:e.scrollLeft,a=Math.abs(t-i),p=Math.min(O.MAX_DURATION,Math.max(O.MIN_DURATION,a/O.SPEED_FACTOR)),u=performance.now(),b=n=>{if(s?.cancelled)return;let f=(n-u)/p,v=Math.min(f,1),T=l(v),R=i+(t-i)*T;o?e.scrollTop=R:e.scrollLeft=R,v<1?requestAnimationFrame(b):(o?e.scrollTop=t:e.scrollLeft=t,r?.());};requestAnimationFrame(b);},k=e=>e.filter(t=>t.offsetParent!==null),ee=(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(a=>{a.style.flex="",a.style.minWidth="",a.style.minHeight="";});return}let i=`calc((100% - ${r*(l-1)}px) / ${l})`;t?e.slides.forEach(a=>{a.style.flex=`0 0 ${i}`,a.style.minHeight=i,a.style.minWidth="";}):e.slides.forEach(a=>{a.style.flex=`0 0 ${i}`,a.style.minWidth=i,a.style.minHeight="";});},ye=(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 Ne=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=X({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=j({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??B,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},s=null,i=me(e.slides),a=ae(),p={cancelled:false},u=null,b=()=>{let c=ye(e.feed,r.cachedFeedRect,r.lastWidth,o);return r.cachedFeedRect=c.rect,r.lastWidth=c.size,c.rect},n=(c,d)=>{Z(e.feed,c,o,l,d);},f=(c,d)=>{p.cancelled=true,p={cancelled:false},Z(e.feed,c,o,d??l,void 0,p);},v=()=>{if(r.isLoopRepositioning)return;let c=b(),d,S,m;if(o?(d=e.feed.scrollTop<=1,S=e.feed.scrollTop+c.height>=e.feed.scrollHeight-1,m=e.feed.scrollHeight<=c.height):(d=e.feed.scrollLeft<=1,S=e.feed.scrollLeft+c.width>=e.feed.scrollWidth-1,m=e.feed.scrollWidth<=c.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=m?"none":"block"),e.loop){_(e.prevSlideButton,!m,e.feed),_(e.nextSlideButton,!m,e.feed);return}_(e.prevSlideButton,!d&&!m,e.feed),_(e.nextSlideButton,!S&&!m,e.feed);},T=()=>{let c=b(),d=i.initialized?i.realSlides:k(e.slides),S=d.filter(m=>{let h=m.getBoundingClientRect(),L=20;return o?h.bottom>c.top+L&&h.top<c.bottom-L:h.right>c.left+L&&h.left<c.right-L});if(S.length&&S[0]){let m=d.indexOf(S[0]);if(m!==-1){r.currentSlideIndex=m;let h=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:h,currentSlideIndex:r.currentSlideIndex});}}},R=c=>{if(!e.thumbs)return;let d=e.thumbs.indexOf(c);if(d===-1||!e.slides[d])return;r.currentSlideIndex=d,F(e.thumbs,d),r.isScrolling=true,r.updateThumbTimeout&&clearTimeout(r.updateThumbTimeout),r.updateThumbTimeout=setTimeout(()=>{r.isScrolling=false;},O.THUMB_UPDATE_DELAY);let S=o?e.slides[d].offsetTop:e.slides[d].offsetLeft;n(S);},A=c=>{let d=i.initialized?i.realSlides:k(e.slides),S=z()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,m=d.length;T();let h,L=false;if(c==="prev")if(e.loop&&i.initialized&&r.currentSlideIndex===0){let g=i.clonedSlides.filter(q=>q.getAttribute("data-lazer-clone")==="prepend");h=g[g.length-1],L=true;}else r.currentSlideIndex=Math.max(0,r.currentSlideIndex-S),h=d[r.currentSlideIndex];else e.loop&&i.initialized&&r.currentSlideIndex>=m-1?(h=i.clonedSlides.filter(q=>q.getAttribute("data-lazer-clone")==="append")[0],L=true):(r.currentSlideIndex=Math.min(m-1,r.currentSlideIndex+S),h=d[r.currentSlideIndex]);if(!h)return;let w=o?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:w,target:h,direction:c});let x=o?h.offsetTop:h.offsetLeft;L?n(x,()=>{Se(c,e,i,o,g=>{r.currentSlideIndex=g;},g=>{r.isLoopRepositioning=g;},v);}):n(x);},V=()=>{Ee(e,o),v(),T(),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});},O.SCROLL_END_DELAY);},W=()=>{r.ticking||(requestAnimationFrame(()=>{V(),r.ticking=false;}),r.ticking=true);},P=()=>{let c=r.currentSlideIndex;r.cachedFeedRect=null;let d=()=>{let m=(i.initialized?i.realSlides:k(e.slides))[c];if(m){let h=o?m.offsetTop:m.offsetLeft;o?e.feed.scrollTop=h:e.feed.scrollLeft=h;}};d(),u&&clearTimeout(u),u=setTimeout(()=>{D(),d();},150);},y=()=>{let{signal:c}=r.abortController;window.addEventListener("resize",P),e.feed.addEventListener("scroll",W,{passive:true,signal:c}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>A("prev"),{signal:c}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>A("next"),{signal:c}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(d=>{d.addEventListener("click",()=>R(d),{signal:c});})),re(e.feed,()=>A("prev"),()=>A("next"),c,t),e.enableDragToScroll!==false&&(s=ie({feed:e.feed,slides:e.slides,abortSignal:c,smoothScrollTo:f,onDragEnd:d=>{let S=d?.getAttribute("data-lazer-clone");if(!!(S&&e.loop&&i.initialized)&&d){let h=i.realSlides,L=0,w;if(S==="prepend"){let g=i.clonedSlides.filter(q=>q.getAttribute("data-lazer-clone")==="prepend").indexOf(d);L=h.length-i.clonesPerSide+g,w=h[L];}else if(S==="append"){let g=i.clonedSlides.filter(q=>q.getAttribute("data-lazer-clone")==="append").indexOf(d);L=g,w=h[g];}if(w){r.currentSlideIndex=L;let x=o?w.offsetTop:w.offsetLeft;setTimeout(()=>{p.cancelled=true,o?e.feed.scrollTop=x:e.feed.scrollLeft=x;},O.MIN_DURATION),F(e.thumbs,r.currentSlideIndex);}}else T(),F(e.thumbs,r.currentSlideIndex);},direction:t,loop:e.loop})),ve(e,r,c),fe(e,r,c);},I=c=>{let d=i.initialized?i.realSlides:k(e.slides),S=Math.max(0,Math.min(c,d.length-1)),m=d[S];if(!m)return;r.currentSlideIndex=S,F(e.thumbs,S);let h=o?m.offsetTop:m.offsetLeft;n(h);},D=()=>{r.cachedFeedRect=null,ee(e,o,z()),J(e,b(),o),v(),e.marquee&&!r.marqueePaused&&G(e,r);},M=()=>{Q(r),de(r,e),r.abortController.abort(),window.removeEventListener("resize",P),r.updateThumbTimeout&&clearTimeout(r.updateThumbTimeout),r.scrollEndTimeout&&clearTimeout(r.scrollEndTimeout),u&&clearTimeout(u),s&&ne(s),he(i),ce(a),r.cachedFeedRect=null;},E=()=>{e.marquee?r.marqueePaused?$(r,e):G(e,r):e.autoplay&&K(e,r,A);},H=()=>{e.marquee?Y(r,e):Q(r);};return te(e),ee(e,o,z()),e.marquee?ue(e,r,a):(pe(e,i,o),e.autoplay&&K(e,r,A)),v(),y(),J(e,b(),o),{goToIndex:I,refresh:D,unload:M,play:E,pause:H,next:()=>A("next"),prev:()=>A("prev")}};export{Ne as createSlider,ge as easeInOutCubic,N as easeOutCubic,B as easeOutExpo,Ae as easeOutQuad,X as generateBullets,j as generateThumbs,Me as linear};
1
+ var H={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},ve="(min-width: 64rem)",N=()=>window.matchMedia(ve).matches;var k=e=>e===1?1:1-Math.pow(2,-10*e),w=e=>1-Math.pow(1-e,3),Ee=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Le=e=>1-(1-e)*(1-e),Ae=e=>e;var ye=()=>`slider-${Math.random().toString(36).substring(2,9)}`,le=e=>{let{feed:t,prevSlideButton:l,nextSlideButton:i,thumbs:o,slides:c}=e;t.id||(t.id=ye()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),c.forEach((r,a)=>{r.setAttribute("role","group"),r.setAttribute("aria-roledescription","slide"),r.setAttribute("aria-label",`Slide ${a+1} of ${c.length}`);}),l&&(l.setAttribute("aria-label","Previous slide"),l.setAttribute("aria-controls",t.id),l.setAttribute("tabindex","0"),l.tagName!=="BUTTON"&&l.setAttribute("role","button")),i&&(i.setAttribute("aria-label","Next slide"),i.setAttribute("aria-controls",t.id),i.setAttribute("tabindex","0"),i.tagName!=="BUTTON"&&i.setAttribute("role","button")),o?.length&&o.forEach((r,a)=>{r.tagName!=="BUTTON"&&r.setAttribute("role","button"),r.setAttribute("aria-label",`Go to slide ${a+1}`),r.setAttribute("tabindex","0"),r.setAttribute("aria-controls",t.id);});},W=(e,t,l)=>{if(!e)return;!t&&e===document.activeElement&&l&&l.focus();let i="opacity 0.3s ease",o=t?"1":"0";Object.assign(e.style,{opacity:o,transition:i,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,l="active")=>{e?.length&&e.forEach((i,o)=>{let c=o===t;i.classList.toggle(l,c),i.setAttribute("aria-selected",c.toString());});},re=(e,t,l,i,o="horizontal")=>{let c=o==="vertical",r=c?"ArrowUp":"ArrowLeft",a=c?"ArrowDown":"ArrowRight";e.addEventListener("keydown",u=>{switch(u.key){case r:u.preventDefault(),t();break;case a:u.preventDefault(),l();break}},{signal:i}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var D={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},ge=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),xe=()=>({...ge(),velocityHistory:[],dragDistance:0,dragStartTime:0}),$=(e,t,l="horizontal")=>{let i=e.getBoundingClientRect(),o=l==="vertical",c=o?i.top:i.left,r=null,a=1/0;for(let u of t){if(u.offsetParent===null)continue;let f=u.getBoundingClientRect(),p=o?f.top:f.left,E=Math.abs(c-p);E<a&&(a=E,r=u);}return r},Ie=(e,t,l,i="horizontal")=>{let o=e.getBoundingClientRect(),c=i==="vertical",r=c?o.top:o.left,a=t.filter(n=>n.offsetParent!==null);if(a.length===0)return null;let u=0,f=1/0;a.forEach((n,S)=>{let L=n.getBoundingClientRect(),v=c?L.top:L.left,O=Math.abs(r-v);O<f&&(f=O,u=S);});let p=2,E=u;return Math.abs(l)>p&&(l>0?E=Math.min(u+1,a.length-1):E=Math.max(u-1,0)),a[E]??null},Me=e=>{if(e.length===0)return 0;let t=0,l=0;return e.forEach((i,o)=>{let c=o+1;t+=i*c,l+=c;}),t/l},De=(e,t,l,i,o,c="horizontal",r=false)=>{let a=c==="vertical",u=e.velocity*D.MOMENTUM_RATIO,f=()=>{if(Math.abs(u)<D.MIN_VELOCITY){e.momentumId=null;let S=$(t,l,c);if(S){let L=a?S.offsetTop:S.offsetLeft;i(L,w);}o?.(S);return}let p=a?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,n=(a?t.scrollTop:t.scrollLeft)+u;r||(n<0||n>p)&&(u*=.5),a?t.scrollTop=Math.max(0,Math.min(p,n)):t.scrollLeft=Math.max(0,Math.min(p,n)),u*=D.FRICTION,e.momentumId=requestAnimationFrame(f);};e.momentumId=requestAnimationFrame(f);},ie=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,ne=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,Ce=(e,t)=>t==="vertical"?ne(e):ie(e),ae=e=>{let {feed:t,slides:l,abortSignal:i,smoothScrollTo:o,onDragStart:c,onDragEnd:r,direction:a="horizontal",loop:u=false,touchRatio:f=1,shortSwipeThreshold:p=300,swipeDistanceThreshold:E=10}=e,n=xe(),S=a==="vertical",L=()=>{if(!u)return l;let A=[],M=t.children;for(let C=0;C<M.length;C++){let x=M[C];(l.includes(x)||x.hasAttribute("data-lazer-clone"))&&A.push(x);}return A.length>0?A:l},v=0,U=()=>{v=S?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,S?t.clientHeight:t.clientWidth;},B=A=>{n.momentumId!==null&&(cancelAnimationFrame(n.momentumId),n.momentumId=null),U(),c?.(),n.isDragging=true,n.startX=ie(A),n.startY=ne(A),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"),A.type==="mousedown"&&A.preventDefault();},X=A=>{if(!n.isDragging)return;let M=Ce(A,a),C=S?n.startY:n.startX,x=S?n.lastY:n.lastX,s=S?n.startScrollTop:n.startScrollLeft,d=performance.now(),b=d-n.lastTime,h=(C-M)*f,m=s+h;if(n.dragDistance=Math.abs(h),!u){if(m<0){let T=Math.abs(m),y=1-Math.min(T/D.MAX_EDGE_OVERSCROLL,1)*(1-D.EDGE_RESISTANCE);m=-T*y;}else if(m>v){let T=m-v,y=1-Math.min(T/D.MAX_EDGE_OVERSCROLL,1)*(1-D.EDGE_RESISTANCE);m=v+T*y;}}if(S?t.scrollTop=m:t.scrollLeft=m,b>0){let T=(x-M)/b*16;if(n.velocityHistory.length>0){let y=n.velocity;n.velocity=y*(1-D.VELOCITY_SMOOTHING)+T*D.VELOCITY_SMOOTHING;}else n.velocity=T;n.velocityHistory.push(T),n.velocityHistory.length>5&&n.velocityHistory.shift();}S?n.lastY=M:n.lastX=M,n.lastTime=d,A.type==="touchmove"&&A.preventDefault();},P=()=>{if(!n.isDragging)return;n.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let M=performance.now()-n.dragStartTime<p&&n.dragDistance>E,C=Me(n.velocityHistory),x=L();if(!u){let s=S?t.scrollTop:t.scrollLeft;if(s<0||s>v){let d=s<0?0:v,b=s,h=performance.now(),m=()=>{let T=performance.now()-h,y=Math.min(T/D.BOUNCE_DURATION,1),R=w(y),g=b+(d-b)*R;if(S?t.scrollTop=g:t.scrollLeft=g,y<1)requestAnimationFrame(m);else {let I=$(t,x,a);if(I){let Te=S?I.offsetTop:I.offsetLeft;o(Te,w);}r?.(I);}};requestAnimationFrame(m);return}}if(M||Math.abs(C)>D.SHORT_SWIPE_VELOCITY){let s=Ie(t,x,C,a);if(s){let d=S?s.offsetTop:s.offsetLeft;o(d,w),r?.(s);}else r?.(null);}else if(Math.abs(n.velocity)>1&&!n.isLoopDragHandled)De(n,t,x,o,r,a,u);else {let s=$(t,x,a);if(!n.isLoopDragHandled){if(s){let d=S?s.offsetTop:s.offsetLeft;o(d,w);}r?.(s);}}};return t.addEventListener("mousedown",B,{signal:i}),document.addEventListener("mousemove",X,{signal:i}),document.addEventListener("mouseup",P,{signal:i}),t.addEventListener("touchstart",B,{passive:true,signal:i}),t.addEventListener("touchmove",X,{passive:false,signal:i}),t.addEventListener("touchend",P,{signal:i}),t.addEventListener("touchcancel",P,{signal:i}),document.addEventListener("mouseleave",P,{signal:i}),t.style.cursor="grab",n},ce=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var q=({bulletsContainer:e,slides:t,bulletClass:l,bulletActiveClass:i,feedId:o})=>{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(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="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 c=t.map((a,u)=>({slide:a,originalIndex:u})).filter(({slide:a})=>a.offsetParent!==null);return c.length===0?(console.warn("No visible slides found"),[]):c.map(({slide:a,originalIndex:u},f)=>{let p=document.createElement("button");return p.type="button",p.classList.add(l),f===0&&p.classList.add(i),p.setAttribute("role","tab"),p.setAttribute("aria-selected",f===0?"true":"false"),p.setAttribute("aria-controls",o),p.setAttribute("aria-label",`Go to slide ${f+1}`),p.setAttribute("data-slide-index",String(f)),e.appendChild(p),p})};var j=({thumbsContainer:e,slides:t,thumbClass:l,thumbActiveClass:i,feedId:o,thumbImageSelector:c="img",thumbSize:r})=>{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(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="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 a=t.map((f,p)=>({slide:f,originalIndex:p})).filter(({slide:f})=>f.offsetParent!==null);return a.length===0?(console.warn("No visible slides found"),[]):a.map(({slide:f,originalIndex:p},E)=>{let n=document.createElement("button");n.type="button",n.classList.add(l),E===0&&n.classList.add(i);let S=f.querySelector(c);if(S?.src){let L=document.createElement("img");L.src=S.src,L.alt=S.alt||`Slide ${E+1} thumbnail`,L.draggable=false,r&&(L.style.width=`${r.width}px`,L.style.height=`${r.height}px`,L.style.objectFit="cover"),n.appendChild(L);}return n.setAttribute("role","tab"),n.setAttribute("aria-selected",E===0?"true":"false"),n.setAttribute("aria-controls",o),n.setAttribute("aria-label",`Go to slide ${E+1}`),n.setAttribute("data-slide-index",String(E)),e.appendChild(n),n})};var _=(e,t,l,i)=>{if(t.autoScrollAnimationId!==null)return;t.autoScrollPaused=false,t.autoScrollStopped=false,t.autoScrollLastTimestamp=performance.now();let o=e.autoScrollSpeed??50,c=e.autoScrollDirection??"forward",r=a=>{if(t.autoScrollPaused||t.autoScrollStopped){t.autoScrollAnimationId=null;return}let u=a-t.autoScrollLastTimestamp;t.autoScrollLastTimestamp=a,u>100&&(u=100);let f=o*(u/1e3);c==="backward"&&(f=-f),i?e.feed.scrollTop+=f:e.feed.scrollLeft+=f,Re(e,l,i,c),t.autoScrollAnimationId=requestAnimationFrame(r);};t.autoScrollAnimationId=requestAnimationFrame(r);},Re=(e,t,l,i)=>{if(!t.initialized||t.realSlides.length===0)return;let o=e.feed;if(i==="forward"){let c=l?o.scrollHeight-o.clientHeight:o.scrollWidth-o.clientWidth;if((l?o.scrollTop:o.scrollLeft)>=c-1){let a=t.realSlides[0];a&&(l?o.scrollTop=a.offsetTop:o.scrollLeft=a.offsetLeft);}}else if((l?o.scrollTop:o.scrollLeft)<=1){let r=t.realSlides[t.realSlides.length-1];r&&(l?o.scrollTop=r.offsetTop:o.scrollLeft=r.offsetLeft);}},K=e=>{e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null),e.autoScrollResumeTimeout!==null&&(clearTimeout(e.autoScrollResumeTimeout),e.autoScrollResumeTimeout=null);},z=e=>{e.autoScrollPaused=true,e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null);},G=(e,t,l,i)=>{t.autoScrollStopped||(t.autoScrollLastTimestamp=performance.now(),t.autoScrollPaused=false,t.autoScrollAnimationId===null&&_(e,t,l,i));},Y=(e,t,l,i)=>{if(t.autoScrollStopped)return;t.autoScrollResumeTimeout!==null&&clearTimeout(t.autoScrollResumeTimeout);let o=e.autoScrollStartDelay??0;o>0?t.autoScrollResumeTimeout=setTimeout(()=>{t.autoScrollResumeTimeout=null,G(e,t,l,i);},o):G(e,t,l,i);},se=(e,t,l,i,o)=>{if(!e.autoScroll)return;let c=e.stopOnMouseEnter!==false,r=e.stopOnFocusIn!==false;c&&(e.feed.addEventListener("mouseenter",()=>z(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>Y(e,t,l,i),{signal:o})),r&&(e.feed.addEventListener("focusin",()=>z(t),{signal:o}),e.feed.addEventListener("focusout",()=>Y(e,t,l,i),{signal:o})),e.feed.addEventListener("touchstart",()=>z(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>Y(e,t,l,i),{signal:o});};var de=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0}),He=e=>{let t=N()?e.desktopSlidesPerView:e.mobileSlidesPerView;if(e.autoScroll){let l=!t||t==="auto"?3:Math.ceil(t)+1;return Math.min(l,e.slides.length)}return !t||t==="auto"?1:Math.ceil(t)},Q=(e,t,l)=>{if(!e.loop||t.initialized)return;let i=t.realSlides,o=He(e);t.clonesPerSide=o;for(let c=i.length-o;c<i.length;c++){let r=i[c];if(!r)continue;let a=r.cloneNode(true);a.setAttribute("data-lazer-clone","prepend"),a.setAttribute("aria-hidden","true"),e.feed.insertBefore(a,e.feed.firstChild),t.clonedSlides.push(a);}for(let c=0;c<o;c++){let r=i[c];if(!r)continue;let a=r.cloneNode(true);a.setAttribute("data-lazer-clone","append"),a.setAttribute("aria-hidden","true"),e.feed.appendChild(a),t.clonedSlides.push(a);}requestAnimationFrame(()=>{let c=i[0];c&&(l?e.feed.scrollTop=c.offsetTop:e.feed.scrollLeft=c.offsetLeft);}),t.initialized=true;},ue=(e,t,l,i,o,c,r)=>{if(!t.loop||!l.initialized)return;c(true);let a=l.realSlides,u=a.length;if(e==="next"){let f=a[0];f&&(i?t.feed.scrollTop=f.offsetTop:t.feed.scrollLeft=f.offsetLeft),o(0);}else {let f=a[u-1];f&&(i?t.feed.scrollTop=f.offsetTop:t.feed.scrollLeft=f.offsetLeft),o(u-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(false),r();});});},fe=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0);};var J=(e,t,l)=>{if(t.autoplayIntervalId)return;let i=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||l("next");},i);},Z=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},me=e=>{e.autoplayPaused=true;},pe=e=>{e.autoplayPaused=false;},Se=(e,t,l)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>me(t),{signal:l}),e.feed.addEventListener("mouseleave",()=>pe(t),{signal:l}),e.feed.addEventListener("touchstart",()=>me(t),{passive:true,signal:l}),e.feed.addEventListener("touchend",()=>pe(t),{signal:l}));};var ee=(e,t,l)=>{if(e.scrollbarThumb)if(l){let i=t.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${i}%`,e.scrollbarThumb.style.width="";}else {let i=t.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${i}%`,e.scrollbarThumb.style.height="";}},he=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let l=e.scrollbarTrack.getBoundingClientRect().height,i=e.scrollbarThumb.getBoundingClientRect().height,o=l-i,c=e.feed.scrollHeight-e.feed.clientHeight,r=c>0?e.feed.scrollTop/c:0;e.scrollbarThumb.style.transform=`translateY(${o*r}px)`;}else {let l=e.scrollbarTrack.getBoundingClientRect().width,i=e.scrollbarThumb.getBoundingClientRect().width,o=l-i,c=e.feed.scrollWidth-e.feed.clientWidth,r=c>0?e.feed.scrollLeft/c:0;e.scrollbarThumb.style.transform=`translateX(${o*r}px)`;}};var te=(e,t,l,i=k,o,c)=>{let r=l?e.scrollTop:e.scrollLeft,a=Math.abs(t-r),u=Math.min(H.MAX_DURATION,Math.max(H.MIN_DURATION,a/H.SPEED_FACTOR)),f=performance.now(),p=E=>{if(c?.cancelled)return;let n=(E-f)/u,S=Math.min(n,1),L=i(S),v=r+(t-r)*L;l?e.scrollTop=v:e.scrollLeft=v,S<1?requestAnimationFrame(p):(l?e.scrollTop=t:e.scrollLeft=t,o?.());};requestAnimationFrame(p);},V=e=>e.filter(t=>t.offsetParent!==null),oe=(e,t,l)=>{let i=l?e.desktopSlidesPerView:e.mobileSlidesPerView,o=e.slideGap??0;if(o>0&&(e.feed.style.gap=`${o}px`),!i||i==="auto"){e.slides.forEach(a=>{a.style.flex="",a.style.minWidth="",a.style.minHeight="";});return}let r=`calc((100% - ${o*(i-1)}px) / ${i})`;t?e.slides.forEach(a=>{a.style.flex=`0 0 ${r}`,a.style.minHeight=r,a.style.minWidth="";}):e.slides.forEach(a=>{a.style.flex=`0 0 ${r}`,a.style.minWidth=r,a.style.minHeight="";});},be=(e,t,l,i)=>{let o=i?e.clientHeight:e.clientWidth;return !t||l!==o?{rect:e.getBoundingClientRect(),size:o}:{rect:t,size:l}};var we=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 s=q({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=s;}if(e.thumbsContainer&&!e.thumbs){let s=j({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=s;}let t=e.direction??"horizontal",l=t==="vertical",i=e.easing??k,o={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,autoScrollAnimationId:null,autoScrollPaused:false,autoScrollLastTimestamp:0,autoScrollStopped:false,autoScrollResumeTimeout:null,isLoopRepositioning:false},c=null,r=de(e.slides),a={cancelled:false},u=null,f=()=>{let s=be(e.feed,o.cachedFeedRect,o.lastWidth,l);return o.cachedFeedRect=s.rect,o.lastWidth=s.size,s.rect},p=(s,d)=>{te(e.feed,s,l,i,d);},E=(s,d)=>{a.cancelled=true,a={cancelled:false},te(e.feed,s,l,d??i,void 0,a);},n=()=>{if(o.isLoopRepositioning)return;let s=f(),d,b,h;if(l?(d=e.feed.scrollTop<=1,b=e.feed.scrollTop+s.height>=e.feed.scrollHeight-1,h=e.feed.scrollHeight<=s.height):(d=e.feed.scrollLeft<=1,b=e.feed.scrollLeft+s.width>=e.feed.scrollWidth-1,h=e.feed.scrollWidth<=s.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=h?"none":"block"),e.loop){W(e.prevSlideButton,!h,e.feed),W(e.nextSlideButton,!h,e.feed);return}W(e.prevSlideButton,!d&&!h,e.feed),W(e.nextSlideButton,!b&&!h,e.feed);},S=()=>{let s=f(),d=r.initialized?r.realSlides:V(e.slides),b=d.filter(h=>{let m=h.getBoundingClientRect(),T=20;return l?m.bottom>s.top+T&&m.top<s.bottom-T:m.right>s.left+T&&m.left<s.right-T});if(b.length&&b[0]){let h=d.indexOf(b[0]);if(h!==-1){o.currentSlideIndex=h;let m=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:m,currentSlideIndex:o.currentSlideIndex});}}},L=s=>{if(!e.thumbs)return;let d=e.thumbs.indexOf(s);if(d===-1||!e.slides[d])return;o.currentSlideIndex=d,F(e.thumbs,d),o.isScrolling=true,o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.updateThumbTimeout=setTimeout(()=>{o.isScrolling=false;},H.THUMB_UPDATE_DELAY);let b=l?e.slides[d].offsetTop:e.slides[d].offsetLeft;p(b);},v=s=>{let d=r.initialized?r.realSlides:V(e.slides),b=N()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,h=d.length;S();let m,T=false;if(s==="prev")if(e.loop&&r.initialized&&o.currentSlideIndex===0){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="prepend");m=g[g.length-1],T=true;}else o.currentSlideIndex=Math.max(0,o.currentSlideIndex-b),m=d[o.currentSlideIndex];else e.loop&&r.initialized&&o.currentSlideIndex>=h-1?(m=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="append")[0],T=true):(o.currentSlideIndex=Math.min(h-1,o.currentSlideIndex+b),m=d[o.currentSlideIndex]);if(!m)return;let y=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:y,target:m,direction:s});let R=l?m.offsetTop:m.offsetLeft;T?p(R,()=>{ue(s,e,r,l,g=>{o.currentSlideIndex=g;},g=>{o.isLoopRepositioning=g;},n);}):p(R);},O=()=>{he(e,l),n(),S(),o.isScrolling||F(e.thumbs,o.currentSlideIndex),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),o.scrollEndTimeout=setTimeout(()=>{o.isScrolling=false;let s=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:s,currentSlideIndex:o.currentSlideIndex});},H.SCROLL_END_DELAY);},U=()=>{o.ticking||(requestAnimationFrame(()=>{O(),o.ticking=false;}),o.ticking=true);},B=()=>{let s=o.currentSlideIndex;o.cachedFeedRect=null;let d=()=>{let h=(r.initialized?r.realSlides:V(e.slides))[s];if(h){let m=l?h.offsetTop:h.offsetLeft;l?e.feed.scrollTop=m:e.feed.scrollLeft=m;}};d(),u&&clearTimeout(u),u=setTimeout(()=>{A(),d();},150);},X=()=>{let{signal:s}=o.abortController;window.addEventListener("resize",B),e.feed.addEventListener("scroll",U,{passive:true,signal:s}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>v("prev"),{signal:s}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>v("next"),{signal:s}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(d=>{d.addEventListener("click",()=>L(d),{signal:s});})),re(e.feed,()=>v("prev"),()=>v("next"),s,t),e.enableDragToScroll!==false&&(c=ae({feed:e.feed,slides:e.slides,abortSignal:s,smoothScrollTo:E,onDragStart:()=>{e.autoScroll&&z(o);},onDragEnd:d=>{let b=d?.getAttribute("data-lazer-clone");if(!!(b&&e.loop&&r.initialized)&&d){let m=r.realSlides,T=0,y;if(b==="prepend"){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="prepend").indexOf(d);T=m.length-r.clonesPerSide+g,y=m[T];}else if(b==="append"){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="append").indexOf(d);T=g,y=m[g];}if(y){o.currentSlideIndex=T;let R=l?y.offsetTop:y.offsetLeft;setTimeout(()=>{a.cancelled=true,l?e.feed.scrollTop=R:e.feed.scrollLeft=R;},H.MIN_DURATION),F(e.thumbs,o.currentSlideIndex);}}else S(),F(e.thumbs,o.currentSlideIndex);e.autoScroll&&!o.autoScrollStopped&&(e.stopOnInteraction?o.autoScrollStopped=true:Y(e,o,r,l));},direction:t,loop:e.loop})),Se(e,o,s),se(e,o,r,l,s);},P=s=>{let d=r.initialized?r.realSlides:V(e.slides),b=Math.max(0,Math.min(s,d.length-1)),h=d[b];if(!h)return;o.currentSlideIndex=b,F(e.thumbs,b);let m=l?h.offsetTop:h.offsetLeft;p(m);},A=()=>{o.cachedFeedRect=null,oe(e,l,N()),ee(e,f(),l),n(),e.autoScroll&&!o.autoScrollPaused&&!o.autoScrollStopped&&(K(o),_(e,o,r,l));},M=()=>{Z(o),K(o),o.abortController.abort(),window.removeEventListener("resize",B),o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),u&&clearTimeout(u),c&&ce(c),fe(r),o.cachedFeedRect=null;},C=()=>{e.autoScroll?(o.autoScrollStopped=false,o.autoScrollPaused?G(e,o,r,l):_(e,o,r,l)):e.autoplay&&J(e,o,v);},x=()=>{e.autoScroll?z(o):Z(o);};if(le(e),oe(e,l,N()),e.autoScroll){e.loop=true,Q(e,r,l);let s=e.autoScrollStartDelay??0;s>0?o.autoScrollResumeTimeout=setTimeout(()=>{o.autoScrollResumeTimeout=null,_(e,o,r,l);},s):requestAnimationFrame(()=>{requestAnimationFrame(()=>{_(e,o,r,l);});});}else Q(e,r,l),e.autoplay&&J(e,o,v);return n(),X(),ee(e,f(),l),{goToIndex:P,refresh:A,unload:M,play:C,pause:x,next:()=>v("next"),prev:()=>v("prev")}};export{we as createSlider,Ee as easeInOutCubic,w as easeOutCubic,k as easeOutExpo,Le as easeOutQuad,q as generateBullets,j as generateThumbs,Ae as linear};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lazer-slider",
3
- "version": "1.1.10",
3
+ "version": "1.2.0",
4
4
  "description": "A lightweight, accessible slider with smooth scroll-to-snap animations and drag-to-scroll support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -20,6 +20,8 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "build": "tsup && cp src/styles/lazer-slider.css dist/",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
23
25
  "prepare": "npm run build"
24
26
  },
25
27
  "keywords": [
@@ -38,8 +40,10 @@
38
40
  "author": "Cesar Devs",
39
41
  "license": "UNLICENSED",
40
42
  "devDependencies": {
43
+ "jsdom": "^25.0.0",
41
44
  "tsup": "^8.0.0",
42
- "typescript": "^5.0.0"
45
+ "typescript": "^5.0.0",
46
+ "vitest": "^3.0.0"
43
47
  },
44
48
  "repository": {
45
49
  "type": "git",