-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkCarousel.js
39 lines (34 loc) · 1.08 KB
/
linkCarousel.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
const slider = new Slider('.link-carousel .gallery-slider', SliderType.Link, navMove);
const slideCount = slider.slides.length;
let autoIndex = 0;
//let autoSlideOn = true;
const autoInterval = 4000; //ms
autoSlide();
let auto = window.setInterval(autoSlide, autoInterval);
//let auto;
//window.setTimeout(()=>{auto = window.setInterval(autoSlide, autoInterval);}, 0);
window.addEventListener('pointerup', (e) =>
{
if(e.button != 0) return;
clickEnd(slider, e);
dragCount = 0;
});
setUpSliderListeners(slider);
const sliderContainer = document.querySelector('.carousel-container');
setUpSliderFocus(sliderContainer, slider);
sliderContainer.addEventListener('keydown', e => keyboardNavigation(e, slider));
setUpNavBulletListeners(slider, navMove);
function autoSlide()
{
moveInnerSlider(slider, autoIndex);
setActiveBullet(slider, autoIndex);
autoIndex = ++autoIndex % slideCount;
}
function navMove(i)
{
moveInnerSlider(slider, i);
setActiveBullet(slider, i);
focusedSlide = i;
window.clearInterval(auto);
//autoSlideOn = false;
}