I made a (working) sub sub menu using html and normal boxes (containers) with buttons in it. It’s like this:
My one problem is, how can I add this to my header? Since that’s not quite working for me because the boxes are outside the header and I can’t stick it to the header.
enlarge the height the (and it’s ok if it goes out of the header boundaries) and put the text element/repeater inside.
P.S. I’m moving this thread to the Site and Design forum.
Hi you need to handle it differently. Something like:
let’s say you have buttons in the menu with ID like “menuCategory1”, “menuCategory2”, and you have submenu boxes with IDs like: “menuCategory1Box”, “menuCategory2Box”
@gerbergroen Hi, you don’t have to do it exactly as I suggested, but you should understand the concept: The challenge:
When you hover out of the menu, the boxes should collpase/hide. BUT if you move out of the menu to the sub-menu box itself, it should stay up. The solution:
When you hover over a box, mark this box as “clicked” and do not close it.
Here’s the code with comments:
$w.onReady(() => {
let menuCategories = ["menuCategory1", "menuCategory2", "meneCategory3"];//This is a list of the menu button IDs
let menuSelector = menuCategories.reduce((a,b) => a + "#" + b + ",", "");//This is a short way to write: "#menuCategory1, #menuCategory2, #menuCategory3" (the selector for the menu buttons)
let menuBoxSelector = menuCategories.reduce((a,b) => a + "#" + b + "Box,", "")
//This is the short way to write: "#menuCategory1Box, #menuCategory2Box, #menuCategory3Box" (the selector for the sub-menu box IDs)
$w(menuSelector).onMouseIn(event => {
$w("#" + event.target.id + "Box").expand();//Expand the correspondent sub-menu box
})
let menuBoxHovers = menuCategories.map(e => ({id:e, hovered: false});//Here you store the sub-menu hover status
$w(menuBoxSelector).onMouseIn(event => {
//Find the current hovered box:
const currentHovered = menuBoxHovers.find(e => e.id === e);
//Set its status to true:
currentClicked.hovered= true;
})
$w(menuSelector).onMouseOut(event => {
//when you hover out the menu button:
//Find the recently-left button:
const currentLeave = menuBoxHovers .find(e => event.target.id === e.split("Box").join("");
if(!currentLeave.hovered){
//Hide/collapse the box only if its boxed is not currently being hovered over:
$w("#" + event.target.id + "Box").collapse();
}
//Reset the status:
currentLeave.hovered= false;
})
$w(menuBoxSelector).onMouseOut(event => $w("#" + event.target.id).collapse());
})