const next = document.querySelector(".next")
const gallery = document.querySelector(".gallery")
const cards = Array.from(document.querySelectorAll(".card"))
const matrixR = /matrix\(\s*\d+,\s*\d+,\s*\d+,\s*(\-*\d+),\s*\d+,\s*\d+\)/
gallery.style.transform = window.getComputedStyle(gallery).transform
next.addEventListener('click', e => {
let current = null
cards.forEach((c, i) => {
if(c.classList.contains('current')){
current = i
}
})
if(current < cards.length - 1){
cards[current].classList.remove('current')
cards[current + 1].classList.add('current')
gallery.style.transform = `matrix(1, 0, 0, 1, ${-220 * (current + 1)}, 0)`
previous.style.opacity = 1
if(current + 1 === cards.length - 1){
next.style.opacity = 0.3
}
}
})
previous.addEventListener('click', e => {
let current = null
cards.forEach((c, i) => {
if(c.classList.contains('current')){
current = i
}
})
if(current > 0){
cards[current].classList.remove('current')
cards[current - 1].classList.add('current')
gallery.style.transform = `matrix(1, 0, 0, 1, ${-220 * (current - 1)}, 0)`
next.style.opacity = 1
if(current - 1 === 0){
previous.style.opacity = 0.3
}
}
})
// javascript
const previous = document.querySelector(".previous")