dynamicweb / swiffy-slider

Super fast carousel and slider with touch for optimized websites running in modern browsers.
MIT License
250 stars 29 forks source link

Script skips images #36

Closed GuyVervillePerso closed 2 years ago

GuyVervillePerso commented 2 years ago

Describe the bug On a 5 image-slider, the script skips 2 and 4. You can see that the button list below is visited only on 1, 3 and 5. Why?

CleanShot 2022-04-21 at 08 15 11

The code is as follows:

`

  • Erika

    Erika
  • [...]
  <button type="button" class="slider-nav"></button>
  <button type="button" class="slider-nav slider-nav-next"></button>
  <div class="slider-indicators">
    <button class=""></button>
    <button></button>
    <button class=""></button>
    <button></button>
    <button class="active"></button>
  </div>
</div>

`

The script is fired this way:

window.addEventListener('load', () => { swiffyslider.initSlider(document.getElementById('employees')); });

nicped commented 2 years ago

I think it can be one of 2 things. I just tested your markup and it seems to work fine with my local installation.

  • You might accidently initialize the script twice causing 2 autoplayers to run at the same time. If you load swiffy-slider.js in a script tag using src attribute, it will automatically initialize the slider instance - except if you add data-noinit attribute to the script tag. So try to remove your window.addEventListener and see if that will not fix the issue.
  • If each of the slides (or the content inside the slides) are wider than the swiffy-slider container, scrolling next can cause the slider to skip a slide as it will slide the width of the slide. So you can check in the developer tools of your browser if that looks ok.

BR Nicolai

pneumotube commented 2 years ago

Hi, thanks for a great slider!

It seems I managed to run into this too (Chrome 102):

https://user-images.githubusercontent.com/4160539/171045653-e411aa46-b5aa-41b4-8c63-062b689cfbed.mp4

Configurator settings. I reproduce this issue with this settings on Chrome Canary too.

nicped commented 2 years ago

Hi - thanks for trying it out!

I think this problem is 2 things - double loading and initialization of the slider (which happened on the configuration page) and a problem with dragging also reacting when using arrows. Never tested that since I thought you would not combine those.

Made an update of the configuration page that I believe fixes this issue. https://github.com/dynamicweb/swiffy-slider/commit/c2753596f5b7a293b182719ef369bf706050499e

Will also note that I do not see the dragging feature as a feature that should be used. It is really odd to have mouse dragging on these things (seen from a UX perspective)....

Thanks for giving it a spin and testing things out.

pneumotube commented 2 years ago

Okay, noted, thanks. I personally like to drag slider items, it seems to be a more natural movement for me (on the desktop of course). Easier than aiming at arrows :)