scrimba
Note at 2:29
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 2:29
by
AboutCommentsNotes
Note at 2:29
by
Expand for more info
index.js
run
preview
console
// javascript

const cards = document.getElementsByClassName("card");
let current = 0;
let show = 0;
const length = (cards.length - 1);
document.querySelector(".next").addEventListener("click",() => {
cards[current].classList.remove("current");
if(current == length) {
show = 0;
current = 0;
} else {
current += 1;
show -= 220;
}
cards[current].classList.add("current");
document.querySelector(".gallery").style.transform = `translateX(${show}px)`;

})
document.querySelector(".previous").addEventListener("click",() => {
cards[current].classList.remove("current");
if(current == 0) {
show = -(220 * length);
current = length;
} else {
current -= 1;
show += 220;
}
cards[current].classList.add("current");
document.querySelector(".gallery").style.transform = `translateX(${show}px)`;

})

Console
/index.html
LIVE