scrimba
Note at 2:23
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:23
AboutCommentsNotes
Note at 2:23
Expand for more info
index.js
run
preview
console
const previousBtn = document.getElementById("previous")
const nextBtn = document.getElementById("next")
const gallery = document.getElementById("gallery")
const n = gallery.getElementsByClassName("card").length

let increse = -220
let decrese = 220
let x = 0

function handleNextBtnClick() {
if (x > increse * (n - 1)) {
previousBtn.style.opacity = "1"
x += increse
gallery.style.transform = `translateX(${x}px)`
}
}

function handlePreviousBtnClick() {
if (x != 0) {
x += decrese
gallery.style.transform = `translateX(${x}px)`
}
}

nextBtn.addEventListener("click", handleNextBtnClick)
previousBtn.addEventListener(
"click",
handlePreviousBtnClick
)
Console
/index.html
LIVE