lazer-slider 1.1.4 → 1.1.6
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 +132 -153
- package/dist/index.cjs +2 -1197
- package/dist/index.d.cts +1 -28
- package/dist/index.d.ts +1 -28
- package/dist/index.js +2 -1161
- package/dist/lazer-slider.css +5 -9
- package/package.json +5 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -14,7 +14,8 @@ A lightweight, accessible slider with smooth scroll-to-snap animations, drag-to-
|
|
|
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)
|
|
17
|
-
- **
|
|
17
|
+
- **Optional CSS** - Ready-to-use styles with CSS custom properties for easy theming
|
|
18
|
+
- **Lightweight** - Zero dependencies, ~17KB minified
|
|
18
19
|
- **TypeScript** - Full type definitions included
|
|
19
20
|
|
|
20
21
|
## Installation
|
|
@@ -29,8 +30,8 @@ npm install lazer-slider
|
|
|
29
30
|
|
|
30
31
|
```html
|
|
31
32
|
<div class="lazer-slider">
|
|
32
|
-
<button class="lazer-prev"
|
|
33
|
-
<button class="lazer-next"
|
|
33
|
+
<button class="lazer-nav lazer-prev">‹</button>
|
|
34
|
+
<button class="lazer-nav lazer-next">›</button>
|
|
34
35
|
|
|
35
36
|
<div class="lazer-feed">
|
|
36
37
|
<div class="lazer-slide">Slide 1</div>
|
|
@@ -44,52 +45,25 @@ npm install lazer-slider
|
|
|
44
45
|
|
|
45
46
|
### CSS
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
Import the optional stylesheet for ready-to-use styles:
|
|
48
49
|
|
|
49
|
-
```
|
|
50
|
-
<div class="lazer-slider">
|
|
51
|
-
<button class="lazer-prev">Previous</button>
|
|
52
|
-
<button class="lazer-next">Next</button>
|
|
53
|
-
|
|
54
|
-
<div class="lazer-feed">
|
|
55
|
-
<div class="lazer-slide">Slide 1</div>
|
|
56
|
-
<div class="lazer-slide">Slide 2</div>
|
|
57
|
-
<div class="lazer-slide">Slide 3</div>
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
<div class="lazer-bullets"></div>
|
|
61
|
-
</div>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**Optional Styles:** For bullets, thumbs, scrollbar, and navigation styling, import the optional CSS file:
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
// Import optional styles for bullets, thumbs, scrollbar, etc.
|
|
50
|
+
```js
|
|
68
51
|
import 'lazer-slider/css'
|
|
69
52
|
```
|
|
70
53
|
|
|
71
54
|
Or in HTML:
|
|
55
|
+
|
|
72
56
|
```html
|
|
73
57
|
<link rel="stylesheet" href="node_modules/lazer-slider/dist/lazer-slider.css">
|
|
74
58
|
```
|
|
75
59
|
|
|
76
|
-
**
|
|
77
|
-
|
|
78
|
-
```css
|
|
79
|
-
/* Override the auto-injected styles */
|
|
80
|
-
.lazer-feed {
|
|
81
|
-
gap: 20px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.lazer-slide {
|
|
85
|
-
scroll-snap-align: center; /* Change snap alignment */
|
|
86
|
-
}
|
|
87
|
-
```
|
|
60
|
+
> **Note:** The CSS is optional. You can write your own styles or customize the included ones using CSS custom properties. See [Styling](#styling) for details.
|
|
88
61
|
|
|
89
62
|
### JavaScript
|
|
90
63
|
|
|
91
64
|
```typescript
|
|
92
65
|
import { createSlider } from 'lazer-slider'
|
|
66
|
+
import 'lazer-slider/css'
|
|
93
67
|
|
|
94
68
|
const slider = createSlider({
|
|
95
69
|
feed: document.querySelector('.lazer-feed'),
|
|
@@ -97,6 +71,7 @@ const slider = createSlider({
|
|
|
97
71
|
prevSlideButton: document.querySelector('.lazer-prev'),
|
|
98
72
|
nextSlideButton: document.querySelector('.lazer-next'),
|
|
99
73
|
bulletsContainer: document.querySelector('.lazer-bullets'),
|
|
74
|
+
bulletsClass: 'lazer-bullet',
|
|
100
75
|
enableDragToScroll: true
|
|
101
76
|
})
|
|
102
77
|
|
|
@@ -121,10 +96,10 @@ slider.unload()
|
|
|
121
96
|
| `nextSlideButton` | `HTMLElement \| null` | `null` | Next slide button |
|
|
122
97
|
| `thumbs` | `HTMLElement[]` | `undefined` | Thumbnail/dot elements for direct navigation (manual) |
|
|
123
98
|
| `bulletsContainer` | `HTMLElement \| null` | `null` | Container element for auto-generated bullets |
|
|
124
|
-
| `bulletsClass` | `string` | `'
|
|
99
|
+
| `bulletsClass` | `string` | `'slider-bullet'` | CSS class for bullet elements |
|
|
125
100
|
| `bulletsActiveClass` | `string` | `'active'` | CSS class for active bullet element |
|
|
126
101
|
| `thumbsContainer` | `HTMLElement \| null` | `null` | Container element for auto-generated thumbnails |
|
|
127
|
-
| `thumbsClass` | `string` | `'
|
|
102
|
+
| `thumbsClass` | `string` | `'slider-thumb'` | CSS class for thumbnail elements |
|
|
128
103
|
| `thumbsActiveClass` | `string` | `'active'` | CSS class for active thumbnail element |
|
|
129
104
|
| `thumbImageSelector` | `string` | `'img'` | CSS selector to find image inside each slide |
|
|
130
105
|
| `thumbSize` | `{ width: number; height: number }` | `undefined` | Fixed dimensions for thumbnail images |
|
|
@@ -255,7 +230,7 @@ const slider = createSlider({
|
|
|
255
230
|
|
|
256
231
|
```typescript
|
|
257
232
|
const slider = createSlider({
|
|
258
|
-
feed: document.querySelector('.
|
|
233
|
+
feed: document.querySelector('.slider-feed'),
|
|
259
234
|
slides: [...document.querySelectorAll('.slide')]
|
|
260
235
|
})
|
|
261
236
|
```
|
|
@@ -264,10 +239,10 @@ const slider = createSlider({
|
|
|
264
239
|
|
|
265
240
|
```typescript
|
|
266
241
|
const slider = createSlider({
|
|
267
|
-
feed: document.querySelector('.
|
|
242
|
+
feed: document.querySelector('.slider-feed'),
|
|
268
243
|
slides: [...document.querySelectorAll('.slide')],
|
|
269
244
|
prevSlideButton: document.querySelector('.prev'),
|
|
270
|
-
nextSlideButton: document.querySelector('.
|
|
245
|
+
nextSlideButton: document.querySelector('.next')
|
|
271
246
|
})
|
|
272
247
|
```
|
|
273
248
|
|
|
@@ -275,7 +250,7 @@ const slider = createSlider({
|
|
|
275
250
|
|
|
276
251
|
```typescript
|
|
277
252
|
const slider = createSlider({
|
|
278
|
-
feed: document.querySelector('.
|
|
253
|
+
feed: document.querySelector('.slider-feed'),
|
|
279
254
|
slides: [...document.querySelectorAll('.slide')],
|
|
280
255
|
mobileSlidesPerView: 1,
|
|
281
256
|
desktopSlidesPerView: 3,
|
|
@@ -289,7 +264,7 @@ const slider = createSlider({
|
|
|
289
264
|
|
|
290
265
|
```typescript
|
|
291
266
|
const slider = createSlider({
|
|
292
|
-
feed: document.querySelector('.
|
|
267
|
+
feed: document.querySelector('.slider-feed'),
|
|
293
268
|
slides: [...document.querySelectorAll('.slide')],
|
|
294
269
|
loop: true,
|
|
295
270
|
autoplay: true,
|
|
@@ -334,19 +309,19 @@ Create a vertical scrolling slider for content that flows top-to-bottom.
|
|
|
334
309
|
|
|
335
310
|
```html
|
|
336
311
|
<div class="vertical-slider">
|
|
337
|
-
<button class="
|
|
338
|
-
<button class="
|
|
312
|
+
<button class="slider-prev">↑</button>
|
|
313
|
+
<button class="slider-next">↓</button>
|
|
339
314
|
|
|
340
315
|
<div class="slider-feed">
|
|
341
|
-
<div class="
|
|
342
|
-
<div class="
|
|
343
|
-
<div class="
|
|
316
|
+
<div class="slide">Slide 1</div>
|
|
317
|
+
<div class="slide">Slide 2</div>
|
|
318
|
+
<div class="slide">Slide 3</div>
|
|
344
319
|
</div>
|
|
345
320
|
</div>
|
|
346
321
|
```
|
|
347
322
|
|
|
348
323
|
```css
|
|
349
|
-
.
|
|
324
|
+
.slider-feed {
|
|
350
325
|
display: flex;
|
|
351
326
|
flex-direction: column;
|
|
352
327
|
overflow-y: auto;
|
|
@@ -354,7 +329,7 @@ Create a vertical scrolling slider for content that flows top-to-bottom.
|
|
|
354
329
|
scrollbar-width: none;
|
|
355
330
|
}
|
|
356
331
|
|
|
357
|
-
.
|
|
332
|
+
.slider-feed::-webkit-scrollbar {
|
|
358
333
|
display: none;
|
|
359
334
|
}
|
|
360
335
|
|
|
@@ -366,10 +341,10 @@ Create a vertical scrolling slider for content that flows top-to-bottom.
|
|
|
366
341
|
|
|
367
342
|
```typescript
|
|
368
343
|
const verticalSlider = createSlider({
|
|
369
|
-
feed: document.querySelector('.
|
|
344
|
+
feed: document.querySelector('.slider-feed'),
|
|
370
345
|
slides: [...document.querySelectorAll('.slide')],
|
|
371
|
-
prevSlideButton: document.querySelector('.
|
|
372
|
-
nextSlideButton: document.querySelector('.
|
|
346
|
+
prevSlideButton: document.querySelector('.slider-prev'),
|
|
347
|
+
nextSlideButton: document.querySelector('.slider-next'),
|
|
373
348
|
direction: 'vertical',
|
|
374
349
|
mobileSlidesPerView: 1,
|
|
375
350
|
desktopSlidesPerView: 1,
|
|
@@ -401,9 +376,9 @@ The slider can automatically generate bullets from your slides. Just provide a c
|
|
|
401
376
|
```html
|
|
402
377
|
<div class="slider">
|
|
403
378
|
<div class="slider-feed">
|
|
404
|
-
<div class="
|
|
405
|
-
<div class="
|
|
406
|
-
<div class="
|
|
379
|
+
<div class="slide">Slide 1</div>
|
|
380
|
+
<div class="slide">Slide 2</div>
|
|
381
|
+
<div class="slide">Slide 3</div>
|
|
407
382
|
</div>
|
|
408
383
|
|
|
409
384
|
<div class="slider-bullets"></div>
|
|
@@ -411,14 +386,14 @@ The slider can automatically generate bullets from your slides. Just provide a c
|
|
|
411
386
|
```
|
|
412
387
|
|
|
413
388
|
```css
|
|
414
|
-
.
|
|
389
|
+
.slider-bullets {
|
|
415
390
|
display: flex;
|
|
416
391
|
gap: 8px;
|
|
417
392
|
justify-content: center;
|
|
418
393
|
margin-top: 16px;
|
|
419
394
|
}
|
|
420
395
|
|
|
421
|
-
.
|
|
396
|
+
.slider-bullet {
|
|
422
397
|
width: 12px;
|
|
423
398
|
height: 12px;
|
|
424
399
|
border-radius: 50%;
|
|
@@ -428,16 +403,16 @@ The slider can automatically generate bullets from your slides. Just provide a c
|
|
|
428
403
|
transition: background 0.3s;
|
|
429
404
|
}
|
|
430
405
|
|
|
431
|
-
.
|
|
406
|
+
.slider-bullet.active {
|
|
432
407
|
background: #333;
|
|
433
408
|
}
|
|
434
409
|
```
|
|
435
410
|
|
|
436
411
|
```typescript
|
|
437
412
|
const slider = createSlider({
|
|
438
|
-
feed: document.querySelector('.
|
|
413
|
+
feed: document.querySelector('.slider-feed'),
|
|
439
414
|
slides: [...document.querySelectorAll('.slide')],
|
|
440
|
-
bulletsContainer: document.querySelector('.
|
|
415
|
+
bulletsContainer: document.querySelector('.slider-bullets'),
|
|
441
416
|
bulletsClass: 'slider-bullet', // Optional: default is 'slider-bullet'
|
|
442
417
|
bulletsActiveClass: 'active' // Optional: default is 'active'
|
|
443
418
|
})
|
|
@@ -456,9 +431,9 @@ Alternatively, you can create bullets manually and pass them via the `thumbs` op
|
|
|
456
431
|
```html
|
|
457
432
|
<div class="slider">
|
|
458
433
|
<div class="slider-feed">
|
|
459
|
-
<div class="
|
|
460
|
-
<div class="
|
|
461
|
-
<div class="
|
|
434
|
+
<div class="slide">Slide 1</div>
|
|
435
|
+
<div class="slide">Slide 2</div>
|
|
436
|
+
<div class="slide">Slide 3</div>
|
|
462
437
|
</div>
|
|
463
438
|
|
|
464
439
|
<div class="slider-dots">
|
|
@@ -494,7 +469,7 @@ Alternatively, you can create bullets manually and pass them via the `thumbs` op
|
|
|
494
469
|
|
|
495
470
|
```typescript
|
|
496
471
|
const slider = createSlider({
|
|
497
|
-
feed: document.querySelector('.
|
|
472
|
+
feed: document.querySelector('.slider-feed'),
|
|
498
473
|
slides: [...document.querySelectorAll('.slide')],
|
|
499
474
|
thumbs: [...document.querySelectorAll('.dot')]
|
|
500
475
|
})
|
|
@@ -509,15 +484,15 @@ Auto-generate clickable thumbnail images from your slides. Perfect for product g
|
|
|
509
484
|
```html
|
|
510
485
|
<div class="slider">
|
|
511
486
|
<div class="slider-feed">
|
|
512
|
-
<div class="
|
|
487
|
+
<div class="slide">
|
|
513
488
|
<img src="/images/product-1.jpg" alt="Product 1">
|
|
514
489
|
<h3>Product Title 1</h3>
|
|
515
490
|
</div>
|
|
516
|
-
<div class="
|
|
491
|
+
<div class="slide">
|
|
517
492
|
<img src="/images/product-2.jpg" alt="Product 2">
|
|
518
493
|
<h3>Product Title 2</h3>
|
|
519
494
|
</div>
|
|
520
|
-
<div class="
|
|
495
|
+
<div class="slide">
|
|
521
496
|
<img src="/images/product-3.jpg" alt="Product 3">
|
|
522
497
|
<h3>Product Title 3</h3>
|
|
523
498
|
</div>
|
|
@@ -536,7 +511,7 @@ Auto-generate clickable thumbnail images from your slides. Perfect for product g
|
|
|
536
511
|
justify-content: center;
|
|
537
512
|
}
|
|
538
513
|
|
|
539
|
-
.
|
|
514
|
+
.slider-thumb {
|
|
540
515
|
padding: 0;
|
|
541
516
|
border: 2px solid transparent;
|
|
542
517
|
background: none;
|
|
@@ -545,16 +520,16 @@ Auto-generate clickable thumbnail images from your slides. Perfect for product g
|
|
|
545
520
|
transition: opacity 0.2s, border-color 0.2s;
|
|
546
521
|
}
|
|
547
522
|
|
|
548
|
-
.
|
|
523
|
+
.slider-thumb:hover {
|
|
549
524
|
opacity: 0.8;
|
|
550
525
|
}
|
|
551
526
|
|
|
552
|
-
.
|
|
527
|
+
.slider-thumb.active {
|
|
553
528
|
opacity: 1;
|
|
554
529
|
border-color: #007bff;
|
|
555
530
|
}
|
|
556
531
|
|
|
557
|
-
.
|
|
532
|
+
.slider-thumb img {
|
|
558
533
|
display: block;
|
|
559
534
|
border-radius: 4px;
|
|
560
535
|
}
|
|
@@ -562,7 +537,7 @@ Auto-generate clickable thumbnail images from your slides. Perfect for product g
|
|
|
562
537
|
|
|
563
538
|
```typescript
|
|
564
539
|
const slider = createSlider({
|
|
565
|
-
feed: document.querySelector('.
|
|
540
|
+
feed: document.querySelector('.slider-feed'),
|
|
566
541
|
slides: [...document.querySelectorAll('.slide')],
|
|
567
542
|
thumbsContainer: document.querySelector('.thumbs-gallery'),
|
|
568
543
|
thumbsClass: 'slider-thumb', // Optional: default is 'slider-thumb'
|
|
@@ -591,9 +566,9 @@ Create a draggable scrollbar that syncs with the slider position.
|
|
|
591
566
|
```html
|
|
592
567
|
<div class="slider">
|
|
593
568
|
<div class="slider-feed">
|
|
594
|
-
<div class="
|
|
595
|
-
<div class="
|
|
596
|
-
<div class="
|
|
569
|
+
<div class="slide">Slide 1</div>
|
|
570
|
+
<div class="slide">Slide 2</div>
|
|
571
|
+
<div class="slide">Slide 3</div>
|
|
597
572
|
</div>
|
|
598
573
|
|
|
599
574
|
<div class="scrollbar-track">
|
|
@@ -622,7 +597,7 @@ Create a draggable scrollbar that syncs with the slider position.
|
|
|
622
597
|
|
|
623
598
|
```typescript
|
|
624
599
|
const slider = createSlider({
|
|
625
|
-
feed: document.querySelector('.
|
|
600
|
+
feed: document.querySelector('.slider-feed'),
|
|
626
601
|
slides: [...document.querySelectorAll('.slide')],
|
|
627
602
|
scrollbarThumb: document.querySelector('.scrollbar-thumb'),
|
|
628
603
|
scrollbarTrack: document.querySelector('.scrollbar-track')
|
|
@@ -654,7 +629,7 @@ Use `slidesPerView: 'auto'` when slides have different natural widths defined in
|
|
|
654
629
|
|
|
655
630
|
```typescript
|
|
656
631
|
const slider = createSlider({
|
|
657
|
-
feed: document.querySelector('.
|
|
632
|
+
feed: document.querySelector('.slider-feed'),
|
|
658
633
|
slides: [...document.querySelectorAll('.slide')],
|
|
659
634
|
mobileSlidesPerView: 'auto',
|
|
660
635
|
desktopSlidesPerView: 'auto',
|
|
@@ -667,13 +642,13 @@ const slider = createSlider({
|
|
|
667
642
|
|
|
668
643
|
```typescript
|
|
669
644
|
const slider = createSlider({
|
|
670
|
-
feed: document.querySelector('.
|
|
645
|
+
feed: document.querySelector('.slider-feed'),
|
|
671
646
|
slides: [...document.querySelectorAll('.slide')],
|
|
672
647
|
prevSlideButton: document.querySelector('.prev'),
|
|
673
|
-
nextSlideButton: document.querySelector('.
|
|
648
|
+
nextSlideButton: document.querySelector('.next'),
|
|
674
649
|
|
|
675
650
|
// Navigation (choose one: bullets OR thumbs)
|
|
676
|
-
bulletsContainer: document.querySelector('.
|
|
651
|
+
bulletsContainer: document.querySelector('.slider-bullets'), // Auto-generated bullets
|
|
677
652
|
// OR for image galleries:
|
|
678
653
|
// thumbsContainer: document.querySelector('.thumbs-gallery'),
|
|
679
654
|
// thumbSize: { width: 80, height: 60 },
|
|
@@ -696,13 +671,75 @@ const slider = createSlider({
|
|
|
696
671
|
})
|
|
697
672
|
```
|
|
698
673
|
|
|
699
|
-
##
|
|
674
|
+
## Accessibility
|
|
675
|
+
|
|
676
|
+
The slider automatically adds ARIA attributes for accessibility:
|
|
677
|
+
|
|
678
|
+
- `role="region"` and `aria-roledescription="carousel"` on the feed
|
|
679
|
+
- `role="group"` and `aria-label="Slide X of Y"` on each slide
|
|
680
|
+
- `aria-controls` linking buttons to the feed
|
|
681
|
+
- `aria-hidden` and `tabindex` management for visibility
|
|
682
|
+
- Keyboard navigation with arrow keys when feed is focused
|
|
683
|
+
|
|
684
|
+
## TypeScript
|
|
685
|
+
|
|
686
|
+
Full TypeScript support with exported types:
|
|
687
|
+
|
|
688
|
+
```typescript
|
|
689
|
+
import {
|
|
690
|
+
createSlider,
|
|
691
|
+
generateBullets,
|
|
692
|
+
generateThumbs,
|
|
693
|
+
type SliderSettings,
|
|
694
|
+
type Slider,
|
|
695
|
+
type EasingFunction,
|
|
696
|
+
type ScrollParams,
|
|
697
|
+
type ScrollStartParams,
|
|
698
|
+
type SliderDirection,
|
|
699
|
+
type MarqueeDirection
|
|
700
|
+
} from 'lazer-slider'
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
> **Note:** `generateBullets` and `generateThumbs` are also exported if you need to manually generate navigation elements outside of the slider initialization.
|
|
704
|
+
|
|
705
|
+
## Styling
|
|
706
|
+
|
|
707
|
+
### Optional CSS
|
|
700
708
|
|
|
701
|
-
|
|
709
|
+
Lazer Slider ships with an optional stylesheet that provides ready-to-use styles:
|
|
710
|
+
|
|
711
|
+
```js
|
|
712
|
+
import 'lazer-slider/css'
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
### CSS Classes
|
|
716
|
+
|
|
717
|
+
The stylesheet provides these class names:
|
|
718
|
+
|
|
719
|
+
| Class | Description |
|
|
720
|
+
|-------|-------------|
|
|
721
|
+
| `.lazer-slider` | Optional wrapper container |
|
|
722
|
+
| `.lazer-feed` | Scrollable container (horizontal) |
|
|
723
|
+
| `.lazer-feed.lazer-vertical` | Vertical slider variant |
|
|
724
|
+
| `.lazer-feed.lazer-draggable` | Adds grab cursor for drag-enabled sliders |
|
|
725
|
+
| `.lazer-slide` | Individual slide |
|
|
726
|
+
| `.lazer-bullets` | Bullets container |
|
|
727
|
+
| `.lazer-bullet` | Individual bullet/dot |
|
|
728
|
+
| `.lazer-thumbs` | Thumbnails container |
|
|
729
|
+
| `.lazer-thumb` | Individual thumbnail |
|
|
730
|
+
| `.lazer-track` | Scrollbar track |
|
|
731
|
+
| `.lazer-scrollbar` | Scrollbar thumb |
|
|
732
|
+
| `.lazer-nav` | Navigation button base |
|
|
733
|
+
| `.lazer-prev` | Previous button |
|
|
734
|
+
| `.lazer-next` | Next button |
|
|
735
|
+
|
|
736
|
+
### CSS Custom Properties
|
|
737
|
+
|
|
738
|
+
Customize the look by overriding CSS variables:
|
|
702
739
|
|
|
703
740
|
```css
|
|
704
741
|
:root {
|
|
705
|
-
/* Bullets
|
|
742
|
+
/* Bullets */
|
|
706
743
|
--lazer-bullet-size: 12px;
|
|
707
744
|
--lazer-bullet-gap: 8px;
|
|
708
745
|
--lazer-bullet-color: #cbd5e1;
|
|
@@ -725,7 +762,7 @@ When using the optional CSS file (`import 'lazer-slider/css'`), you can customiz
|
|
|
725
762
|
--lazer-thumb-color: #1e293b;
|
|
726
763
|
--lazer-track-radius: 2px;
|
|
727
764
|
|
|
728
|
-
/* Navigation
|
|
765
|
+
/* Navigation */
|
|
729
766
|
--lazer-nav-size: 40px;
|
|
730
767
|
--lazer-nav-offset: 12px;
|
|
731
768
|
--lazer-nav-bg: rgba(255, 255, 255, 0.9);
|
|
@@ -739,85 +776,27 @@ When using the optional CSS file (`import 'lazer-slider/css'`), you can customiz
|
|
|
739
776
|
}
|
|
740
777
|
```
|
|
741
778
|
|
|
742
|
-
### CSS
|
|
743
|
-
|
|
744
|
-
The slider automatically adds these classes for CSS targeting:
|
|
779
|
+
### Custom Styles (No CSS Import)
|
|
745
780
|
|
|
746
|
-
|
|
747
|
-
|-------|------------|-------------|
|
|
748
|
-
| `.lazer-feed` | Feed element | Scrollable container |
|
|
749
|
-
| `.lazer-slide` | Slide elements | Individual slides |
|
|
750
|
-
| `.lazer-vertical` | Feed element | When using vertical direction |
|
|
751
|
-
| `.lazer-marquee` | Feed element | When marquee mode is enabled |
|
|
752
|
-
|
|
753
|
-
You can use these classes in your CSS:
|
|
781
|
+
If you prefer not to use the included styles, here's the minimal CSS required:
|
|
754
782
|
|
|
755
783
|
```css
|
|
756
|
-
.
|
|
757
|
-
|
|
784
|
+
.slider-feed {
|
|
785
|
+
display: flex;
|
|
786
|
+
overflow-x: auto;
|
|
787
|
+
-webkit-overflow-scrolling: touch;
|
|
788
|
+
scrollbar-width: none;
|
|
758
789
|
}
|
|
759
790
|
|
|
760
|
-
.
|
|
761
|
-
|
|
791
|
+
.slider-feed::-webkit-scrollbar {
|
|
792
|
+
display: none;
|
|
762
793
|
}
|
|
763
794
|
|
|
764
|
-
.
|
|
765
|
-
|
|
795
|
+
.slide {
|
|
796
|
+
flex-shrink: 0;
|
|
766
797
|
}
|
|
767
798
|
```
|
|
768
799
|
|
|
769
|
-
### Available Classes
|
|
770
|
-
|
|
771
|
-
| Class | Element | Description |
|
|
772
|
-
|-------|---------|-------------|
|
|
773
|
-
| `.lazer-slider` | Container | Optional wrapper |
|
|
774
|
-
| `.lazer-feed` | Feed | Scrollable container |
|
|
775
|
-
| `.lazer-slide` | Slide | Individual slides |
|
|
776
|
-
| `.lazer-bullets` | Bullets container | Dot navigation wrapper |
|
|
777
|
-
| `.lazer-bullet` | Bullet | Individual dot |
|
|
778
|
-
| `.lazer-thumbs` | Thumbs container | Thumbnail navigation wrapper |
|
|
779
|
-
| `.lazer-thumb` | Thumb | Individual thumbnail |
|
|
780
|
-
| `.lazer-track` | Scrollbar track | Scrollbar background |
|
|
781
|
-
| `.lazer-scrollbar` | Scrollbar thumb | Draggable scrollbar |
|
|
782
|
-
| `.lazer-nav` | Nav button | Navigation button base |
|
|
783
|
-
| `.lazer-prev` | Prev button | Previous button |
|
|
784
|
-
| `.lazer-next` | Next button | Next button |
|
|
785
|
-
|
|
786
|
-
## Accessibility
|
|
787
|
-
|
|
788
|
-
The slider automatically adds ARIA attributes for accessibility:
|
|
789
|
-
|
|
790
|
-
- `role="region"` and `aria-roledescription="carousel"` on the feed
|
|
791
|
-
- `role="group"` and `aria-label="Slide X of Y"` on each slide
|
|
792
|
-
- `aria-controls` linking buttons to the feed
|
|
793
|
-
- `aria-hidden` and `tabindex` management for visibility
|
|
794
|
-
- Keyboard navigation with arrow keys when feed is focused
|
|
795
|
-
|
|
796
|
-
## TypeScript
|
|
797
|
-
|
|
798
|
-
Full TypeScript support with exported types:
|
|
799
|
-
|
|
800
|
-
```typescript
|
|
801
|
-
import {
|
|
802
|
-
createSlider,
|
|
803
|
-
generateBullets,
|
|
804
|
-
generateThumbs,
|
|
805
|
-
injectStyles,
|
|
806
|
-
removeStyles,
|
|
807
|
-
type SliderSettings,
|
|
808
|
-
type Slider,
|
|
809
|
-
type EasingFunction,
|
|
810
|
-
type ScrollParams,
|
|
811
|
-
type ScrollStartParams,
|
|
812
|
-
type SliderDirection,
|
|
813
|
-
type MarqueeDirection
|
|
814
|
-
} from 'lazer-slider'
|
|
815
|
-
```
|
|
816
|
-
|
|
817
|
-
> **Note:** `generateBullets` and `generateThumbs` are also exported if you need to manually generate navigation elements outside of the slider initialization.
|
|
818
|
-
|
|
819
|
-
> **Note:** `injectStyles()` is called automatically by `createSlider()`. Use it manually only if you need to inject styles before creating a slider (e.g., for SSR hydration). `removeStyles()` removes the injected styles from the document.
|
|
820
|
-
|
|
821
800
|
## Browser Support
|
|
822
801
|
|
|
823
802
|
- Chrome (latest)
|