waitForAnimate

更新日: 2019-12-19

アニメーション中にスライドを移動させるリクエストを無視します。

  • 初期値 : true
  • type : boolean
$('.slider').slick({
  waitForAnimate: true,
});

デモ

アニメーション中にスライドを移動させないようにしています。 "無効化"ボタンを押すと、アニメーション中にも別のスライドへ移動させることができます。

1

2

3

無効化
JavaScript
$(document).ready(function(){
  $('.slider').slick({
    waitForAnimate: true,
  });
  var waitForAnimate = true;
  $('.js-setoption').on('click', function() {
    waitForAnimate = !waitForAnimate;
    $('.slider').slick('slickSetOption', {
      waitForAnimate: waitForAnimate,
    }, true);
    if (waitForAnimate === true) {
      $(this).text('無効化');
    } else {
      $(this).text('有効化');
    }
  });
});
HTML
<div class="slider">
  <p>1</p>
  <p>2</p>
  <p>3</p>
</div>
<div class="buttons">
  <div class="button js-setoption">無効化</div>
</div>
CSS
.slick-prev:before,
.slick-next:before {
  color: #000 !important;
}

.slider p {
  font-size: 2rem;
  font-weight: bold;
  line-height: 100px;
  color: #666;
  margin: 10px;
  text-align: center;
  background-color: #e0e0e0;
}

.buttons {
  display: flex;
  justify-content: center;
}

.buttons .button {
  margin: 8px;
  border: 1px solid #000;
  color: #000;
  padding: 8px;
  text-align: center;
  width: 8em;
  transition: all 300ms ease;
}

.buttons .button:hover {
  cursor: pointer;
  background-color: #000;
  color: #fff;
  transition: all 300ms ease;
}

© 2017 Ken Wheeler Licensed under the MIT license

このコンテンツはKen Wheeler(kenwheeler)によるslickドキュメントを翻訳/改変したものです。