"틀:이미지스와이퍼"의 두 판 사이의 차이
광주문화예술인문스토리플랫폼
| 72번째 줄: | 72번째 줄: | ||
// 이미지 로딩 타임아웃 및 에러 처리 | // 이미지 로딩 타임아웃 및 에러 처리 | ||
var swiperContainer = document.querySelector('.image-swiper-container'); | var swiperContainer = document.querySelector('.image-swiper-container'); | ||
| − | + | document.querySelectorAll('.image-swiper-container .swiper-image').forEach(function(img) { | |
| − | |||
| − | |||
var timeout; | var timeout; | ||
var removeSlide = function() { | var removeSlide = function() { | ||
clearTimeout(timeout); | clearTimeout(timeout); | ||
| − | img.closest('.swiper-slide').remove(); | + | |
| + | // 슬라이드 제거 | ||
| + | var slideToRemove = img.closest('.swiper-slide'); | ||
| + | if (slideToRemove) { | ||
| + | slideToRemove.remove(); | ||
| + | } | ||
| + | |||
swiper.update(); | swiper.update(); | ||
| + | |||
| + | // 슬라이드 제거 후 남은 슬라이드 확인 | ||
| + | var remainingSlides = document.querySelectorAll('.image-swiper-container .swiper-slide'); | ||
| + | console.log('남은 슬라이드 개수:', remainingSlides.length); | ||
// 슬라이드가 하나도 없으면 스와이퍼 컨테이너 제거 | // 슬라이드가 하나도 없으면 스와이퍼 컨테이너 제거 | ||
| − | |||
if (remainingSlides.length === 0 && swiperContainer) { | if (remainingSlides.length === 0 && swiperContainer) { | ||
| + | console.log('슬라이드가 없어서 스와이퍼 컨테이너 제거'); | ||
swiperContainer.remove(); | swiperContainer.remove(); | ||
} | } | ||