- This topic has 13 replies, 3 voices, and was last updated 5 years, 1 month ago by Tom.
-
AuthorPosts
-
March 14, 2019 at 11:05 am #839098Ronald
Hi Tom a/o colleagues,
I’m using the GeneratePress .mega-menu layout for the navigation, with a fairly big menu that occupies most of the screen width, and big sub-menus under each item.
That means that when the cursor moves from the header down to the page, it will always pass over an item in the navigation menu and open its sub-menu: this sub-menu was not intended to be opened by the user, but when open it fills a large part of the screen, and for many people this is confusing when they actually just wanted to scroll down the page.
Is it possible to have delay before opening the sub-menu? Say for example that the cursor has to stand on top of the parent item for 500ms before the sub-menu opens?
Kind regards,
Ronald PostmaMarch 14, 2019 at 3:16 pm #839255LeoStaffCustomer SupportHi there,
Give this a shot:
.main-navigation ul ul { transition: opacity 500ms linear; }
March 15, 2019 at 12:21 am #839436RonaldHi Leo,
Thanks for your reply, but this is just an animation delay; the sub-menu still opens directly. So when hovering down from the header to the page, the issue still occurs.
I read in older forum posts that Tom had written a script for this delay:
https://generatepress.com/forums/topic/drop-down-menu-speed/#post-164348<script> jQuery( window ).load( function() { jQuery( '.sf-menu .menu-item-has-children' ).GenerateDropdownMenu.destroy(); jQuery( '.sf-menu .menu-item-has-children' ).GenerateDropdownMenu({ transition_speed: 0, open_delay: 0, close_delay: 0 }); }); </script>
This no longer seems to work, was this perhaps replaced with another script?
Regards,
RonaldMarch 15, 2019 at 9:58 am #840047TomLead DeveloperLead DeveloperThe menu no longer uses javascript at all – it’s 100% CSS.
It looks like you’ve switched the menu to open on click. Is that a better solution for you?
Let me know ๐
March 18, 2019 at 1:38 am #841890RonaldHi Tom,
The open on click is not a bad solution, though I would have preferred the hover option with a delay before opening the submenu. I understand this is not possible out of the box if there is no JS involved anymore; however if there is an easy way to introduce this I’d love to know about it.
Thank you,
RonaldMarch 18, 2019 at 5:46 pm #842767TomLead DeveloperLead DeveloperI would have tried the same
transition-delay
method Leo mentioned. That should prevent the menu from being visible for however long you set the delay.Otherwise, a javascript solution may be necessary.
March 19, 2019 at 1:35 am #842986RonaldHi Tom,
Thanks for the reply; I don’t want to press on with this too much, but just to explain the issue again, as it can not be solved with CSS:
If a user hovers from the header down to the page and randomly passes by a nav item, it will instantly trigger the nearly full-screen mega-menu sub-menu to open. The
transition-delay
will only delay the visibility, but the mega-menu sub-menu will still load and cover the screen anyway even when not intended, creating confusion with users.That is why a javascript open-delay solution would greatly improve the UX of the full-width nav with GP mega-menu. For lack of this solution I will use the click on open, but if you have a script that could work with the current GP navigation I would appreciate using it a lot!
March 19, 2019 at 9:11 am #843514TomLead DeveloperLead Developertransition-delay
shouldn’t actually open the menu unless the mouse stays on top of it: https://codepen.io/jhogue/pen/payujMarch 25, 2019 at 1:38 am #848806RonaldHi Tom,
transition-delay does open the sub-menu, regardless of it showing. See https://vimeo.com/326288834 for a screen capture of the codepen you shared. I made the delay 3 seconds, to show that if the user moves over the menu item, the sub-menu will load anyway and prevent the user from viewing/interacting with the page below the nav menu.
Obviously this is exaggerated with 3 seconds, but with the gp mega-menu I believe it is important to be able to set a delay before the opening the sub-menu, because a full-screen sub-menu will confuse/annoy people when they did not intend to open it.
I hope the issue is clear and that perhaps you agree this is worth solving.
Kind regards,
RonaldMarch 25, 2019 at 10:00 am #849388TomLead DeveloperLead DeveloperAh yes, that’s because the delay is set to the opacity, but the positioning of the menu (
top
). So thetop
value updates immediately, which means if your mouse is still on top of the invisible element,transition-delay
still does its thing.In GP, this might work:
.main-navigation ul ul { transition: opacity 500ms linear, left 0s ease; } .dropdown-hover .main-navigation:not(.toggled) ul li:hover > ul, .dropdown-hover .main-navigation:not(.toggled) ul li.sfHover > ul { transition-delay: 3s; }
March 25, 2019 at 12:22 pm #849537RonaldHi Tom,
Unfortunately this does not work, it still just delays the
opacity
, but as long as the mouse stays in the area that the sub-menu will occupy after thetransition-delay
it still loads anyway. I want it to only load when the mouse stays on top of the parentli
element, not below it. Sort of like this:
https://www.w3schools.com/code/tryit.asp?filename=G2FOTCD3IYD0Not literally like that with the width, but how it behaves regarding hovering: how it does not continue growing when the mouse moves out of the red area.
On https://www.mamotok.net/sma/ I’ve made the sub-menu again to activate on hover and not on click, so you can see the ‘problem’ of when you hover down from the header into the page over the navigation menu and instantly open a nearly full screen (especially on smaller screens) sub-menu, like the item ‘Behandeling’ for example.
I’ve added your CSS so you can see what it does.
March 25, 2019 at 4:19 pm #849736TomLead DeveloperLead DeveloperIn your custom CSS, find this:
nav .main-nav .mega-menu > ul { position: absolute; width: calc(100% - 100px); padding: 15px 50px 30px 50px; left: 0 !important; border-bottom: 10px solid var(--green1); border-top: 4px solid var(--green1); }
And remove this:
left: 0 !important;
Then, add this:
.dropdown-hover .main-navigation:not(.toggled) ul li:hover>ul, .dropdown-hover .main-navigation:not(.toggled) ul li.sfHover>ul { left: 0 !important; }
March 26, 2019 at 12:25 am #849952RonaldThat’s fantastic Tom, it works perfectly!
Thank you very much, I really appreciate your help and the patience with which you followed up this thread!
Regards,RonaldMarch 26, 2019 at 8:05 am #850480TomLead DeveloperLead DeveloperGlad I could help! ๐
-
AuthorPosts
- You must be logged in to reply to this topic.