scrimba
Note at 0:00
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 0:00
AboutCommentsNotes
Note at 0:00
Expand for more info
index.js
run
preview
console
const prev = document.querySelector('.previous')
const next = document.querySelector('.next')
const gallery = document.querySelector('.gallery')
let transform = 0

function updateArrows() {
if(transform === 0) {
next.style.opacity = 0.3
prev.style.opacity = 1
} else {
next.style.opacity = 1
}
if (transform === -880) {
prev.style.opacity = 0.3
next.style.opacity = 1
} else {
prev.style.opacity = 1
}
}

prev.addEventListener('click', () => {
if(transform > -880) {
transform -= 220
gallery.style.transform = `translateX(${transform}px)`
}
updateArrows()
})

next.addEventListener('click', () => {
if(transform < 0) {
transform += 220
gallery.style.transform = `translateX(${transform}px)`
}
updateArrows()
})
Console
/index.html
LIVE