home > slideshow : enable
All checks were successful
Deploy / Deploy to Production (push) Successful in 3s
All checks were successful
Deploy / Deploy to Production (push) Successful in 3s
This commit is contained in:
parent
dc0c48acc3
commit
13040a9df3
8 changed files with 163 additions and 48 deletions
18
assets/js/home-slideshow.js
Normal file
18
assets/js/home-slideshow.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const slideshow = document.getElementById('home-slideshow');
|
||||
|
||||
if (slideshow) {
|
||||
const items = [...slideshow.querySelectorAll('picture, video')];
|
||||
const prev = slideshow.querySelector('.prev');
|
||||
const next = slideshow.querySelector('.next');
|
||||
let current = 0;
|
||||
|
||||
function goTo(index) {
|
||||
items[current].classList.remove('active');
|
||||
current = (index + items.length) % items.length;
|
||||
items[current].classList.add('active');
|
||||
}
|
||||
|
||||
items[0]?.classList.add('active');
|
||||
prev?.addEventListener('click', () => goTo(current - 1));
|
||||
next?.addEventListener('click', () => goTo(current + 1));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue