@@ -4,7 +4,7 @@ import { ScrollToPlugin } from "gsap/ScrollToPlugin";
44
55gsap . registerPlugin ( ScrollToPlugin ) ;
66
7- const ScrollControls = ( ) => {
7+ const ScrollControls = ( { isMobileMenuOpen = false } ) => {
88 const [ scrollProgress , setScrollProgress ] = useState ( 0 ) ;
99 const [ showTopBtn , setShowTopBtn ] = useState ( false ) ;
1010 const [ showBottomBtn , setShowBottomBtn ] = useState ( true ) ;
@@ -60,7 +60,7 @@ const ScrollControls = () => {
6060 } ,
6161 } ) ;
6262
63- // Button press “ blink”
63+ // Button press " blink"
6464 gsap . to ( ".scroll-to-top" , {
6565 scale : 0.9 ,
6666 duration : 0.1 ,
@@ -99,8 +99,11 @@ const ScrollControls = () => {
9999 const modalOverlay = document . querySelector ( ".modal-overlay" ) ;
100100 const isModalOpen = Boolean ( modalOverlay ) ;
101101
102- // If the modal is open, do not render any scroll buttons or ring:
103- if ( isModalOpen ) {
102+ /* Hide scroll controls if:
103+ * Modal is open
104+ * Mobile menu is open
105+ */
106+ if ( isModalOpen || isMobileMenuOpen ) {
104107 return null ;
105108 }
106109
@@ -112,7 +115,7 @@ const ScrollControls = () => {
112115 onClick = { scrollToTop }
113116 disabled = { isScrolling }
114117 className = { `
115- scroll-to-top fixed right-6 bottom-20 z-50 group transition-all duration-500
118+ scroll-to-top fixed right-3 bottom-16 md:right-6 md: bottom-20 z-50 group transition-all duration-500
116119 ${
117120 showTopBtn
118121 ? "opacity-100 translate-y-0 pointer-events-auto"
@@ -122,29 +125,29 @@ const ScrollControls = () => {
122125 ` }
123126 aria-label = 'Scroll to top'
124127 >
125- < div className = 'relative w-14 h-14' >
128+ < div className = 'relative w-10 h-10 md:w- 14 md: h-14' >
126129 { /* Background Ring */ }
127- < svg className = 'w-14 h-14 transform -rotate-90' viewBox = '0 0 56 56' >
130+ < svg className = 'w-full h-full transform -rotate-90' viewBox = '0 0 56 56' >
128131 < circle
129132 cx = '28'
130133 cy = '28'
131- r = '24 '
134+ r = '22 '
132135 fill = 'none'
133136 stroke = 'rgba(148, 163, 184, 0.2)'
134- strokeWidth = '3 '
137+ strokeWidth = '2.5 '
135138 className = 'dark:stroke-slate-600/30'
136139 />
137140 { /* Progress Ring */ }
138141 < circle
139142 cx = '28'
140143 cy = '28'
141- r = '24 '
144+ r = '22 '
142145 fill = 'none'
143146 stroke = 'url(#scrollGradient)'
144- strokeWidth = '3 '
147+ strokeWidth = '2.5 '
145148 strokeLinecap = 'round'
146- strokeDasharray = { 150.8 }
147- strokeDashoffset = { 150.8 - ( scrollProgress / 100 ) * 150.8 }
149+ strokeDasharray = { 138.2 }
150+ strokeDashoffset = { 138.2 - ( scrollProgress / 100 ) * 138.2 }
148151 className = 'transition-all duration-300 ease-out'
149152 />
150153 </ svg >
@@ -168,7 +171,7 @@ const ScrollControls = () => {
168171 { /* Arrow Icon */ }
169172 < div className = 'absolute inset-0 flex items-center justify-center bg-white/90 dark:bg-slate-800/90 backdrop-blur-sm rounded-full border border-white/20 dark:border-slate-700/50 shadow-lg group-hover:shadow-xl transition-all duration-300 group-hover:scale-110' >
170173 < svg
171- className = 'w-5 h-5 text-indigo-600 dark:text-indigo-400 transition-transform duration-300 group-hover:-translate-y-0.5'
174+ className = 'w-4 h-4 md:w-5 md: h-5 text-indigo-600 dark:text-indigo-400 transition-transform duration-300 group-hover:-translate-y-0.5'
172175 fill = 'none'
173176 stroke = 'currentColor'
174177 viewBox = '0 0 24 24'
@@ -197,7 +200,7 @@ const ScrollControls = () => {
197200 </ div >
198201
199202 { /* Tooltip */ }
200- < div className = 'absolute right-full mr-3 top-1/2 transform -translate-y-1/2 px-3 py-1.5 bg-slate-900 dark:bg-slate-700 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-all duration-300 whitespace-nowrap pointer-events-none' >
203+ < div className = 'hidden md:block absolute right-full mr-3 top-1/2 transform -translate-y-1/2 px-3 py-1.5 bg-slate-900 dark:bg-slate-700 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-all duration-300 whitespace-nowrap pointer-events-none' >
201204 { isScrolling ? "Scrolling..." : "Back to top" }
202205 < div className = 'absolute left-full top-1/2 transform -translate-y-1/2 border-4 border-transparent border-l-slate-900 dark:border-l-slate-700' > </ div >
203206 </ div >
@@ -210,7 +213,7 @@ const ScrollControls = () => {
210213 onClick = { scrollToBottom }
211214 disabled = { isScrolling }
212215 className = { `
213- scroll-to-bottom fixed right-6 bottom-4 z-50 group transition-all duration-500
216+ scroll-to-bottom fixed right-3 bottom-4 md:right-6 md: bottom-4 z-50 group transition-all duration-500
214217 ${
215218 showBottomBtn
216219 ? "opacity-100 translate-y-0 pointer-events-auto"
@@ -220,11 +223,11 @@ const ScrollControls = () => {
220223 ` }
221224 aria-label = 'Scroll to bottom'
222225 >
223- < div className = 'relative w-14 h-14' >
226+ < div className = 'relative w-10 h-10 md:w- 14 md: h-14' >
224227 { /* Arrow Icon */ }
225228 < div className = 'absolute inset-0 flex items-center justify-center bg-white/90 dark:bg-slate-800/90 backdrop-blur-sm rounded-full border border-white/20 dark:border-slate-700/50 shadow-lg group-hover:shadow-xl transition-all duration-300 group-hover:scale-110' >
226229 < svg
227- className = 'w-5 h-5 text-indigo-600 dark:text-indigo-400 transition-transform duration-300 group-hover:translate-y-0.5'
230+ className = 'w-4 h-4 md:w-5 md: h-5 text-indigo-600 dark:text-indigo-400 transition-transform duration-300 group-hover:translate-y-0.5'
228231 fill = 'none'
229232 stroke = 'currentColor'
230233 viewBox = '0 0 24 24'
@@ -253,7 +256,7 @@ const ScrollControls = () => {
253256 </ div >
254257
255258 { /* Tooltip */ }
256- < div className = 'absolute right-full mr-3 top-1/2 transform -translate-y-1/2 px-3 py-1.5 bg-slate-900 dark:bg-slate-700 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-all duration-300 whitespace-nowrap pointer-events-none' >
259+ < div className = 'hidden md:block absolute right-full mr-3 top-1/2 transform -translate-y-1/2 px-3 py-1.5 bg-slate-900 dark:bg-slate-700 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-all duration-300 whitespace-nowrap pointer-events-none' >
257260 { isScrolling ? "Scrolling..." : "Go to bottom" }
258261 < div className = 'absolute left-full top-1/2 transform -translate-y-1/2 border-4 border-transparent border-l-slate-900 dark:border-l-slate-700' > </ div >
259262 </ div >
0 commit comments