var modernPlayerMenu = document.querySelector("#hamburger > div"); var isMenuOpen = document.body.classList.contains("sidebar-open");
if (isMenuOpen) { // The menu is open, so close it if (modernPlayerMenu) { modernPlayerMenu.click(); } } else { // The menu is already closed, do nothing }
Just out of personal curiosity, if the menu is closed, does it hurt anything to close it? If not, why check? Just close it, and it's closed whether it was open or not.
Trying to close the menu automatically on timeline start if it's open, then hide the hamburger menu so it not possible to open again until I decide to show it back again using JavaScript.
So maybe I wasn't clear. I don't ask why you want to close it; I'm asking why you need to check if it's open. Close it when you start the timeline. If it's already closed, it doesn't change if you close it. Seems to me to be less work, and fewer moving parts. On the other hand, look at what you learned by trying it that way. Maybe it was worth it. :)
Your right, I don't need to check if it's open. I still had the toggle trigger still in mind so I had to check if it was open to trigger the toggle code.
var modernPlayerMenu = document.querySelector("#hamburger > div"); var isMenuOpen = ! document.body.classList.contains("sidebar-closed"); if (isMenuOpen) { modernPlayerMenu.click(); }
Do you know if it's possible to Disable the hamburger menu after hiding it using JavaScript? The "TAB" key can still open the menu even if it's not accessible via the mouse.
15 Replies
you can check if menu is closed with
Thank you.
This code is not working for some reason.
var modernPlayerMenu = document.querySelector("#hamburger > div");
var isMenuOpen = document.body.classList.contains("sidebar-open");
if (isMenuOpen) {
// The menu is open, so close it
if (modernPlayerMenu) {
modernPlayerMenu.click();
}
} else {
// The menu is already closed, do nothing
}
Just out of personal curiosity, if the menu is closed, does it hurt anything to close it? If not, why check? Just close it, and it's closed whether it was open or not.
Trying to close the menu automatically on timeline start if it's open, then hide the hamburger menu so it not possible to open again until I decide to show it back again using JavaScript.
try not "closed":
var isMenuOpen = ! document.body.classList.contains("sidebar-closed");
https://360.articulate.com/review/content/d1391023-8e8f-494b-ab82-c014b505f9df/review
You are the king.!! This is exactly what I was trying to build.
So maybe I wasn't clear. I don't ask why you want to close it; I'm asking why you need to check if it's open. Close it when you start the timeline. If it's already closed, it doesn't change if you close it. Seems to me to be less work, and fewer moving parts. On the other hand, look at what you learned by trying it that way. Maybe it was worth it. :)
Your right, I don't need to check if it's open. I still had the toggle trigger still in mind so I had to check if it was open to trigger the toggle code.
var modernPlayerMenu = document.querySelector("#hamburger > div");
var isMenuOpen = ! document.body.classList.contains("sidebar-closed");
if (isMenuOpen) {
modernPlayerMenu.click();
}
Do you know if it's possible to Disable the hamburger menu after hiding it using JavaScript? The "TAB" key can still open the menu even if it's not accessible via the mouse.
Ah, that makes sense. Thanks.
No, I can’t help with the hamburger menu. Sorry.
you can remove the hamburger button from the tab-key sequence with
and reactivate the old state with
if you want, you can also deactivate the hamburger menu (without hiding)
and reactivate with
Works perfectly. Thank you so much for your help. I was able to do exactly what I intended to do because of your help.
what would be he variable to change if I were to use the Top bar menu?
Is it possible open the notes with a javascript action?