diff --git a/src/feature/photo-detail/components/SwiperPhotoList.tsx b/src/feature/photo-detail/components/SwiperPhotoList.tsx index 7c4fdf2..6789c7e 100644 --- a/src/feature/photo-detail/components/SwiperPhotoList.tsx +++ b/src/feature/photo-detail/components/SwiperPhotoList.tsx @@ -42,15 +42,14 @@ export default function SwiperPhotoList({ return () => window.removeEventListener('resize', updateThumbOffset); }, [updateThumbOffset]); - // TODO : activeIndex위치 구하는 로직 고도화 필요 - // useEffect(() => { - // if (!thumbSwiper || thumbSwiper.destroyed) return; + useEffect(() => { + if (!thumbSwiper || thumbSwiper.destroyed) return; - // thumbSwiper.slideTo(activeIndex); - // requestAnimationFrame(() => { - // thumbSwiper.setTranslate(thumbOffset); - // }); - // }, [activeIndex, thumbOffset, thumbSwiper]); + thumbSwiper.slideTo(activeIndex); + requestAnimationFrame(() => { + thumbSwiper.setTranslate(thumbOffset); + }); + }, [activeIndex, thumbOffset, thumbSwiper]); return ( <> @@ -121,8 +120,9 @@ export default function SwiperPhotoList({ initialSlide={activeIndex} slidesPerView='auto' spaceBetween={2} + slidesOffsetBefore={thumbOffset} + slidesOffsetAfter={thumbOffset} watchSlidesProgress - centeredSlides allowTouchMove={false} className='custom-thumb-swiper relative w-full px-3 py-2 backdrop-blur-md' >