script.js 482 B

123456789101112131415161718
  1. let offset = 0;
  2. const sliderLine = document.querySelector('.slider-line');
  3. document.querySelector('.slider-next').addEventListener('click', function(){
  4. offset = offset + 256;
  5. if (offset > 768) {
  6. offset = 0;
  7. }
  8. sliderLine.style.left = -offset + 'px';
  9. });
  10. document.querySelector('.slider-prev').addEventListener('click', function () {
  11. offset = offset - 256;
  12. if (offset < 0) {
  13. offset = 768;
  14. }
  15. sliderLine.style.left = -offset + 'px';
  16. });