let position = 0;
const slidesToShow = 3;
const slidesToScroll = 1;
const container = document.querySelector(".review__row");
const track = document.querySelector(".review__track");
const items = document.querySelectorAll(".review__item");
const btnPrev = document.querySelector(".prev");
const btnNext = document.querySelector(".next");
const itemsCount = items.length;
const itemWidth = container.clientWidth / slidesToShow;
const movePosition = slidesToScroll * itemWidth;
items.forEach((item) => {
item.style.minWidth = `${itemWidth}px`;
});
btnPrev.addEventListener("click", () => {
position += movePosition;
setPosition();
checkBtns();
});
btnNext.addEventListener("click", () => {
position -= movePosition;
setPosition();
checkBtns();
});
const setPosition = () => {
track.style.transform = `translateX(${position}px)`;
};
const checkBtns = () => {
btnPrev.disabled = position == 0;
// btnNext.disabled = position <= -(itemsCount - slidesToShow) * itemWidth;
};
checkBtns();