Skip to content

Commit

Permalink
comment out if-else logic and replaced slider logic with curIdx = (id…
Browse files Browse the repository at this point in the history
…x + totSl) % totSli
  • Loading branch information
TBS96 committed Jun 1, 2024
1 parent b631474 commit ad43c5c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ const showSlide = (index) => {
const slides = document.getElementById('slides');
const totalSlides = slides.children.length;

if(index >= totalSlides)
{
currentIndex = 0;
}
else if(index < 0)
{
currentIndex = totalSlides - 1;
}
else
{
currentIndex = index;
}
// if(index >= totalSlides)
// {
// currentIndex = 0;
// }
// else if(index < 0)
// {
// currentIndex = totalSlides - 1;
// }
// else
// {
// currentIndex = index;
// }

currentIndex = (index + totalSlides) % totalSlides;

slides.style.transform = `translateX(${-currentIndex * 100}%)`;
};
Expand Down

0 comments on commit ad43c5c

Please sign in to comment.