splide icon indicating copy to clipboard operation
splide copied to clipboard

My slides not skipping automatically

Open wokalove opened this issue 6 years ago • 3 comments

I suppose that it can be some problem with "autoplay" or with not accurate library? I don't really know. I will leave code here which is associated with splide.

IN HTML:
 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@splidejs/[email protected]/dist/css/splide.min.css">
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@splidejs/splide@latest/dist/js/splide.min.js">


<section class = "latest_posts">
					<h1 class="ml2">Aktualności</h1>
					<div id="splide" class="splide">
					  <div class="splide__track">
						<ul class="splide__list">
						  <li class="splide__slide " >
								<img src = "img/ola_lezy.jpg">
						  </li>
						  <li class="splide__slide">
								<img src = "img/ola_lezy.jpg">
						  </li>
						  <li class="splide__slide">
								<img src = "img/ola_lezy.jpg">
						  </li>
						</ul>
					  </div>
					</div>
				</section>


 <script>
      document.addEventListener( 'DOMContentLoaded', function () {
			  new Splide('#splide', {
				type: 'loop',
				perPage: 3,
				focus: 'center',
				autoplay: true,
				interval: 1000,
				flickMaxPages: 3,
				updateOnMove: true,
				pagination: false,
				padding: '10%',
				throttle: 300,
				<!--pauseOnHover:true,-->
				
				breakpoints: {
				  1440: {
					perPage: 1,
					padding: '30%'
				  }
				}
  }).mount();
});
  </script>

 IN CSSS:

.splide{
	padding-top: 30px;
	padding-bottom: 60px;
}
.splide img {
	width: 100%;
	height: auto;
    border-radius: 8px;
    transition: transform 400ms;
    transform: scale(.95);
    transform-origin: center center;
}


.splide .splide__arrow {
  top: 0;
  bottom: 0;
  height: 100%;
  transform: none;
  border-radius: unset;
  width: 50px;
  opacity: .9;
  svg {
    filter: invert(1);
    width: 24px;
    height: 24px;
	
  }
}
.splide__arrow.splide__arrow--prev {
  left: 0;
  background: linear-gradient(90deg,rgba(103, 80, 105, 0.95) 0%, rgba(0,0,0,0) 100%);
}
.splide__arrow.splide__arrow--next {
  right: 0;
  background: linear-gradient(270deg, rgba(103, 80, 105, 0.95) 0%, rgba(0,0,0,0) 100%);
}

wokalove avatar Jul 28 '20 07:07 wokalove

Auto play starts when the number of slides are greater than perPage to avoid meaningless page change.

Your auto play doesn't start because you set perPage: 3 but your slider has 3 slides. It will work by changing it to 2 or add one more slide to your slider.

NaotoshiFujita avatar Jul 28 '20 08:07 NaotoshiFujita

OMG, thank you for explanation!!! It works! Your Splide is masterpiece :)

wokalove avatar Jul 28 '20 08:07 wokalove

Okay, thanks 😄

NaotoshiFujita avatar Jul 28 '20 08:07 NaotoshiFujita