lazer-slider 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -20,14 +20,622 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- greet: () => greet
23
+ createSlider: () => createSlider,
24
+ easeInOutCubic: () => easeInOutCubic,
25
+ easeOutCubic: () => easeOutCubic,
26
+ easeOutExpo: () => easeOutExpo,
27
+ easeOutQuad: () => easeOutQuad,
28
+ linear: () => linear
24
29
  });
25
30
  module.exports = __toCommonJS(index_exports);
26
- function greet(name) {
27
- return `Hello, ${name}!`;
28
- }
31
+
32
+ // src/core/easing.ts
33
+ var easeOutExpo = (t) => t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
34
+ var easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
35
+ var easeInOutCubic = (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
36
+ var easeOutQuad = (t) => 1 - (1 - t) * (1 - t);
37
+ var linear = (t) => t;
38
+
39
+ // src/core/accessibility.ts
40
+ var generateSliderId = () => `slider-${Math.random().toString(36).substring(2, 9)}`;
41
+ var initAria = (settings) => {
42
+ const { feed, prevSlideButton, nextSlideButton, thumbs, slides } = settings;
43
+ if (!feed.id) {
44
+ feed.id = generateSliderId();
45
+ }
46
+ feed.setAttribute("role", "region");
47
+ feed.setAttribute("aria-label", "Carousel");
48
+ feed.setAttribute("aria-roledescription", "carousel");
49
+ feed.removeAttribute("tabindex");
50
+ slides.forEach((slide, index) => {
51
+ slide.setAttribute("role", "group");
52
+ slide.setAttribute("aria-roledescription", "slide");
53
+ slide.setAttribute("aria-label", `Slide ${index + 1} of ${slides.length}`);
54
+ });
55
+ if (prevSlideButton) {
56
+ prevSlideButton.setAttribute("aria-label", "Previous slide");
57
+ prevSlideButton.setAttribute("aria-controls", feed.id);
58
+ prevSlideButton.setAttribute("tabindex", "0");
59
+ if (prevSlideButton.tagName !== "BUTTON") {
60
+ prevSlideButton.setAttribute("role", "button");
61
+ }
62
+ }
63
+ if (nextSlideButton) {
64
+ nextSlideButton.setAttribute("aria-label", "Next slide");
65
+ nextSlideButton.setAttribute("aria-controls", feed.id);
66
+ nextSlideButton.setAttribute("tabindex", "0");
67
+ if (nextSlideButton.tagName !== "BUTTON") {
68
+ nextSlideButton.setAttribute("role", "button");
69
+ }
70
+ }
71
+ if (thumbs?.length) {
72
+ thumbs.forEach((thumb, index) => {
73
+ if (thumb.tagName !== "BUTTON") {
74
+ thumb.setAttribute("role", "button");
75
+ }
76
+ thumb.setAttribute("aria-label", `Go to slide ${index + 1}`);
77
+ thumb.setAttribute("tabindex", "0");
78
+ thumb.setAttribute("aria-controls", feed.id);
79
+ });
80
+ }
81
+ };
82
+ var toggleControlVisibility = (button, shouldShow, feedElement) => {
83
+ if (!button) return;
84
+ if (!shouldShow && button === document.activeElement && feedElement) {
85
+ feedElement.focus();
86
+ }
87
+ const transition = "opacity 0.3s ease";
88
+ const opacity = shouldShow ? "1" : "0";
89
+ Object.assign(button.style, {
90
+ opacity,
91
+ transition,
92
+ pointerEvents: shouldShow ? "auto" : "none"
93
+ });
94
+ if (!shouldShow) {
95
+ button.setAttribute("aria-hidden", "true");
96
+ button.setAttribute("tabindex", "-1");
97
+ } else {
98
+ button.removeAttribute("aria-hidden");
99
+ button.setAttribute("tabindex", "0");
100
+ }
101
+ if (!shouldShow) {
102
+ setTimeout(() => {
103
+ if (button.style.opacity === "0") {
104
+ button.style.visibility = "hidden";
105
+ }
106
+ }, 300);
107
+ } else {
108
+ button.style.visibility = "visible";
109
+ }
110
+ };
111
+ var updateActiveThumb = (thumbs, currentIndex, activeClass = "active") => {
112
+ if (!thumbs?.length) return;
113
+ thumbs.forEach((thumb, index) => {
114
+ const isActive = index === currentIndex;
115
+ thumb.classList.toggle(activeClass, isActive);
116
+ thumb.setAttribute("aria-selected", isActive.toString());
117
+ });
118
+ };
119
+ var setupKeyboardNavigation = (feed, onPrev, onNext, abortSignal) => {
120
+ feed.addEventListener(
121
+ "keydown",
122
+ (event) => {
123
+ switch (event.key) {
124
+ case "ArrowLeft":
125
+ event.preventDefault();
126
+ onPrev();
127
+ break;
128
+ case "ArrowRight":
129
+ event.preventDefault();
130
+ onNext();
131
+ break;
132
+ }
133
+ },
134
+ { signal: abortSignal }
135
+ );
136
+ if (!feed.hasAttribute("tabindex")) {
137
+ feed.setAttribute("tabindex", "0");
138
+ }
139
+ };
140
+
141
+ // src/core/drag.ts
142
+ var createDragState = () => ({
143
+ isDragging: false,
144
+ startX: 0,
145
+ startScrollLeft: 0,
146
+ velocity: 0,
147
+ lastX: 0,
148
+ lastTime: 0,
149
+ momentumId: null
150
+ });
151
+ var findNearestSlide = (feed, slides) => {
152
+ const feedRect = feed.getBoundingClientRect();
153
+ const feedCenter = feedRect.left + feedRect.width / 2;
154
+ let nearestSlide = null;
155
+ let minDistance = Infinity;
156
+ for (const slide of slides) {
157
+ if (slide.offsetParent === null) continue;
158
+ const slideRect = slide.getBoundingClientRect();
159
+ const slideCenter = slideRect.left + slideRect.width / 2;
160
+ const distance = Math.abs(feedCenter - slideCenter);
161
+ if (distance < minDistance) {
162
+ minDistance = distance;
163
+ nearestSlide = slide;
164
+ }
165
+ }
166
+ return nearestSlide;
167
+ };
168
+ var applyMomentum = (state, feed, slides, smoothScrollTo, onDragEnd) => {
169
+ const friction = 0.95;
170
+ const minVelocity = 0.5;
171
+ const animate = () => {
172
+ if (Math.abs(state.velocity) < minVelocity) {
173
+ state.momentumId = null;
174
+ const nearestSlide = findNearestSlide(feed, slides);
175
+ if (nearestSlide) {
176
+ smoothScrollTo(nearestSlide.offsetLeft, easeOutCubic);
177
+ }
178
+ onDragEnd?.();
179
+ return;
180
+ }
181
+ feed.scrollLeft += state.velocity;
182
+ state.velocity *= friction;
183
+ state.momentumId = requestAnimationFrame(animate);
184
+ };
185
+ state.momentumId = requestAnimationFrame(animate);
186
+ };
187
+ var getEventX = (event) => {
188
+ if ("touches" in event) {
189
+ return event.touches[0]?.clientX ?? 0;
190
+ }
191
+ return event.clientX;
192
+ };
193
+ var setupDragToScroll = (config) => {
194
+ const { feed, slides, abortSignal, smoothScrollTo, onDragEnd } = config;
195
+ const state = createDragState();
196
+ const handleDragStart = (event) => {
197
+ if (state.momentumId !== null) {
198
+ cancelAnimationFrame(state.momentumId);
199
+ state.momentumId = null;
200
+ }
201
+ state.isDragging = true;
202
+ state.startX = getEventX(event);
203
+ state.startScrollLeft = feed.scrollLeft;
204
+ state.velocity = 0;
205
+ state.lastX = state.startX;
206
+ state.lastTime = performance.now();
207
+ feed.style.cursor = "grabbing";
208
+ feed.style.userSelect = "none";
209
+ if (event.type === "mousedown") {
210
+ event.preventDefault();
211
+ }
212
+ };
213
+ const handleDragMove = (event) => {
214
+ if (!state.isDragging) return;
215
+ const currentX = getEventX(event);
216
+ const currentTime = performance.now();
217
+ const deltaX = state.startX - currentX;
218
+ const deltaTime = currentTime - state.lastTime;
219
+ feed.scrollLeft = state.startScrollLeft + deltaX;
220
+ if (deltaTime > 0) {
221
+ state.velocity = (state.lastX - currentX) / deltaTime * 16;
222
+ }
223
+ state.lastX = currentX;
224
+ state.lastTime = currentTime;
225
+ if (event.type === "touchmove") {
226
+ event.preventDefault();
227
+ }
228
+ };
229
+ const handleDragEnd = () => {
230
+ if (!state.isDragging) return;
231
+ state.isDragging = false;
232
+ feed.style.cursor = "grab";
233
+ feed.style.userSelect = "";
234
+ if (Math.abs(state.velocity) > 1) {
235
+ applyMomentum(state, feed, slides, smoothScrollTo, onDragEnd);
236
+ } else {
237
+ const nearestSlide = findNearestSlide(feed, slides);
238
+ if (nearestSlide) {
239
+ smoothScrollTo(nearestSlide.offsetLeft, easeOutCubic);
240
+ }
241
+ onDragEnd?.();
242
+ }
243
+ };
244
+ feed.style.cursor = "grab";
245
+ feed.addEventListener("mousedown", handleDragStart, { signal: abortSignal });
246
+ document.addEventListener("mousemove", handleDragMove, { signal: abortSignal });
247
+ document.addEventListener("mouseup", handleDragEnd, { signal: abortSignal });
248
+ feed.addEventListener("touchstart", handleDragStart, {
249
+ passive: true,
250
+ signal: abortSignal
251
+ });
252
+ feed.addEventListener("touchmove", handleDragMove, {
253
+ passive: false,
254
+ // Need to prevent default
255
+ signal: abortSignal
256
+ });
257
+ feed.addEventListener("touchend", handleDragEnd, { signal: abortSignal });
258
+ document.addEventListener("mouseleave", handleDragEnd, { signal: abortSignal });
259
+ return state;
260
+ };
261
+ var cleanupDrag = (state) => {
262
+ if (state.momentumId !== null) {
263
+ cancelAnimationFrame(state.momentumId);
264
+ state.momentumId = null;
265
+ }
266
+ };
267
+
268
+ // src/core/slider.ts
269
+ var ANIMATION = {
270
+ MIN_DURATION: 400,
271
+ MAX_DURATION: 1e3,
272
+ SPEED_FACTOR: 1.5,
273
+ SCROLL_END_DELAY: 50,
274
+ THUMB_UPDATE_DELAY: 500
275
+ };
276
+ var DESKTOP_BREAKPOINT = "(min-width: 64rem)";
277
+ var createSlider = (settings) => {
278
+ if (!settings.feed) {
279
+ throw new Error("lazer-slider: feed element is required");
280
+ }
281
+ if (!settings.slides?.length) {
282
+ throw new Error("lazer-slider: slides array is required and must not be empty");
283
+ }
284
+ const state = {
285
+ currentSlideIndex: 0,
286
+ isScrolling: false,
287
+ ticking: false,
288
+ cachedFeedRect: null,
289
+ lastWidth: 0,
290
+ updateThumbTimeout: null,
291
+ scrollEndTimeout: null,
292
+ abortController: new AbortController(),
293
+ autoplayIntervalId: null,
294
+ autoplayPaused: false
295
+ };
296
+ let dragState = null;
297
+ const easing = settings.easing ?? easeOutExpo;
298
+ const getFeedRect = () => {
299
+ const currentWidth = settings.feed.clientWidth;
300
+ if (!state.cachedFeedRect || state.lastWidth !== currentWidth) {
301
+ state.cachedFeedRect = settings.feed.getBoundingClientRect();
302
+ state.lastWidth = currentWidth;
303
+ }
304
+ return state.cachedFeedRect;
305
+ };
306
+ const getVisibleSlides = () => {
307
+ return settings.slides.filter((slide) => slide.offsetParent !== null);
308
+ };
309
+ const isDesktop = () => {
310
+ return window.matchMedia(DESKTOP_BREAKPOINT).matches;
311
+ };
312
+ const applySlideWidths = () => {
313
+ const perView = isDesktop() ? settings.desktopSlidesPerView : settings.mobileSlidesPerView;
314
+ const gap = settings.slideGap ?? 0;
315
+ if (gap > 0) {
316
+ settings.feed.style.gap = `${gap}px`;
317
+ }
318
+ if (!perView || perView === "auto") {
319
+ settings.slides.forEach((slide) => {
320
+ slide.style.flex = "";
321
+ slide.style.minWidth = "";
322
+ });
323
+ return;
324
+ }
325
+ const totalGapWidth = gap * (perView - 1);
326
+ const slideWidth = `calc((100% - ${totalGapWidth}px) / ${perView})`;
327
+ settings.slides.forEach((slide) => {
328
+ slide.style.flex = `0 0 ${slideWidth}`;
329
+ slide.style.minWidth = slideWidth;
330
+ });
331
+ };
332
+ const updateScrollbar = () => {
333
+ if (!settings.scrollbarThumb) return;
334
+ const feedRect = getFeedRect();
335
+ const thumbWidth = feedRect.width / settings.feed.scrollWidth * 100;
336
+ settings.scrollbarThumb.style.width = `${thumbWidth}%`;
337
+ };
338
+ const updateScrollbarPosition = () => {
339
+ if (!settings.scrollbarThumb || !settings.scrollbarTrack) return;
340
+ const trackWidth = settings.scrollbarTrack.getBoundingClientRect().width;
341
+ const thumbWidth = settings.scrollbarThumb.getBoundingClientRect().width;
342
+ const totalTransform = trackWidth - thumbWidth;
343
+ const maxScroll = settings.feed.scrollWidth - settings.feed.clientWidth;
344
+ const scrollProgress = maxScroll > 0 ? settings.feed.scrollLeft / maxScroll : 0;
345
+ settings.scrollbarThumb.style.transform = `translateX(${totalTransform * scrollProgress}px)`;
346
+ };
347
+ const updateControlsVisibility = () => {
348
+ const feedRect = getFeedRect();
349
+ const isAtStart = settings.feed.scrollLeft <= 1;
350
+ const isAtEnd = settings.feed.scrollLeft + feedRect.width >= settings.feed.scrollWidth - 1;
351
+ const shouldHideScrollbar = settings.feed.scrollWidth <= feedRect.width;
352
+ if (settings.scrollbarTrack) {
353
+ settings.scrollbarTrack.style.display = shouldHideScrollbar ? "none" : "block";
354
+ }
355
+ if (settings.loop) {
356
+ toggleControlVisibility(
357
+ settings.prevSlideButton,
358
+ !shouldHideScrollbar,
359
+ settings.feed
360
+ );
361
+ toggleControlVisibility(
362
+ settings.nextSlideButton,
363
+ !shouldHideScrollbar,
364
+ settings.feed
365
+ );
366
+ return;
367
+ }
368
+ toggleControlVisibility(
369
+ settings.prevSlideButton,
370
+ !isAtStart && !shouldHideScrollbar,
371
+ settings.feed
372
+ );
373
+ toggleControlVisibility(
374
+ settings.nextSlideButton,
375
+ !isAtEnd && !shouldHideScrollbar,
376
+ settings.feed
377
+ );
378
+ };
379
+ const updateCurrentSlideIndex = () => {
380
+ const feedRect = getFeedRect();
381
+ const allVisibleSlides = getVisibleSlides();
382
+ const viewportVisibleSlides = settings.slides.filter((slide) => {
383
+ const slideRect = slide.getBoundingClientRect();
384
+ const tolerance = 20;
385
+ return slideRect.right > feedRect.left + tolerance && slideRect.left < feedRect.right - tolerance;
386
+ });
387
+ if (viewportVisibleSlides.length && viewportVisibleSlides[0]) {
388
+ const newIndex = allVisibleSlides.indexOf(viewportVisibleSlides[0]);
389
+ if (newIndex !== -1) {
390
+ state.currentSlideIndex = newIndex;
391
+ settings.onScroll?.({
392
+ currentScroll: settings.feed.scrollLeft,
393
+ currentSlideIndex: state.currentSlideIndex
394
+ });
395
+ }
396
+ }
397
+ };
398
+ const smoothScrollTo = (target, customEasing = easing) => {
399
+ const start = settings.feed.scrollLeft;
400
+ const distance = Math.abs(target - start);
401
+ const duration = Math.min(
402
+ ANIMATION.MAX_DURATION,
403
+ Math.max(ANIMATION.MIN_DURATION, distance / ANIMATION.SPEED_FACTOR)
404
+ );
405
+ const startTime = performance.now();
406
+ const animateScroll = (currentTime) => {
407
+ const elapsed = (currentTime - startTime) / duration;
408
+ const progress = Math.min(elapsed, 1);
409
+ const ease = customEasing(progress);
410
+ settings.feed.scrollLeft = start + (target - start) * ease;
411
+ if (progress < 1) {
412
+ requestAnimationFrame(animateScroll);
413
+ } else {
414
+ settings.feed.scrollLeft = target;
415
+ }
416
+ };
417
+ requestAnimationFrame(animateScroll);
418
+ };
419
+ const handleThumbClick = (thumb) => {
420
+ if (!settings.thumbs) return;
421
+ const index = settings.thumbs.indexOf(thumb);
422
+ if (index === -1 || !settings.slides[index]) return;
423
+ state.currentSlideIndex = index;
424
+ updateActiveThumb(settings.thumbs, index);
425
+ state.isScrolling = true;
426
+ if (state.updateThumbTimeout) {
427
+ clearTimeout(state.updateThumbTimeout);
428
+ }
429
+ state.updateThumbTimeout = setTimeout(() => {
430
+ state.isScrolling = false;
431
+ }, ANIMATION.THUMB_UPDATE_DELAY);
432
+ smoothScrollTo(settings.slides[index].offsetLeft);
433
+ };
434
+ const handleNavButtonClick = (direction) => {
435
+ const visibleSlides = getVisibleSlides();
436
+ const slidesToScroll = isDesktop() ? settings.desktopSlidesPerScroll ?? 1 : settings.mobileSlidesPerScroll ?? 1;
437
+ const totalSlides = visibleSlides.length;
438
+ updateCurrentSlideIndex();
439
+ if (direction === "prev") {
440
+ if (settings.loop && state.currentSlideIndex === 0) {
441
+ state.currentSlideIndex = totalSlides - 1;
442
+ } else {
443
+ state.currentSlideIndex = Math.max(0, state.currentSlideIndex - slidesToScroll);
444
+ }
445
+ } else {
446
+ if (settings.loop && state.currentSlideIndex >= totalSlides - 1) {
447
+ state.currentSlideIndex = 0;
448
+ } else {
449
+ state.currentSlideIndex = Math.min(
450
+ totalSlides - 1,
451
+ state.currentSlideIndex + slidesToScroll
452
+ );
453
+ }
454
+ }
455
+ const targetSlide = visibleSlides[state.currentSlideIndex];
456
+ if (!targetSlide) return;
457
+ settings.onScrollStart?.({
458
+ currentScroll: settings.feed.scrollLeft,
459
+ target: targetSlide,
460
+ direction
461
+ });
462
+ smoothScrollTo(targetSlide.offsetLeft);
463
+ };
464
+ const updateScrollPosition = () => {
465
+ updateScrollbarPosition();
466
+ updateControlsVisibility();
467
+ updateCurrentSlideIndex();
468
+ if (!state.isScrolling) {
469
+ updateActiveThumb(settings.thumbs, state.currentSlideIndex);
470
+ }
471
+ if (state.scrollEndTimeout) {
472
+ clearTimeout(state.scrollEndTimeout);
473
+ }
474
+ state.scrollEndTimeout = setTimeout(() => {
475
+ state.isScrolling = false;
476
+ settings.onScrollEnd?.({
477
+ currentScroll: settings.feed.scrollLeft,
478
+ currentSlideIndex: state.currentSlideIndex
479
+ });
480
+ }, ANIMATION.SCROLL_END_DELAY);
481
+ };
482
+ const handleFeedScroll = () => {
483
+ if (!state.ticking) {
484
+ requestAnimationFrame(() => {
485
+ updateScrollPosition();
486
+ state.ticking = false;
487
+ });
488
+ state.ticking = true;
489
+ }
490
+ };
491
+ const handleWindowResize = () => {
492
+ state.cachedFeedRect = null;
493
+ refresh();
494
+ };
495
+ const attachEventListeners = () => {
496
+ const { signal } = state.abortController;
497
+ window.addEventListener("resize", handleWindowResize);
498
+ settings.feed.addEventListener("scroll", handleFeedScroll, {
499
+ passive: true,
500
+ signal
501
+ });
502
+ if (settings.prevSlideButton) {
503
+ settings.prevSlideButton.addEventListener(
504
+ "click",
505
+ () => handleNavButtonClick("prev"),
506
+ { signal }
507
+ );
508
+ }
509
+ if (settings.nextSlideButton) {
510
+ settings.nextSlideButton.addEventListener(
511
+ "click",
512
+ () => handleNavButtonClick("next"),
513
+ { signal }
514
+ );
515
+ }
516
+ if (settings.thumbs?.length) {
517
+ settings.thumbs[0]?.classList.add("active");
518
+ settings.thumbs.forEach((thumb) => {
519
+ thumb.addEventListener("click", () => handleThumbClick(thumb), { signal });
520
+ });
521
+ }
522
+ setupKeyboardNavigation(
523
+ settings.feed,
524
+ () => handleNavButtonClick("prev"),
525
+ () => handleNavButtonClick("next"),
526
+ signal
527
+ );
528
+ if (settings.enableDragToScroll) {
529
+ dragState = setupDragToScroll({
530
+ feed: settings.feed,
531
+ slides: settings.slides,
532
+ abortSignal: signal,
533
+ smoothScrollTo,
534
+ onDragEnd: () => {
535
+ updateCurrentSlideIndex();
536
+ updateActiveThumb(settings.thumbs, state.currentSlideIndex);
537
+ }
538
+ });
539
+ }
540
+ if (settings.autoplay && settings.pauseOnHover !== false) {
541
+ settings.feed.addEventListener(
542
+ "mouseenter",
543
+ pauseAutoplay,
544
+ { signal }
545
+ );
546
+ settings.feed.addEventListener(
547
+ "mouseleave",
548
+ resumeAutoplay,
549
+ { signal }
550
+ );
551
+ settings.feed.addEventListener(
552
+ "touchstart",
553
+ pauseAutoplay,
554
+ { passive: true, signal }
555
+ );
556
+ settings.feed.addEventListener(
557
+ "touchend",
558
+ resumeAutoplay,
559
+ { signal }
560
+ );
561
+ }
562
+ };
563
+ const startAutoplay = () => {
564
+ if (state.autoplayIntervalId) return;
565
+ const interval = settings.autoplayInterval ?? 3e3;
566
+ state.autoplayIntervalId = setInterval(() => {
567
+ if (!state.autoplayPaused) {
568
+ handleNavButtonClick("next");
569
+ }
570
+ }, interval);
571
+ };
572
+ const stopAutoplay = () => {
573
+ if (state.autoplayIntervalId) {
574
+ clearInterval(state.autoplayIntervalId);
575
+ state.autoplayIntervalId = null;
576
+ }
577
+ };
578
+ const pauseAutoplay = () => {
579
+ state.autoplayPaused = true;
580
+ };
581
+ const resumeAutoplay = () => {
582
+ state.autoplayPaused = false;
583
+ };
584
+ const goToIndex = (index) => {
585
+ const visibleSlides = getVisibleSlides();
586
+ const safeIndex = Math.max(0, Math.min(index, visibleSlides.length - 1));
587
+ const targetSlide = visibleSlides[safeIndex];
588
+ if (!targetSlide) return;
589
+ state.currentSlideIndex = safeIndex;
590
+ updateActiveThumb(settings.thumbs, safeIndex);
591
+ smoothScrollTo(targetSlide.offsetLeft);
592
+ };
593
+ const refresh = () => {
594
+ state.cachedFeedRect = null;
595
+ applySlideWidths();
596
+ updateScrollbar();
597
+ updateControlsVisibility();
598
+ };
599
+ const unload = () => {
600
+ stopAutoplay();
601
+ state.abortController.abort();
602
+ window.removeEventListener("resize", handleWindowResize);
603
+ if (state.updateThumbTimeout) {
604
+ clearTimeout(state.updateThumbTimeout);
605
+ }
606
+ if (state.scrollEndTimeout) {
607
+ clearTimeout(state.scrollEndTimeout);
608
+ }
609
+ if (dragState) {
610
+ cleanupDrag(dragState);
611
+ }
612
+ state.cachedFeedRect = null;
613
+ };
614
+ initAria(settings);
615
+ applySlideWidths();
616
+ updateControlsVisibility();
617
+ attachEventListeners();
618
+ updateScrollbar();
619
+ if (settings.autoplay) {
620
+ startAutoplay();
621
+ }
622
+ return {
623
+ goToIndex,
624
+ refresh,
625
+ unload,
626
+ play: startAutoplay,
627
+ pause: stopAutoplay,
628
+ next: () => handleNavButtonClick("next"),
629
+ prev: () => handleNavButtonClick("prev")
630
+ };
631
+ };
29
632
  // Annotate the CommonJS export names for ESM import in node:
30
633
  0 && (module.exports = {
31
- greet
634
+ createSlider,
635
+ easeInOutCubic,
636
+ easeOutCubic,
637
+ easeOutExpo,
638
+ easeOutQuad,
639
+ linear
32
640
  });
33
641
  //# sourceMappingURL=index.cjs.map