Jump to content

Slideshow JS issues with timing between slides


Jeza95

Recommended Posts

Im currently using the slideshow/carousel code with automatic slide JS, but I'm having issues with the timing of the slides. The issue is when I set the timing to 4000ms, the intervals are showing one slide, then 4000ms of nothing, then the next slide. Would anyone be able to assist?

Here's the code I'm using:

<!-- Slideshow container -->
<div class="slideshow-container">

  <!-- Full-width images with number and caption text -->

  <div class="mySlides fade">
   <a href="https://bhl.co.uk/heating-plumbing/air-conditioning-ventilation.html">
   <img src="{{media url=&quot;wysiwyg/AC_banner_1.png&quot;}}" alt="" />
</a>
  </div>

  <div class="mySlides fade">
<a href="https://bhl.co.uk/outdoor-gardening/garden-chemicals/seeds-bulbs.html">
    <img src="{{media url=&quot;wysiwyg/Bird_Seeds_1.png&quot;}}" alt="" /> 
</a>
  </div>

<div class="mySlides fade">
<a href="https://bhl.co.uk/outdoor-gardening/garden-tools.html">
    <img src="{{media url=&quot;wysiwyg/garden_tools_banner_1.png&quot;}}" alt="" />
</a>
  </div>

<div class="mySlides fade">
<a href="https://bhl.co.uk/outdoor-gardening/garden-watering.html">
    <img src="{{media url=&quot;wysiwyg/Garden_Watering_Banner_1.png&quot;}}" alt="" />
</a>
  </div>

</div>
<br>

<!-- The dots/circles -->
<div style="text-align:center">
   
</div>

<script>
let slideIndex = 0;
showSlides();

function showSlides() {
  let i;
  let slides = document.getElementsByClassName("mySlides");
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";
  }
  slideIndex++;
  if (slideIndex > slides.length) {slideIndex = 1}
  slides[slideIndex-1].style.display = "block";
  setTimeout(showSlides, 3500); // Change image every 4 seconds
}
</script>

  • Like 1
Link to comment
Share on other sites

There is not enough information here to solve the problem, so I have to make some guesses.

It's possible that the fade class has an animation which makes the slide fade out. Try removing the fade class from the slides. If you want a fading effect, the Javascript code needs to have some control over it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...