Skip to content

Commit 996fe7e

Browse files
committed
Smooth mobile nav transitions behind hamburger overlay
Instantly swap sections behind the menu overlay by temporarily disabling CSS transitions, then fade out the menu to reveal the new section already in place. Eliminates the flash of the previous section during navigation.
1 parent 0bb8437 commit 996fe7e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,13 +2142,20 @@
21422142
navItems.forEach(item => {
21432143
item.addEventListener('click', () => {
21442144
const targetId = item.dataset.target;
2145-
showSection(targetId);
2146-
// Close hamburger menu on mobile after nav click
21472145
if (sidebar.classList.contains('menu-open')) {
2146+
// Disable section transitions so the swap is instant behind the overlay
2147+
sections.forEach(s => s.style.transition = 'none');
2148+
showSection(targetId);
2149+
// Force reflow so the instant swap applies before re-enabling transitions
2150+
document.body.offsetHeight;
2151+
sections.forEach(s => s.style.transition = '');
2152+
// Now fade out the menu to reveal the new section already in place
21482153
sidebar.classList.remove('menu-open');
21492154
hamburger.classList.remove('open');
21502155
document.body.style.overflow = '';
21512156
if (carouselWrapperEl) carouselWrapperEl.style.display = '';
2157+
} else {
2158+
showSection(targetId);
21522159
}
21532160
});
21542161
});

0 commit comments

Comments
 (0)