最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - slick slider make delay of start - Stack Overflow

programmeradmin1浏览0评论

is it possible to make delay of slider start... I don't want to slider start immediatly, want it to wait 2 sec before start and then slide.

$(function() {
    $('.banner').slick({
      autoplay:true,
      autoplaySpeed:2000,
      centerMode: true,
      centerPadding: '50px',
      slidesToShow: 1,
      speed:2000,
      pauseOnFocus: false,
      pauseOnHover: false,
      pauseOnDotsHover: false,
    });

is it possible to make delay of slider start... I don't want to slider start immediatly, want it to wait 2 sec before start and then slide.

$(function() {
    $('.banner').slick({
      autoplay:true,
      autoplaySpeed:2000,
      centerMode: true,
      centerPadding: '50px',
      slidesToShow: 1,
      speed:2000,
      pauseOnFocus: false,
      pauseOnHover: false,
      pauseOnDotsHover: false,
    });
Share Improve this question edited Mar 29, 2019 at 6:52 asked Mar 29, 2019 at 6:20 user10828115user10828115 5
  • Already answer exit, best example by @Calsal Ans: stackoverflow./a/38199293/2384642 – Shiv Singh Commented Mar 29, 2019 at 6:40
  • Possible duplicate of slick carousel individual slide duration – Shiv Singh Commented Mar 29, 2019 at 6:43
  • Did you try using setTimeout? – Thanveer Shah Commented Mar 29, 2019 at 7:03
  • you need to show me to how... @ThanveerShah – user10828115 Commented Mar 29, 2019 at 7:03
  • Check my answer – Thanveer Shah Commented Mar 29, 2019 at 7:05
Add a ment  | 

3 Answers 3

Reset to default 3

If you want this at initial page load then simply use a setTimeout() function like this,

var count = 0;
    setTimeout(()=>{
        count = 1;
        $('.banner').slick({
          autoplay:true,
          autoplaySpeed:2000,
          centerMode: true,
          centerPadding: '50px',
          slidesToShow: 1,
          speed:2000,
          pauseOnFocus: false,
          pauseOnHover: false,
          pauseOnDotsHover: false,

    },2000) // Initialize the amount of time to delay , Its 2seconds currently.

if(count == 1){
 $(function() {
        $('.banner').slick({
          autoplay:true,
          autoplaySpeed:2000,
          centerMode: true,
          centerPadding: '50px',
          slidesToShow: 1,
          speed:2000,
          pauseOnFocus: false,
          pauseOnHover: false,
          pauseOnDotsHover: false,
        });
      }

I think this is a bit of a cleaner solution than above. Making use of the inbuilt play/pause methods in Slick. Taken from here.

var slider = $('.slider');

slider.slick({
    autoplay: true,
    autoplaySpeed: 1000
}).slick("slickPause");

var initialDelay = 3000;

setTimeout(function() {
    slider.slick("slickPlay");
},initialDelay);

just control your speed through speed:2000, or autoplaySpeed:2000, this will delay your slider according to the given time

发布评论

评论列表(0)

  1. 暂无评论