-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
78 lines (70 loc) · 1.62 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// dropdown
//
console.log('carousel')
import { Carousel } from 'flowbite'
const items = [
{
position: 0,
el: document.getElementById('carousel-item-1'),
},
{
position: 1,
el: document.getElementById('carousel-item-2'),
},
{
position: 2,
el: document.getElementById('carousel-item-3'),
},
{
position: 3,
el: document.getElementById('carousel-item-4'),
},
]
const options = {
defaultPosition: 1,
interval: 3000,
indicators: {
activeClasses: 'bg-white dark:bg-gray-800',
inactiveClasses:
'bg-white/50 dark:bg-gray-800/50 hover:bg-white dark:hover:bg-gray-800',
items: [
{
position: 0,
el: document.getElementById('carousel-indicator-1'),
},
{
position: 1,
el: document.getElementById('carousel-indicator-2'),
},
{
position: 2,
el: document.getElementById('carousel-indicator-3'),
},
{
position: 3,
el: document.getElementById('carousel-indicator-4'),
},
],
},
// callback functions
onNext: () => {
console.log('next slider item is shown')
},
onPrev: () => {
console.log('previous slider item is shown')
},
onChange: () => {
console.log('new slider item has been shown')
},
}
const carousel = new Carousel(items, options)
// goes to the next (right) slide
carousel.next()
// goes to the previous (left) slide
carousel.prev()
// jumps to the 3rd position (position starts from 0)
carousel.slideTo(2)
// starts or resumes the carousel cycling (automated sliding)
carousel.cycle()
// pauses the cycling (automated sliding)
carousel.pause()