@@ -437,6 +437,27 @@ export default function MobileMenu({ lang, items = [], socialItems = [] }) {
437437 else playOpen ( ) ;
438438 } , [ playOpen , playClose ] ) ;
439439
440+ // ---- Smooth scroll helper with controlled duration ----
441+ const smoothScrollTo = useCallback ( ( targetPosition , duration = 2000 ) => {
442+ const startPosition = window . pageYOffset ;
443+ const distance = targetPosition - startPosition ;
444+ let startTime = null ;
445+
446+ function easeInOutCubic ( t ) {
447+ return t < 0.5 ? 4 * t * t * t : 1 - Math . pow ( - 2 * t + 2 , 3 ) / 2 ;
448+ }
449+
450+ function animation ( currentTime ) {
451+ if ( startTime === null ) startTime = currentTime ;
452+ const timeElapsed = currentTime - startTime ;
453+ const progress = Math . min ( timeElapsed / duration , 1 ) ;
454+ window . scrollTo ( 0 , startPosition + distance * easeInOutCubic ( progress ) ) ;
455+ if ( timeElapsed < duration ) requestAnimationFrame ( animation ) ;
456+ }
457+
458+ requestAnimationFrame ( animation ) ;
459+ } , [ ] ) ;
460+
440461 // ---- Nav link click handler (hash scroll) ----
441462 const handleNavClick = useCallback (
442463 ( e , href ) => {
@@ -447,19 +468,19 @@ export default function MobileMenu({ lang, items = [], socialItems = [] }) {
447468 const targetId = hashMatch [ 1 ] ;
448469 const el = targetId === 'hero' ? null : document . getElementById ( targetId ) ;
449470 if ( targetId === 'hero' && document . getElementById ( 'hero' ) ) {
450- window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
471+ smoothScrollTo ( 0 ) ;
451472 } else if ( el ) {
452473 const header = document . getElementById ( 'main-header' ) ;
453474 const offset = header ? header . offsetHeight : 0 ;
454475 const top = el . getBoundingClientRect ( ) . top + window . scrollY - offset ;
455- window . scrollTo ( { top, behavior : 'smooth' } ) ;
476+ smoothScrollTo ( top ) ;
456477 } else {
457478 window . location . href = href ;
458479 }
459480 }
460481 } ) ;
461482 } ,
462- [ playClose ]
483+ [ playClose , smoothScrollTo ]
463484 ) ;
464485
465486 // ---- Submenu item click handler (full page navigation) ----
0 commit comments