scrimba
Note at 2:36
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:36
AboutCommentsNotes
Note at 2:36
Expand for more info
index.js
run
preview
console
// javascript
const btnR = document.querySelector('.next');
const btnL = document.querySelector('.previous');
const cards = document.querySelectorAll('.card');

//gallery translate -220 *
const gallery = document.querySelector('.gallery');

let g = 0;

btnR.addEventListener('click', () => {
btnL.style.opacity = 0.3;
btnR.style.opacity = 1;
gallery.style.transform = `translateX(-${(g += 220)}px)`;

if (g > 880) {
gallery.style.transform = `translateX(-${(g = 0)}px)`;
}
});

btnL.addEventListener('click', () => {
btnL.style.opacity = 1;
btnR.style.opacity = 0.3;
gallery.style.transform = `translateX(-${(g -= 220)}px)`;
if (g < 0) {
gallery.style.transform = `translateX(-${(g = 880)}px)`;
}
});
Console
/index.html
LIVE