Spaces:
Running
Running
| var swiper = new Swiper('.mySwiper', { | |
| loop: true, | |
| navigation: { | |
| nextEl: '.swiper-button-next', | |
| prevEl: '.swiper-button-prev', | |
| }, | |
| }) | |
| const swiperLightbox = document.getElementById('swiper-lightbox') | |
| const swiperLightboxImg = document.getElementById('swiper-lightbox-img') | |
| const swiperCloseBtn = document.getElementById('swiper-lightbox__close') | |
| if (swiperLightbox && swiperLightboxImg && swiperCloseBtn) { | |
| document.querySelectorAll('.swiper-slide img').forEach((slideImage) => { | |
| slideImage.addEventListener('click', () => { | |
| const imgSrc = slideImage.src | |
| if (imgSrc) { | |
| swiperLightbox.style.display = 'flex' | |
| swiperLightboxImg.src = imgSrc | |
| } | |
| }) | |
| }) | |
| swiperCloseBtn.addEventListener('click', () => { | |
| swiperLightbox.style.display = 'none' | |
| }) | |
| swiperLightbox.addEventListener('click', (e) => { | |
| if (swiperLightbox.style.display === 'flex') { | |
| swiperLightbox.style.display = 'none' | |
| } | |
| }) | |
| } else { | |
| console.warn('Элементы лайтбокса в слайдере не найдены.') | |
| } | |