| 13 | downButton.addEventListener('click', () => changeSlide('down')) |
| 14 | |
| 15 | const changeSlide = (direction) => { |
| 16 | const sliderHeight = sliderContainer.clientHeight |
| 17 | if(direction === 'up') { |
| 18 | activeSlideIndex++ |
| 19 | if(activeSlideIndex > slidesLength - 1) { |
| 20 | activeSlideIndex = 0 |
| 21 | } |
| 22 | } else if(direction === 'down') { |
| 23 | activeSlideIndex-- |
| 24 | if(activeSlideIndex < 0) { |
| 25 | activeSlideIndex = slidesLength - 1 |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | slideRight.style.transform = `translateY(-${activeSlideIndex * sliderHeight}px)` |
| 30 | slideLeft.style.transform = `translateY(${activeSlideIndex * sliderHeight}px)` |
| 31 | } |