File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
2+ const menu = document . querySelector ( '[data-mobile-navbar]' ) ;
3+ const closeBtn = document . querySelector ( '.navbar-button-close' ) ;
4+ const menuLinks = document . querySelectorAll (
5+ '.navbar-nav-link, .navbar-join-link-mobile, .join-now-button-bottom, .navbar-join-link-desktop'
6+ ) ;
7+
8+ function closeMenu ( ) {
9+ menu . classList . add ( 'is-hidden' ) ;
10+ }
11+
12+ // Закрытие по кнопке
13+ closeBtn . addEventListener ( 'click' , closeMenu ) ;
14+
15+ // Закрытие и переход по якорю
16+ menuLinks . forEach ( link => {
17+ link . addEventListener ( 'click' , function ( e ) {
18+ e . preventDefault ( ) ;
19+
20+ const targetId = this . getAttribute ( 'href' ) . replace ( '#' , '' ) ;
21+ const target = document . getElementById ( targetId ) ;
22+
23+ // Закрытие меню
24+ closeMenu ( ) ;
25+
26+ // Плавный скролл
27+ if ( target ) {
28+ setTimeout ( ( ) => {
29+ target . scrollIntoView ( { behavior : 'smooth' } ) ;
30+ } , 300 ) ; // Ждём, пока меню скроется (если нужно)
31+ }
32+ } ) ;
33+ } ) ;
34+ } ) ;
You can’t perform that action at this time.
0 commit comments