DEV Community

Discussion on: Image Slider with JavaScript

Collapse
 
paulobcss profile image
Paul O'Brien

Good work though I notice a slight bug if you click the same 'dot' twice and the screen goes blank. I think you need to check whether the same button has been clicked and do nothing.:)

Collapse
 
j471n profile image
Jatin Sharma

I don't face this problem, but I'll look into it, if I found any. Thanks for the feedback. 👍

Collapse
 
paulobcss profile image
Paul O'Brien • Edited

If it helps it happens to me in both Chrome and Firefox.

Screenshot attached.

Thread Thread
 
paulobcss profile image
Paul O'Brien

Just checked on PC and a Mac in Firefox and Chrome on both (and Safari and ios on mobile) and it still doesn't work properly. It's not really usable in its current state and I suggest you test again.

Just click the current dot nav again (or another dot twice) and you will see that the displayed image scales to zero leaving a blank screen - that is not a nice effect. You then have to click again to bring it back.

The problem is evident on all browsers.

Thread Thread
 
j471n profile image
Jatin Sharma • Edited

Oh I see, I'll fix that ASAP. Thanks mate.

Collapse
 
krakoss profile image
krakoss

Hello, I have implemented this check with the following code

// It helps to move the dot, it take "index" 
//as parameter and update the slideIndex
function moveDot(index) {
  slideIndex = index;
  const activeSlide = slides.querySelector("[data-active]");
  const nextPrevSlide = slides.children[slideIndex - 1];
    if(activeSlide !== nextPrevSlide)
        updateImageAndDot();
}
Enter fullscreen mode Exit fullscreen mode

Sorry for my english