@@ -20,18 +20,36 @@ const images = [
2020 "/Assets/Images/cj8.jpg" ,
2121] ;
2222
23- const IMAGE_WIDTH = 600 + 48 ; // width + 2*mx-6 (24px each side)
23+ // Responsive image width and margin
24+ const getImageWidth = ( ) => {
25+ if ( typeof window === "undefined" ) return 600 + 48 ;
26+ if ( window . innerWidth < 640 ) return 320 + 24 ; // mobile: 320px + 2*mx-3
27+ if ( window . innerWidth < 1024 ) return 480 + 32 ; // tablet: 480px + 2*mx-4
28+ return 600 + 48 ; // desktop: 600px + 2*mx-6
29+ } ;
2430
2531const Gallery = ( ) => {
2632 const controls = useAnimation ( ) ;
2733 const [ isPaused , setIsPaused ] = useState ( false ) ;
34+ < < << << < HEAD
35+ const [ offset , setOffset ] = useState ( 0 ) ;
36+ const [ imageWidth , setImageWidth ] = useState ( getImageWidth ( ) ) ;
37+
38+ // Update image width on resize
39+ useEffect ( ( ) => {
40+ const handleResize = ( ) => setImageWidth ( getImageWidth ( ) ) ;
41+ window . addEventListener ( "resize" , handleResize ) ;
42+ return ( ) => window . removeEventListener ( "resize" , handleResize ) ;
43+ } , [ ] ) ;
44+ = === ===
2845 const [ offset , setOffset ] = useState ( 0 ) ; // offset in px
46+ > >>> >>> f44a310707bb1d1606c8f6f0471ed10d89ff7476
2947
3048 // Start animation
3149 useEffect ( ( ) => {
3250 if ( ! isPaused ) {
3351 controls . start ( {
34- x : [ offset , offset - ( images . length * IMAGE_WIDTH ) ] ,
52+ x : [ offset , offset - ( images . length * imageWidth ) ] ,
3553 transition : {
3654 repeat : Infinity ,
3755 repeatType : "loop" ,
@@ -43,41 +61,55 @@ const Gallery = () => {
4361 controls . stop ( ) ;
4462 }
4563 // eslint-disable-next-line
46- } , [ isPaused , offset , controls ] ) ;
64+ } , [ isPaused , offset , controls , imageWidth ] ) ;
4765
48- // When hover, set offset so hovered image is first
66+ // When hover/tap , set offset so hovered image is first
4967 const handleMouseEnter = ( idx : number ) => {
5068 setIsPaused ( true ) ;
69+ < < << << < HEAD
70+ setOffset ( - idx * imageWidth ) ;
71+ controls . set ( { x : - idx * imageWidth } ) ;
72+ = === ===
5173 setOffset ( - idx * IMAGE_WIDTH ) ;
5274 controls . set ( { x : - idx * IMAGE_WIDTH } ) ;
75+ > >>> >>> f44a310707bb1d1606c8f6f0471ed10d89ff7476
5376 } ;
5477
5578 // On leave, resume animation from current offset
5679 const handleMouseLeave = ( ) => {
5780 setIsPaused ( false ) ;
81+ < < << << < HEAD
82+ } ;
83+
84+ // For mobile: handle tap to pause and focus image
85+ const handleTouch = ( idx : number ) => {
86+ handleMouseEnter ( idx ) ;
87+ setTimeout ( ( ) => setIsPaused ( false ) , 2000 ) ; // Resume after 2s
88+ = === ===
89+ >>> >>> > f44a310707bb1d1606c8f6f0471ed10d89ff7476
5890 } ;
5991
6092 return (
6193 < div className = "w-full min-h-screen bg-black" >
6294 < NavBar />
6395
64- < div className = "container mx-auto pt-32 pb-20 px-4 md:px-8 lg:px-16" >
96+ < div className = "container mx-auto pt-32 pb-20 px-2 sm:px- 4 md:px-8 lg:px-16" >
6597 < motion . div
6698 initial = { { opacity : 0 , y : 20 } }
6799 animate = { { opacity : 1 , y : 0 } }
68100 transition = { { duration : 0.8 } }
69101 className = "text-center mb-12"
70102 >
71- < h1 className = "text-4xl md:text-5xl lg:text-6xl font-bold text-white mb-4" >
103+ < h1 className = "text-3xl sm:text- 4xl md:text-5xl lg:text-6xl font-bold text-white mb-4" >
72104 Our < span className = "text-primary" > Gallery</ span >
73105 </ h1 >
74- < p className = "text-white/70 max-w-2xl mx-auto text-lg" >
106+ < p className = "text-white/70 max-w-2xl mx-auto text-base sm:text- lg" >
75107 Explore our collection of memorable moments and achievements
76108 </ p >
77109 </ motion . div >
78110
79111 < div className = "flex justify-center" >
80- < div className = "overflow-hidden w-full max-w-6xl mx-auto rounded-xl border border-white/10 shadow-lg" >
112+ < div className = "overflow-hidden w-full max-w-full sm:max-w-2xl md:max-w-4xl lg:max-w- 6xl mx-auto rounded-xl border border-white/10 shadow-lg" >
81113 < motion . div
82114 className = "flex"
83115 style = { { width : "max-content" } }
@@ -86,10 +118,23 @@ const Gallery = () => {
86118 { [ ...images , ...images ] . map ( ( src , idx ) => (
87119 < motion . div
88120 key = { idx }
89- className = "relative flex-shrink-0 mx-6"
121+ className = { `
122+ relative flex-shrink-0
123+ mx-3 sm:mx-4 lg:mx-6
124+ ` }
90125 style = { {
91- width : "600px" ,
92- height : "340px" ,
126+ width :
127+ imageWidth === 320 + 24
128+ ? 320
129+ : imageWidth === 480 + 32
130+ ? 480
131+ : 600 ,
132+ height :
133+ imageWidth === 320 + 24
134+ ? 180
135+ : imageWidth === 480 + 32
136+ ? 270
137+ : 340 ,
93138 } }
94139 whileHover = { {
95140 scale : 1.08 ,
@@ -98,17 +143,18 @@ const Gallery = () => {
98143 } }
99144 onMouseEnter = { ( ) => handleMouseEnter ( idx % images . length ) }
100145 onMouseLeave = { handleMouseLeave }
146+ onTouchStart = { ( ) => handleTouch ( idx % images . length ) }
101147 >
102148 < Image
103149 src = { src }
104150 alt = { `Gallery Image ${ idx + 1 } ` }
105151 fill
106152 className = "object-cover rounded-xl"
107- sizes = "(max-width: 768px ) 90vw, (max-width: 1200px ) 45vw, 600px"
153+ sizes = "(max-width: 640px ) 90vw, (max-width: 1024px ) 45vw, 600px"
108154 priority = { idx === 0 }
109155 />
110- < div className = "absolute inset-0 bg-gradient-to-t from-black/60 to-transparent opacity-0 hover:opacity-100 transition-opacity duration-300 flex items-end justify-center p-6 rounded-xl" >
111- < p className = "text-white text-base md:text-xl font-medium text-center" >
156+ < div className = "absolute inset-0 bg-gradient-to-t from-black/60 to-transparent opacity-0 hover:opacity-100 transition-opacity duration-300 flex items-end justify-center p-3 sm:p- 6 rounded-xl" >
157+ < p className = "text-white text-xs sm:text- base md:text-xl font-medium text-center" >
112158 Capturing our journey of innovation and collaboration
113159 </ p >
114160 </ div >
0 commit comments