kenwheeler / slick

the last carousel you'll ever need
kenwheeler.github.io/slick
MIT License
28.33k stars 5.88k forks source link

Adding ID to a slide doesnt work correctly when carousel starts to loop back around #4170

Open jmona789 opened 2 years ago

jmona789 commented 2 years ago

short description of the bug / issue, provide more detail below.

Adding ID to a slide doesn't work correctly when the carousel starts to loop back around. Because each slide is added to the dom more than one time only the first slide in the dom gets the id and any related CSS.

====================================================================

paste your jsfiddle link here

====================================================================

Steps to reproduce the problem

  1. Navigate to the last slide.
  2. Click the next arrow to go to the next slide, see that the new slide doesn't have the id and styles set until you navigate once more

====================================================================

What is the expected behaviour?

The slide should get the id so the styles work correctly. Since ids cant be used twice in html it should remove the id from the currently unseen slide and add it to the slide coming into view.

====================================================================

What is observed behaviour?

Only the first instance of slide in the dom gets the id, so when the second instance is shown it doesn't get any styles attached to ID

====================================================================

More Details