You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
const loader = document.querySelector('.loader');
|
|
|
|
window.addEventListener('load', () => {
|
|
|
|
loader.classList.add('fondu-out');
|
|
|
|
})
|
|
|
|
const items = document.querySelectorAll('img');
|
|
const nbSlide = items.length;
|
|
const suivant = document.querySelector('.right');
|
|
const precedent = document.querySelector('.left');
|
|
let count = 0;
|
|
|
|
function slideSuivante(){
|
|
items[count].classList.remove('active');
|
|
|
|
if(count < nbSlide - 1){
|
|
count++;
|
|
} else {
|
|
count = 0;
|
|
}
|
|
|
|
items[count].classList.add('active')
|
|
console.log(count);
|
|
|
|
}
|
|
suivant.addEventListener('click', slideSuivante)
|
|
|
|
|
|
function slidePrecedente(){
|
|
items[count].classList.remove('active');
|
|
|
|
if(count > 0){
|
|
count--;
|
|
} else {
|
|
count = nbSlide - 1;
|
|
}
|
|
|
|
items[count].classList.add('active')
|
|
// console.log(count);
|
|
|
|
}
|
|
precedent.addEventListener('click', slidePrecedente)
|
|
|
|
function keyPress(e){
|
|
console.log(e);
|
|
|
|
if(e.keyCode === 37){
|
|
slidePrecedente();
|
|
} else if(e.keyCode === 39){
|
|
slideSuivante();
|
|
}
|
|
}
|
|
document.addEventListener('keydown', keyPress)
|