Slick js 上下の連動表示のスライダーを同一ページ内に複数設置したいのですが、複数設置した場合動きが連動してしまいます。
レクチャーいただければ幸いです
sauceすべて
<div class="gallery-slider"> <div class="gallery-slider__images"> <div> <div class="item"> <div class="img-fill"><img src="/images/1_360x270.jpg" alt="img1"> </div> </div> <div class="item"> <div class="img-fill"><img src="/images/2_945x708.jpg" alt="img2"> </div> </div> <div class="item"> <div class="img-fill"><img src="/images/3_800x600.jpg" alt="img3"></div> </div> <div class="item"> <div class="img-fill"><img src="/images/4_800x600.jpg" alt="img3"></div> </div> <div class="item"> <div class="img-fill"><img src="/images/5_800x600.jpg" alt="img3"></div> </div> </div> <button class="prev-arrow slick-arrow"> </button> <button class="next-arrow slick-arrow"> </button> </div> <div class="gallery-slider__thumbnails"> <div> <div class="item"> <div class="img-fill"><img src="/images/1_360x270.jpg" alt="img1"> </div> </div> <div class="item"> <div class="img-fill"><img src="/images/2_945x708.jpg" alt="img2"> </div> </div> <div class="item"> <div class="img-fill"><img src="/images/3_800x600.jpg" alt="img3"></div> </div> <div class="item"> <div class="img-fill"><img src="/images/4_800x600.jpg" alt="img3"></div> </div> <div class="item"> <div class="img-fill"><img src="/images/5_800x600.jpg" alt="img3"></div> </div> </div> </div> <div class="gallery-slider"> <div class="gallery-slider__images"> <div> <div class="item"> <div class="img-fill"><img src="/images/1_360x270.jpg" alt="img1"> </div> </div> <div class="item"> <div class="img-fill"><img src="/images/2_945x708.jpg" alt="img2"> </div> </div> <div class="item"> <div class="img-fill"><img src="/images/3_800x600.jpg" alt="img3"></div> </div> <div class="item"> <div class="img-fill"><img src="/images/4_800x600.jpg" alt="img3"></div> </div> <div class="item"> <div class="img-fill"><img src="/images/5_800x600.jpg" alt="img3"></div> </div> </div> <button class="prev-arrow slick-arrow"> </button> <button class="next-arrow slick-arrow"> </button> </div> <div class="gallery-slider__thumbnails"> <div> <div class="item"> <div class="img-fill"><img src="/images/1_360x270.jpg" alt="img1"> </div> </div> <div class="item"> <div class="img-fill"><img src="/images/2_945x708.jpg" alt="img2"> </div> </div> <div class="item"> <div class="img-fill"><img src="/images/3_800x600.jpg" alt="img3"></div> </div> <div class="item"> <div class="img-fill"><img src="/images/4_800x600.jpg" alt="img3"></div> </div> <div class="item"> <div class="img-fill"><img src="/images/5_800x600.jpg" alt="img3"></div> </div> </div> </div>
$(function() { $('.gallery-slider>div,.gallery-slider__images.prev-arrow.next-arrow,.gallery-slider__thumbnails.prev-arrow.next-arrow').each(function(i){ $(this).addClass('data-id' + i); $(this).find('.slider-for').slick({ prevArrow:'data-id'+i+' .gallery-slider__images .prev-arrow', nextArrow:'data-id'+i+' .gallery-slider__images .next-arrow', asNavFor: 'data-id'+i+' .gallery-slider__thumbnails>div' }); $(this).find('.gallery-slider__thumbnails>div').slick({ prevArrow:'data-id'+i+' .gallery-slider__thumbnails .prev-arrow', nextArrow:'data-id'+i+' .gallery-slider__thumbnails .next-arrow', asNavFor: 'data-id'+i+' .gallery-slider .gallery-slider__images>div', }); }); }); /* const $imagesSlider = $(".gallery-slider .gallery-slider__images>div"), $thumbnailsSlider = $(".gallery-slider__thumbnails>div"); */ $('.gallery-slider .gallery-slider__images>div').slick({ speed:300, slidesToShow:1, slidesToScroll:1, cssEase:'linear', fade:true, draggable:false, asNavFor:".gallery-slider__thumbnails>div", prevArrow:'.gallery-slider__images .prev-arrow', nextArrow:'.gallery-slider__images .next-arrow' }); $('.gallery-slider__thumbnails>div').slick({ speed:300, slidesToShow:7, slidesToScroll:1, thumbnailsPosition: 'left', imageScaleMode:'contain', cssEase:'linear', draggable:false, focusOnSelect:true, asNavFor:".gallery-slider .gallery-slider__images>div", prevArrow:'.gallery-slider__thumbnails .prev-arrow', nextArrow:'.gallery-slider__thumbnails .next-arrow', responsive: [ { breakpoint: 720, settings: { slidesToShow: 4, slidesToScroll: 4 } }, { breakpoint: 576, settings: { slidesToShow: 3, slidesToScroll: 3 } }, { breakpoint: 350, settings: { slidesToShow: 2, slidesToScroll: 2 } } ] });
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/12/16 02:10