lazer-slider 1.1.2 → 1.1.3
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 +325 -73
- package/dist/index.cjs +326 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -6
- package/dist/index.d.ts +61 -6
- package/dist/index.js +322 -108
- package/dist/index.js.map +1 -1
- package/dist/lazer-slider.css +263 -0
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -7,10 +7,12 @@ A lightweight, accessible slider with smooth scroll-to-snap animations, drag-to-
|
|
|
7
7
|
- **Smooth Animations** - Buttery smooth scroll animations using `requestAnimationFrame` with customizable easing
|
|
8
8
|
- **Drag to Scroll** - Mouse and touch drag support with momentum physics
|
|
9
9
|
- **Responsive** - Separate settings for mobile and desktop (slidesPerView, slidesPerScroll)
|
|
10
|
+
- **Vertical & Horizontal** - Support for both horizontal and vertical slider directions
|
|
10
11
|
- **Loop Mode** - Infinite loop navigation
|
|
11
12
|
- **Autoplay** - Automatic slide advancement with pause on hover
|
|
12
13
|
- **Marquee Mode** - Continuous smooth scrolling with seamless infinite loop
|
|
13
14
|
- **Automatic Bullets** - Auto-generate navigation bullets from slides
|
|
15
|
+
- **Thumbs Gallery** - Auto-generate thumbnail navigation from slide images
|
|
14
16
|
- **Accessible** - Full ARIA support, keyboard navigation (arrow keys)
|
|
15
17
|
- **Lightweight** - Zero dependencies, ~20KB unminified
|
|
16
18
|
- **TypeScript** - Full type definitions included
|
|
@@ -26,58 +28,61 @@ npm install lazer-slider
|
|
|
26
28
|
### HTML Structure
|
|
27
29
|
|
|
28
30
|
```html
|
|
29
|
-
<div class="slider">
|
|
30
|
-
<button class="
|
|
31
|
-
<button class="
|
|
32
|
-
|
|
33
|
-
<div class="
|
|
34
|
-
<div class="slide">Slide 1</div>
|
|
35
|
-
<div class="slide">Slide 2</div>
|
|
36
|
-
<div class="slide">Slide 3</div>
|
|
31
|
+
<div class="lazer-slider">
|
|
32
|
+
<button class="lazer-prev">Previous</button>
|
|
33
|
+
<button class="lazer-next">Next</button>
|
|
34
|
+
|
|
35
|
+
<div class="lazer-feed">
|
|
36
|
+
<div class="lazer-slide">Slide 1</div>
|
|
37
|
+
<div class="lazer-slide">Slide 2</div>
|
|
38
|
+
<div class="lazer-slide">Slide 3</div>
|
|
37
39
|
</div>
|
|
38
40
|
|
|
39
|
-
<div class="
|
|
41
|
+
<div class="lazer-bullets"></div>
|
|
40
42
|
</div>
|
|
41
43
|
```
|
|
42
44
|
|
|
43
|
-
### CSS
|
|
45
|
+
### CSS
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
.slider-feed {
|
|
47
|
-
display: flex;
|
|
48
|
-
overflow-x: auto;
|
|
49
|
-
-webkit-overflow-scrolling: touch;
|
|
50
|
-
scrollbar-width: none; /* Firefox */
|
|
51
|
-
}
|
|
47
|
+
**Zero-Config (Recommended):** Critical CSS is auto-injected when you call `createSlider()`. The slider automatically adds `.lazer-feed` and `.lazer-slide` classes to your elements!
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
```html
|
|
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>
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
60
|
+
<div class="lazer-bullets"></div>
|
|
61
|
+
</div>
|
|
62
|
+
```
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
display: flex;
|
|
64
|
-
gap: 8px;
|
|
65
|
-
justify-content: center;
|
|
66
|
-
margin-top: 16px;
|
|
67
|
-
}
|
|
64
|
+
**Optional Styles:** For bullets, thumbs, scrollbar, and navigation styling, import the optional CSS file:
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
```typescript
|
|
67
|
+
// Import optional styles for bullets, thumbs, scrollbar, etc.
|
|
68
|
+
import 'lazer-slider/css'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or in HTML:
|
|
72
|
+
```html
|
|
73
|
+
<link rel="stylesheet" href="node_modules/lazer-slider/dist/lazer-slider.css">
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Custom CSS:** You can override the auto-injected styles easily:
|
|
77
|
+
|
|
78
|
+
```css
|
|
79
|
+
/* Override the auto-injected styles */
|
|
80
|
+
.lazer-feed {
|
|
81
|
+
gap: 20px;
|
|
77
82
|
}
|
|
78
83
|
|
|
79
|
-
.
|
|
80
|
-
|
|
84
|
+
.lazer-slide {
|
|
85
|
+
scroll-snap-align: center; /* Change snap alignment */
|
|
81
86
|
}
|
|
82
87
|
```
|
|
83
88
|
|
|
@@ -87,11 +92,11 @@ npm install lazer-slider
|
|
|
87
92
|
import { createSlider } from 'lazer-slider'
|
|
88
93
|
|
|
89
94
|
const slider = createSlider({
|
|
90
|
-
feed: document.querySelector('.
|
|
91
|
-
slides: [...document.querySelectorAll('.slide')],
|
|
92
|
-
prevSlideButton: document.querySelector('.
|
|
93
|
-
nextSlideButton: document.querySelector('.
|
|
94
|
-
bulletsContainer: document.querySelector('.
|
|
95
|
+
feed: document.querySelector('.lazer-feed'),
|
|
96
|
+
slides: [...document.querySelectorAll('.lazer-slide')],
|
|
97
|
+
prevSlideButton: document.querySelector('.lazer-prev'),
|
|
98
|
+
nextSlideButton: document.querySelector('.lazer-next'),
|
|
99
|
+
bulletsContainer: document.querySelector('.lazer-bullets'),
|
|
95
100
|
enableDragToScroll: true
|
|
96
101
|
})
|
|
97
102
|
|
|
@@ -116,10 +121,15 @@ slider.unload()
|
|
|
116
121
|
| `nextSlideButton` | `HTMLElement \| null` | `null` | Next slide button |
|
|
117
122
|
| `thumbs` | `HTMLElement[]` | `undefined` | Thumbnail/dot elements for direct navigation (manual) |
|
|
118
123
|
| `bulletsContainer` | `HTMLElement \| null` | `null` | Container element for auto-generated bullets |
|
|
119
|
-
| `bulletsClass` | `string` | `'
|
|
124
|
+
| `bulletsClass` | `string` | `'lazer-bullet'` | CSS class for bullet elements |
|
|
120
125
|
| `bulletsActiveClass` | `string` | `'active'` | CSS class for active bullet element |
|
|
126
|
+
| `thumbsContainer` | `HTMLElement \| null` | `null` | Container element for auto-generated thumbnails |
|
|
127
|
+
| `thumbsClass` | `string` | `'lazer-thumb'` | CSS class for thumbnail elements |
|
|
128
|
+
| `thumbsActiveClass` | `string` | `'active'` | CSS class for active thumbnail element |
|
|
129
|
+
| `thumbImageSelector` | `string` | `'img'` | CSS selector to find image inside each slide |
|
|
130
|
+
| `thumbSize` | `{ width: number; height: number }` | `undefined` | Fixed dimensions for thumbnail images |
|
|
121
131
|
|
|
122
|
-
> **Note:** When `bulletsContainer` is provided,
|
|
132
|
+
> **Note:** When `bulletsContainer` or `thumbsContainer` is provided, navigation elements are automatically generated. If `thumbs` is also provided, both containers are ignored. Elements are only generated for visible slides.
|
|
123
133
|
|
|
124
134
|
### Responsive
|
|
125
135
|
|
|
@@ -139,6 +149,7 @@ slider.unload()
|
|
|
139
149
|
|
|
140
150
|
| Option | Type | Default | Description |
|
|
141
151
|
|--------|------|---------|-------------|
|
|
152
|
+
| `direction` | `'horizontal' \| 'vertical'` | `'horizontal'` | Slider orientation |
|
|
142
153
|
| `enableDragToScroll` | `boolean` | `false` | Enable mouse/touch drag to scroll |
|
|
143
154
|
| `loop` | `boolean` | `false` | Enable infinite loop navigation |
|
|
144
155
|
| `autoplay` | `boolean` | `false` | Enable automatic slide advancement |
|
|
@@ -244,7 +255,7 @@ const slider = createSlider({
|
|
|
244
255
|
|
|
245
256
|
```typescript
|
|
246
257
|
const slider = createSlider({
|
|
247
|
-
feed: document.querySelector('.
|
|
258
|
+
feed: document.querySelector('.lazer-feed'),
|
|
248
259
|
slides: [...document.querySelectorAll('.slide')]
|
|
249
260
|
})
|
|
250
261
|
```
|
|
@@ -253,10 +264,10 @@ const slider = createSlider({
|
|
|
253
264
|
|
|
254
265
|
```typescript
|
|
255
266
|
const slider = createSlider({
|
|
256
|
-
feed: document.querySelector('.
|
|
267
|
+
feed: document.querySelector('.lazer-feed'),
|
|
257
268
|
slides: [...document.querySelectorAll('.slide')],
|
|
258
269
|
prevSlideButton: document.querySelector('.prev'),
|
|
259
|
-
nextSlideButton: document.querySelector('.next')
|
|
270
|
+
nextSlideButton: document.querySelector('.lazer-next')
|
|
260
271
|
})
|
|
261
272
|
```
|
|
262
273
|
|
|
@@ -264,7 +275,7 @@ const slider = createSlider({
|
|
|
264
275
|
|
|
265
276
|
```typescript
|
|
266
277
|
const slider = createSlider({
|
|
267
|
-
feed: document.querySelector('.
|
|
278
|
+
feed: document.querySelector('.lazer-feed'),
|
|
268
279
|
slides: [...document.querySelectorAll('.slide')],
|
|
269
280
|
mobileSlidesPerView: 1,
|
|
270
281
|
desktopSlidesPerView: 3,
|
|
@@ -278,7 +289,7 @@ const slider = createSlider({
|
|
|
278
289
|
|
|
279
290
|
```typescript
|
|
280
291
|
const slider = createSlider({
|
|
281
|
-
feed: document.querySelector('.
|
|
292
|
+
feed: document.querySelector('.lazer-feed'),
|
|
282
293
|
slides: [...document.querySelectorAll('.slide')],
|
|
283
294
|
loop: true,
|
|
284
295
|
autoplay: true,
|
|
@@ -317,6 +328,68 @@ marquee.play() // Resume marquee
|
|
|
317
328
|
- **Marquee**: For continuous ticker-style scrolling (news tickers, logo carousels, announcements)
|
|
318
329
|
- **Autoplay**: For slide-by-slide carousel navigation (image galleries, product showcases)
|
|
319
330
|
|
|
331
|
+
### Vertical Slider
|
|
332
|
+
|
|
333
|
+
Create a vertical scrolling slider for content that flows top-to-bottom.
|
|
334
|
+
|
|
335
|
+
```html
|
|
336
|
+
<div class="vertical-slider">
|
|
337
|
+
<button class="lazer-prev">↑</button>
|
|
338
|
+
<button class="lazer-next">↓</button>
|
|
339
|
+
|
|
340
|
+
<div class="slider-feed">
|
|
341
|
+
<div class="lazer-slide">Slide 1</div>
|
|
342
|
+
<div class="lazer-slide">Slide 2</div>
|
|
343
|
+
<div class="lazer-slide">Slide 3</div>
|
|
344
|
+
</div>
|
|
345
|
+
</div>
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
```css
|
|
349
|
+
.lazer-feed {
|
|
350
|
+
display: flex;
|
|
351
|
+
flex-direction: column;
|
|
352
|
+
overflow-y: auto;
|
|
353
|
+
height: 400px; /* Set a fixed height for vertical scrolling */
|
|
354
|
+
scrollbar-width: none;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.lazer-feed::-webkit-scrollbar {
|
|
358
|
+
display: none;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.slide {
|
|
362
|
+
scroll-snap-align: start;
|
|
363
|
+
flex-shrink: 0;
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
const verticalSlider = createSlider({
|
|
369
|
+
feed: document.querySelector('.lazer-feed'),
|
|
370
|
+
slides: [...document.querySelectorAll('.slide')],
|
|
371
|
+
prevSlideButton: document.querySelector('.lazer-prev'),
|
|
372
|
+
nextSlideButton: document.querySelector('.lazer-next'),
|
|
373
|
+
direction: 'vertical',
|
|
374
|
+
mobileSlidesPerView: 1,
|
|
375
|
+
desktopSlidesPerView: 1,
|
|
376
|
+
enableDragToScroll: true
|
|
377
|
+
})
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Key Features:**
|
|
381
|
+
- Full vertical scrolling support with smooth animations
|
|
382
|
+
- Keyboard navigation with ArrowUp/ArrowDown keys
|
|
383
|
+
- Drag-to-scroll works in vertical direction
|
|
384
|
+
- Loop mode and autoplay work vertically
|
|
385
|
+
- Custom scrollbar can be styled vertically
|
|
386
|
+
|
|
387
|
+
**When to use Vertical Slider:**
|
|
388
|
+
- Full-page vertical carousels
|
|
389
|
+
- Testimonial/review sliders with tall content
|
|
390
|
+
- Timeline or step-by-step displays
|
|
391
|
+
- Mobile-first vertical content experiences
|
|
392
|
+
|
|
320
393
|
### Bullets/Dots Navigation
|
|
321
394
|
|
|
322
395
|
You can add clickable dots that navigate to specific slides using either manual or automatic generation.
|
|
@@ -328,9 +401,9 @@ The slider can automatically generate bullets from your slides. Just provide a c
|
|
|
328
401
|
```html
|
|
329
402
|
<div class="slider">
|
|
330
403
|
<div class="slider-feed">
|
|
331
|
-
<div class="slide">Slide 1</div>
|
|
332
|
-
<div class="slide">Slide 2</div>
|
|
333
|
-
<div class="slide">Slide 3</div>
|
|
404
|
+
<div class="lazer-slide">Slide 1</div>
|
|
405
|
+
<div class="lazer-slide">Slide 2</div>
|
|
406
|
+
<div class="lazer-slide">Slide 3</div>
|
|
334
407
|
</div>
|
|
335
408
|
|
|
336
409
|
<div class="slider-bullets"></div>
|
|
@@ -338,14 +411,14 @@ The slider can automatically generate bullets from your slides. Just provide a c
|
|
|
338
411
|
```
|
|
339
412
|
|
|
340
413
|
```css
|
|
341
|
-
.
|
|
414
|
+
.lazer-bullets {
|
|
342
415
|
display: flex;
|
|
343
416
|
gap: 8px;
|
|
344
417
|
justify-content: center;
|
|
345
418
|
margin-top: 16px;
|
|
346
419
|
}
|
|
347
420
|
|
|
348
|
-
.
|
|
421
|
+
.lazer-bullet {
|
|
349
422
|
width: 12px;
|
|
350
423
|
height: 12px;
|
|
351
424
|
border-radius: 50%;
|
|
@@ -355,16 +428,16 @@ The slider can automatically generate bullets from your slides. Just provide a c
|
|
|
355
428
|
transition: background 0.3s;
|
|
356
429
|
}
|
|
357
430
|
|
|
358
|
-
.
|
|
431
|
+
.lazer-bullet.active {
|
|
359
432
|
background: #333;
|
|
360
433
|
}
|
|
361
434
|
```
|
|
362
435
|
|
|
363
436
|
```typescript
|
|
364
437
|
const slider = createSlider({
|
|
365
|
-
feed: document.querySelector('.
|
|
438
|
+
feed: document.querySelector('.lazer-feed'),
|
|
366
439
|
slides: [...document.querySelectorAll('.slide')],
|
|
367
|
-
bulletsContainer: document.querySelector('.
|
|
440
|
+
bulletsContainer: document.querySelector('.lazer-bullets'),
|
|
368
441
|
bulletsClass: 'slider-bullet', // Optional: default is 'slider-bullet'
|
|
369
442
|
bulletsActiveClass: 'active' // Optional: default is 'active'
|
|
370
443
|
})
|
|
@@ -383,9 +456,9 @@ Alternatively, you can create bullets manually and pass them via the `thumbs` op
|
|
|
383
456
|
```html
|
|
384
457
|
<div class="slider">
|
|
385
458
|
<div class="slider-feed">
|
|
386
|
-
<div class="slide">Slide 1</div>
|
|
387
|
-
<div class="slide">Slide 2</div>
|
|
388
|
-
<div class="slide">Slide 3</div>
|
|
459
|
+
<div class="lazer-slide">Slide 1</div>
|
|
460
|
+
<div class="lazer-slide">Slide 2</div>
|
|
461
|
+
<div class="lazer-slide">Slide 3</div>
|
|
389
462
|
</div>
|
|
390
463
|
|
|
391
464
|
<div class="slider-dots">
|
|
@@ -421,7 +494,7 @@ Alternatively, you can create bullets manually and pass them via the `thumbs` op
|
|
|
421
494
|
|
|
422
495
|
```typescript
|
|
423
496
|
const slider = createSlider({
|
|
424
|
-
feed: document.querySelector('.
|
|
497
|
+
feed: document.querySelector('.lazer-feed'),
|
|
425
498
|
slides: [...document.querySelectorAll('.slide')],
|
|
426
499
|
thumbs: [...document.querySelectorAll('.dot')]
|
|
427
500
|
})
|
|
@@ -429,6 +502,88 @@ const slider = createSlider({
|
|
|
429
502
|
|
|
430
503
|
> **Note:** If both `bulletsContainer` and `thumbs` are provided, `bulletsContainer` is ignored and manual `thumbs` are used instead.
|
|
431
504
|
|
|
505
|
+
### Thumbs Gallery
|
|
506
|
+
|
|
507
|
+
Auto-generate clickable thumbnail images from your slides. Perfect for product galleries, image carousels, and any slider where visual previews enhance navigation.
|
|
508
|
+
|
|
509
|
+
```html
|
|
510
|
+
<div class="slider">
|
|
511
|
+
<div class="slider-feed">
|
|
512
|
+
<div class="lazer-slide">
|
|
513
|
+
<img src="/images/product-1.jpg" alt="Product 1">
|
|
514
|
+
<h3>Product Title 1</h3>
|
|
515
|
+
</div>
|
|
516
|
+
<div class="lazer-slide">
|
|
517
|
+
<img src="/images/product-2.jpg" alt="Product 2">
|
|
518
|
+
<h3>Product Title 2</h3>
|
|
519
|
+
</div>
|
|
520
|
+
<div class="lazer-slide">
|
|
521
|
+
<img src="/images/product-3.jpg" alt="Product 3">
|
|
522
|
+
<h3>Product Title 3</h3>
|
|
523
|
+
</div>
|
|
524
|
+
</div>
|
|
525
|
+
|
|
526
|
+
<!-- Empty container - thumbnails are auto-generated -->
|
|
527
|
+
<div class="thumbs-gallery"></div>
|
|
528
|
+
</div>
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
```css
|
|
532
|
+
.thumbs-gallery {
|
|
533
|
+
display: flex;
|
|
534
|
+
gap: 8px;
|
|
535
|
+
margin-top: 16px;
|
|
536
|
+
justify-content: center;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.lazer-thumb {
|
|
540
|
+
padding: 0;
|
|
541
|
+
border: 2px solid transparent;
|
|
542
|
+
background: none;
|
|
543
|
+
cursor: pointer;
|
|
544
|
+
opacity: 0.6;
|
|
545
|
+
transition: opacity 0.2s, border-color 0.2s;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.lazer-thumb:hover {
|
|
549
|
+
opacity: 0.8;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.lazer-thumb.active {
|
|
553
|
+
opacity: 1;
|
|
554
|
+
border-color: #007bff;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.lazer-thumb img {
|
|
558
|
+
display: block;
|
|
559
|
+
border-radius: 4px;
|
|
560
|
+
}
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
```typescript
|
|
564
|
+
const slider = createSlider({
|
|
565
|
+
feed: document.querySelector('.lazer-feed'),
|
|
566
|
+
slides: [...document.querySelectorAll('.slide')],
|
|
567
|
+
thumbsContainer: document.querySelector('.thumbs-gallery'),
|
|
568
|
+
thumbsClass: 'slider-thumb', // Optional: default is 'slider-thumb'
|
|
569
|
+
thumbsActiveClass: 'active', // Optional: default is 'active'
|
|
570
|
+
thumbImageSelector: 'img', // Optional: CSS selector for slide images
|
|
571
|
+
thumbSize: { width: 80, height: 60 } // Optional: fixed thumbnail dimensions
|
|
572
|
+
})
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
**Features:**
|
|
576
|
+
- Automatically extracts images from each slide using `thumbImageSelector`
|
|
577
|
+
- Creates clickable thumbnail buttons with proper accessibility attributes
|
|
578
|
+
- Full ARIA support (`role="tablist"`, `aria-selected`, etc.)
|
|
579
|
+
- Active state automatically managed on scroll and click
|
|
580
|
+
- Only generates thumbnails for visible slides
|
|
581
|
+
- Optional fixed dimensions with `thumbSize` for consistent layouts
|
|
582
|
+
|
|
583
|
+
**When to use Thumbs Gallery vs Bullets:**
|
|
584
|
+
- **Thumbs Gallery**: For image-heavy sliders where visual previews help navigation (product galleries, portfolios)
|
|
585
|
+
- **Bullets**: For simpler navigation where slide content preview isn't needed (text carousels, testimonials)
|
|
586
|
+
|
|
432
587
|
### Custom Scrollbar
|
|
433
588
|
|
|
434
589
|
Create a draggable scrollbar that syncs with the slider position.
|
|
@@ -436,9 +591,9 @@ Create a draggable scrollbar that syncs with the slider position.
|
|
|
436
591
|
```html
|
|
437
592
|
<div class="slider">
|
|
438
593
|
<div class="slider-feed">
|
|
439
|
-
<div class="slide">Slide 1</div>
|
|
440
|
-
<div class="slide">Slide 2</div>
|
|
441
|
-
<div class="slide">Slide 3</div>
|
|
594
|
+
<div class="lazer-slide">Slide 1</div>
|
|
595
|
+
<div class="lazer-slide">Slide 2</div>
|
|
596
|
+
<div class="lazer-slide">Slide 3</div>
|
|
442
597
|
</div>
|
|
443
598
|
|
|
444
599
|
<div class="scrollbar-track">
|
|
@@ -467,7 +622,7 @@ Create a draggable scrollbar that syncs with the slider position.
|
|
|
467
622
|
|
|
468
623
|
```typescript
|
|
469
624
|
const slider = createSlider({
|
|
470
|
-
feed: document.querySelector('.
|
|
625
|
+
feed: document.querySelector('.lazer-feed'),
|
|
471
626
|
slides: [...document.querySelectorAll('.slide')],
|
|
472
627
|
scrollbarThumb: document.querySelector('.scrollbar-thumb'),
|
|
473
628
|
scrollbarTrack: document.querySelector('.scrollbar-track')
|
|
@@ -499,7 +654,7 @@ Use `slidesPerView: 'auto'` when slides have different natural widths defined in
|
|
|
499
654
|
|
|
500
655
|
```typescript
|
|
501
656
|
const slider = createSlider({
|
|
502
|
-
feed: document.querySelector('.
|
|
657
|
+
feed: document.querySelector('.lazer-feed'),
|
|
503
658
|
slides: [...document.querySelectorAll('.slide')],
|
|
504
659
|
mobileSlidesPerView: 'auto',
|
|
505
660
|
desktopSlidesPerView: 'auto',
|
|
@@ -512,11 +667,16 @@ const slider = createSlider({
|
|
|
512
667
|
|
|
513
668
|
```typescript
|
|
514
669
|
const slider = createSlider({
|
|
515
|
-
feed: document.querySelector('.
|
|
670
|
+
feed: document.querySelector('.lazer-feed'),
|
|
516
671
|
slides: [...document.querySelectorAll('.slide')],
|
|
517
672
|
prevSlideButton: document.querySelector('.prev'),
|
|
518
|
-
nextSlideButton: document.querySelector('.next'),
|
|
519
|
-
|
|
673
|
+
nextSlideButton: document.querySelector('.lazer-next'),
|
|
674
|
+
|
|
675
|
+
// Navigation (choose one: bullets OR thumbs)
|
|
676
|
+
bulletsContainer: document.querySelector('.lazer-bullets'), // Auto-generated bullets
|
|
677
|
+
// OR for image galleries:
|
|
678
|
+
// thumbsContainer: document.querySelector('.thumbs-gallery'),
|
|
679
|
+
// thumbSize: { width: 80, height: 60 },
|
|
520
680
|
|
|
521
681
|
// Responsive
|
|
522
682
|
mobileSlidesPerView: 1,
|
|
@@ -536,6 +696,93 @@ const slider = createSlider({
|
|
|
536
696
|
})
|
|
537
697
|
```
|
|
538
698
|
|
|
699
|
+
## CSS Customization
|
|
700
|
+
|
|
701
|
+
When using the optional CSS file (`import 'lazer-slider/css'`), you can customize styles using CSS custom properties:
|
|
702
|
+
|
|
703
|
+
```css
|
|
704
|
+
:root {
|
|
705
|
+
/* Bullets / Dots */
|
|
706
|
+
--lazer-bullet-size: 12px;
|
|
707
|
+
--lazer-bullet-gap: 8px;
|
|
708
|
+
--lazer-bullet-color: #cbd5e1;
|
|
709
|
+
--lazer-bullet-active-color: #1e293b;
|
|
710
|
+
--lazer-bullet-hover-scale: 1.2;
|
|
711
|
+
|
|
712
|
+
/* Thumbnails */
|
|
713
|
+
--lazer-thumb-gap: 8px;
|
|
714
|
+
--lazer-thumb-opacity: 0.6;
|
|
715
|
+
--lazer-thumb-hover-opacity: 0.8;
|
|
716
|
+
--lazer-thumb-active-opacity: 1;
|
|
717
|
+
--lazer-thumb-border-width: 2px;
|
|
718
|
+
--lazer-thumb-border-color: transparent;
|
|
719
|
+
--lazer-thumb-active-border-color: #3b82f6;
|
|
720
|
+
--lazer-thumb-border-radius: 4px;
|
|
721
|
+
|
|
722
|
+
/* Scrollbar */
|
|
723
|
+
--lazer-track-height: 4px;
|
|
724
|
+
--lazer-track-color: #e2e8f0;
|
|
725
|
+
--lazer-thumb-color: #1e293b;
|
|
726
|
+
--lazer-track-radius: 2px;
|
|
727
|
+
|
|
728
|
+
/* Navigation Buttons */
|
|
729
|
+
--lazer-nav-size: 40px;
|
|
730
|
+
--lazer-nav-offset: 12px;
|
|
731
|
+
--lazer-nav-bg: rgba(255, 255, 255, 0.9);
|
|
732
|
+
--lazer-nav-hover-bg: white;
|
|
733
|
+
--lazer-nav-radius: 50%;
|
|
734
|
+
--lazer-nav-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
735
|
+
|
|
736
|
+
/* Transitions */
|
|
737
|
+
--lazer-duration: 0.3s;
|
|
738
|
+
--lazer-easing: ease;
|
|
739
|
+
}
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
### CSS Classes
|
|
743
|
+
|
|
744
|
+
The slider automatically adds these classes for CSS targeting:
|
|
745
|
+
|
|
746
|
+
| Class | Applied To | Description |
|
|
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:
|
|
754
|
+
|
|
755
|
+
```css
|
|
756
|
+
.lazer-feed {
|
|
757
|
+
/* Style the feed container */
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.lazer-slide {
|
|
761
|
+
/* Style individual slides */
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
.lazer-feed.lazer-vertical {
|
|
765
|
+
/* Style vertical sliders */
|
|
766
|
+
}
|
|
767
|
+
```
|
|
768
|
+
|
|
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
|
+
|
|
539
786
|
## Accessibility
|
|
540
787
|
|
|
541
788
|
The slider automatically adds ARIA attributes for accessibility:
|
|
@@ -554,6 +801,9 @@ Full TypeScript support with exported types:
|
|
|
554
801
|
import {
|
|
555
802
|
createSlider,
|
|
556
803
|
generateBullets,
|
|
804
|
+
generateThumbs,
|
|
805
|
+
injectStyles,
|
|
806
|
+
removeStyles,
|
|
557
807
|
type SliderSettings,
|
|
558
808
|
type Slider,
|
|
559
809
|
type EasingFunction,
|
|
@@ -564,7 +814,9 @@ import {
|
|
|
564
814
|
} from 'lazer-slider'
|
|
565
815
|
```
|
|
566
816
|
|
|
567
|
-
> **Note:** `generateBullets`
|
|
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.
|
|
568
820
|
|
|
569
821
|
## Browser Support
|
|
570
822
|
|