@@ -24,6 +24,7 @@ const PolaroidGallery = ({
2424 const [ isVisible , setIsVisible ] = useState ( false ) ;
2525 const [ currentIndex , setCurrentIndex ] = useState ( 0 ) ;
2626 const [ isViewerOpen , setIsViewerOpen ] = useState ( false ) ;
27+ const [ isImageLoading , setIsImageLoading ] = useState ( false ) ;
2728
2829 useEffect ( ( ) => {
2930 if ( isInView && ! isVisible ) {
@@ -41,10 +42,12 @@ const PolaroidGallery = ({
4142 } , [ ] ) ;
4243
4344 const nextImage = useCallback ( ( ) => {
45+ setIsImageLoading ( true ) ;
4446 setCurrentIndex ( ( prev ) => ( prev + 1 ) % images . length ) ;
4547 } , [ images . length ] ) ;
4648
4749 const prevImage = useCallback ( ( ) => {
50+ setIsImageLoading ( true ) ;
4851 setCurrentIndex ( ( prev ) => ( prev - 1 + images . length ) % images . length ) ;
4952 } , [ images . length ] ) ;
5053
@@ -150,14 +153,18 @@ const PolaroidGallery = ({
150153 key = { currentIndex }
151154 className = "relative w-full h-[80vh] max-w-4xl mx-auto"
152155 initial = { { scale : 0.8 , opacity : 0 , rotateY : 15 } }
153- animate = { { scale : 1 , opacity : 1 , rotateY : 0 } }
156+ animate = { {
157+ scale : 1 ,
158+ opacity : 1 ,
159+ rotateY : 0 ,
160+ } }
154161 exit = { { scale : 0.8 , opacity : 0 , rotateY : - 15 } }
155162 transition = { {
156- duration : 0.6 ,
163+ duration : 0.4 ,
157164 ease : [ 0.25 , 0.46 , 0.45 , 0.94 ] ,
158165 type : "spring" ,
159- stiffness : 100 ,
160- damping : 20 ,
166+ stiffness : 200 ,
167+ damping : 25 ,
161168 } }
162169 >
163170 < div className = "relative w-full h-full rounded-xl overflow-hidden flex items-center justify-center" >
@@ -166,11 +173,23 @@ const PolaroidGallery = ({
166173 alt = ""
167174 width = { 800 }
168175 height = { 600 }
169- className = "object-contain max-w-full max-h-full rounded-xl"
176+ className = { `object-contain max-w-full max-h-full rounded-xl transition-all duration-300 ${
177+ isImageLoading
178+ ? "blur-sm scale-105"
179+ : "blur-0 scale-100"
180+ } `}
170181 sizes = "(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 70vw"
171182 priority
183+ onLoad = { ( ) => setIsImageLoading ( false ) }
172184 />
173185
186+ { /* Loading overlay */ }
187+ { isImageLoading && (
188+ < div className = "absolute inset-0 bg-black/20 backdrop-blur-sm rounded-xl flex items-center justify-center" >
189+ < div className = "w-8 h-8 border-2 border-white/30 border-t-white rounded-full animate-spin" />
190+ </ div >
191+ ) }
192+
174193 { /* Subtle gradient overlay */ }
175194 < div className = "absolute inset-0 pointer-events-none" />
176195 </ div >
@@ -209,7 +228,10 @@ const PolaroidGallery = ({
209228 { images . map ( ( _ , index ) => (
210229 < button
211230 key = { index }
212- onClick = { ( ) => setCurrentIndex ( index ) }
231+ onClick = { ( ) => {
232+ setIsImageLoading ( true ) ;
233+ setCurrentIndex ( index ) ;
234+ } }
213235 className = { `w-2 h-2 rounded-full transition-all duration-200 ${
214236 index === currentIndex
215237 ? "bg-white scale-125"
0 commit comments