Skip to content

Commit 2197104

Browse files
committed
fixed scroll in mob order
1 parent 6205c22 commit 2197104

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/js/header.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ document.addEventListener('DOMContentLoaded', function () {
55
const burgerBtn = document.querySelector('.open-modal');
66
const closeBtn = document.querySelector('.close-menu');
77
const mobileMenu = document.querySelector('.mobile-burger-menu');
8+
const orderBtnMob = document.querySelector('.order-btn-mob');
89

910
if (
1011
!menuBtn ||
1112
!navMenu ||
1213
navLinks.length === 0 ||
1314
!burgerBtn ||
1415
!closeBtn ||
15-
!mobileMenu
16+
!mobileMenu ||
17+
!orderBtnMob
1618
)
1719
return;
1820

@@ -65,4 +67,19 @@ document.addEventListener('DOMContentLoaded', function () {
6567
closeMobileMenu();
6668
});
6769
});
70+
71+
orderBtnMob.addEventListener('click', function (e) {
72+
e.preventDefault();
73+
const targetId = this.getAttribute('href').substring(1);
74+
const targetSection = document.getElementById(targetId);
75+
76+
if (targetSection) {
77+
window.scrollTo({
78+
top: targetSection.offsetTop - 50,
79+
behavior: 'smooth',
80+
});
81+
}
82+
83+
closeMobileMenu();
84+
});
6885
});

0 commit comments

Comments
 (0)