@Alpha12

Почему slik slider дублирет фото на мобильной версии?

Вопрос такой, есть slick slider і magnific popup
на пк версии все окей, но на мобильной дублирует фото
к примеру у меня есть 3 фото, а на мобильной версии будет показывать что их 6.
Вот код
//slider
$('.slide-item').slick({
    infinite: true,
  slidesToShow: 3,
  slidesToScroll: 1,
  centerPadding: '10px',  
  arrow:true,
  dots:false,
  responsive: [
 
     {
      breakpoint: 895,
      settings: {
        slidesToShow: 2,
        slidesToScroll: 1,
        infinite: true,     
      }
    },    
    {
      breakpoint: 480,
      settings: {
        slidesToShow: 1,
        slidesToScroll: 1,
        infinite: true, 
      }
    }
  
  ]
   });
// popup
 $('.it-img,.big-img').magnificPopup({
 delegate: 'a',
 type: 'image',
 tLoading: 'Загрузка изображения #%curr%...',
 gallery: {
     enabled: true,
     tCounter: '<span class="mfp-counter">%curr% of %total%</span>' ,
     navigateByImgClick: true,
     preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
 }
 });

А вот если понадобится верстка
<div class="image-item">
      <div class="flex big-img">
        <a href="<?php the_post_thumbnail_url();?>"><?php  the_post_thumbnail(); ?></a>
    
      </div>
      <?php if (have_rows('product_album')): ?>
      	
           
      <div class="slide-item flex">
       <?php 	while(have_rows('product_album')):the_row();

       $image	= get_sub_field('foto'); if($image != ""): ?>
                
        <div class="it-img"><a href="<?php echo $image;?>" rel="alternate"><img src="<?php echo $image;?>" alt="prod"></a></div>
              
       <?php    endif;	
     endwhile; ?>
      </div>
      <?php endif;?>
    </div><!--image-item-->
  • Вопрос задан
  • 304 просмотра
Решения вопроса 1
@yarnstart
Превозмогание и React
При использовании карусели( owl , slick etc. ) с включенной функцией infinite необходимо исключать клонированные элементы в различных галереях ( fancybox, mfp etc. ), например
:not(.slick-cloned)
полный код:
$('.it-img:not(.slick-cloned),.big-img').magnificPopup({
 delegate: 'a',
 type: 'image',
 tLoading: 'Загрузка изображения #%curr%...',
 gallery: {
     enabled: true,
     tCounter: '<span class="mfp-counter">%curr% of %total%</span>' ,
     navigateByImgClick: true,
     preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
 }
 });
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы