I am in the process of designing a full-page navigation overlay for my website to ensure consistency across all devices. Currently, I have two buttons - one to display the overlay and another to hide it. I am considering whether it would be more effective to have a single button that is always visible for better animation possibilities. I am aiming to achieve an animated effect similar to the squeeze
animation demonstrated here. However, I am uncertain about how to animate this transition using only one button compared to having two separate buttons or even creating the animation from scratch.
This is the code I am working with;
const navButtons = document.querySelectorAll('button.nav-action');
const siteNav = document.querySelector('.site-nav');
function onClick(event) {
siteNav.classList.toggle('active');
}
navButtons.forEach(button => button.addEventListener('click', onClick));
[CSS CODE HERE]
[HTML CODE HERE]
Currently, the overlay appears based on the button clicked, but I am unsure if having a single button is the most efficient approach or if placing the icon outside of the button would be more effective.
My ultimate goal is to animate the hamburger icon as the overlay is revealed from the top, but I need to first determine the best strategy for handling the button. Any guidance on this matter would be greatly appreciated as I am feeling quite lost at the moment.
Thank you in advance.