已经过了三年了,希望你已经解决了这个问题。
我刚刚研究出一个解决方案:
$('#gallery-1').on('click', 'a', function(event) {
let index = $(this).closest('.gallery-item').index('#gallery-1 .gallery-item');
setTimeout(()=>{
let galleryLightbox = $(`#elementor-lightbox-slideshow-${$(this).data('elementor-lightbox-slideshow')}`);
let swiper_target = galleryLightbox.find('.swiper');
if(swiper_target.length) {
let swiperInstance = swiper_target.data('swiper');
swiperInstance.loopDestroy();
swiperInstance.params.loop = false;
swiperInstance.update();
swiperInstance.slideTo(index, 0)
}
}, 500);
});
通过监听弹出图片,并使用 JS 动态修改 Swiper,请将 #gallery-1 替换为你的 Gallery ID。