- This topic has 13 replies, 3 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
June 8, 2019 at 7:57 am #923427
Manuel
Hey there,
I’ve created a submenu (clicked version) with a few anchor links. When I’ve clicked on one of them, the submenu didn’t close. Any ideas how to fix it?
User: Tom
Password: GenerateBest regrds
ManuelJune 8, 2019 at 8:02 am #923431Leo
StaffCustomer SupportHi there,
Can you give this a shot?
https://generatepress.com/forums/topic/anchor-element-on-a-submenu-item/June 8, 2019 at 8:03 am #923433Manuel
Thanks for the very fast reply.
I’ve already tried that one. Doesn’t work.June 8, 2019 at 8:05 am #923434Leo
StaffCustomer SupportCan you try using Hover?
https://docs.generatepress.com/article/navigation-dropdown/June 8, 2019 at 8:06 am #923435Manuel
yeah, when I choose the “Hover Version” it works. But when it’s possible I want to use the “Clicked Version”.
June 8, 2019 at 9:24 am #923477Tom
Lead DeveloperLead DeveloperCan you try this PHP?:
add_action( 'wp_enqueue_scripts', function() { $script = " var deactivateSubMenuOnScroll = function() { var openSubMenus = document.querySelectorAll( 'nav .main-nav .menu-item-has-children .sub-menu.toggled-on' ), activeMenuItems = document.querySelectorAll( 'nav .main-nav .menu-item-has-children.sfHover' ); for ( var i = 0; i < openSubMenus.length; i++ ) { openSubMenus[i].classList.remove( 'toggled-on' ); } for ( var i = 0; i < activeMenuItems.length; i++ ) { activeMenuItems[i].classList.remove( 'sfHover' ); } }; document.addEventListener( 'scrollStart', deactivateSubMenuOnScroll, false ); "; wp_add_inline_script( 'generate-smooth-scroll', $script ); } );
Let me know ๐
June 8, 2019 at 10:23 am #923522Manuel
Thanks Tom!
When I’ve added the code via “Code Snippets” I got this message:The code snippet that you’re attempting to save has produced a fatal flaw on line 4:
syntax error, unexpected ‘nav’ (T_STRING)
The previous version of the snippet is unchanged and the rest of this website should work as normal before.June 8, 2019 at 7:16 pm #923706Tom
Lead DeveloperLead DeveloperSorry about that! Can you try the updated code?
June 8, 2019 at 9:14 pm #923740Manuel
Sorry Tom, didn’t work. No error message anymore but the submenu keeps still open after click.
June 9, 2019 at 7:42 am #924073Tom
Lead DeveloperLead DeveloperAh, sorry. That code assumed you were using the smooth scroll option in GP Premium.
Are you using a specific smooth scroll script/plugin? Or is it happening automatically with Elementor?
June 9, 2019 at 8:01 am #924096Manuel
It’s happening automatically with Elementor.
I’ve seen that your code assuming smooth scroll but even when I activate your smooth scroll script the code doesn’t work.
Wish I could deactivate the Elementor smooth scroll but I didn’t find a way to do that yet.June 9, 2019 at 8:04 am #924099Tom
Lead DeveloperLead DeveloperI don’t think they allow you to disable it for some reason.
I wonder if there’s an event listener we can hook into within their smooth scroll script? It might be worth asking them. We basically need some code to fire once the smooth scroll begins (or ends).
June 9, 2019 at 8:14 am #924107Manuel
Good idea, I’ll ask the Elementor support. If I get a useful hint I’ll post it here.
Thanks a lot, for your great work and always great support.June 9, 2019 at 9:42 am #924167Tom
Lead DeveloperLead DeveloperNo problem! If they have a listener we can hook into, I’m happy to help with the code ๐
-
AuthorPosts
- You must be logged in to reply to this topic.