Magnific Popup не работает при первом клике - PullRequest
0 голосов
/ 07 марта 2019

Я использую jQuery Magnific Popup в своем портфолио сайтов.Все работает нормально, кроме увеличенного всплывающего окна открывается только после второго клика.Всякий раз, когда я обновляюсь, используя shift + f5, это происходит.Я думаю, что это происходит, потому что я не использую ту же ссылку в href и img src.Пожалуйста, помогите мне исправить это.

HTML

<a class="image-popup" href="https://designassociates.ltd/wp-content/uploads/2019/03/PEB-Office-Interior-6.jpg">
<img src="https://designassociates.ltd/wp-content/uploads/2019/03/PEB-Office-Interior-6-300x300.jpg" alt="Interior Design" width="263" height="263">
</a>       
 <a class="image-popup" href="https://designassociates.ltd/wp-content/uploads/2019/03/PEB-Office-Interior-7.jpg">
<img src="https://designassociates.ltd/wp-content/uploads/2019/03/PEB-Office-Interior-7-300x300.jpg" alt="Interior Design" width="263" height="263">
</a>

jQuery

$('.image-popup').magnificPopup({
    type: 'image',
    closeOnContentClick: true,
    closeBtnInside: true,
    fixedContentPos: true,
    mainClass: 'mfp-no-margins mfp-with-zoom', // class to remove default margin from left and right side
     gallery: {
      enabled: true,
      navigateByImgClick: true,
      preload: [0,1] // Will preload 0 - before current, and 1 after the current image
    },
    callbacks: {
    buildControls: function() {
      // re-appends controls inside the main container
      this.contentContainer.append(this.arrowLeft.add(this.arrowRight));
    }},
    image: {
      verticalFit: true
    },
    zoom: {
      enabled: true,
      duration: 300 // don't foget to change the duration also in CSS
    }
  });

JSFiddle: https://jsfiddle.net/1n6zrm4q/

...