Archived topic
Delay on hover over menu item
11 replies · Started by Patrick on April 12, 2015
Hello Tom,
is there a way to make the delay shorter for the submenu to drop down when you hover over a menu item?
Thank you
Hi Patrick,
The delay is handled by the hoverintent script - it's currently set to 500ms.
To remove the delay, you can add this function:
add_action( 'wp_print_scripts', 'generate_dequeue_scripts', 100 );
function generate_dequeue_scripts() {
wp_dequeue_script( 'hoverIntent' );
}
http://generatepress.com/knowledgebase/adding-php-functions/
Hope this helps :)
Hello Tom,
I added the code to the functions.php in my childtheme, but as far as I see nothing changed.
The reason why the delay is bad for me is, that I have noticed that people seem to click on MenuItem to have the dropdown, but then the page behind the item opens. So I hope when there is no delay people will notice the dropdown before clicking
Thank you
In that case, instead of creating an empty page for the parent item, just create a "Link" with the URL: #
You can do this in "Appearance > Menus" - you'll see the "Links" module on the left.
Using "#" as the URL will make it so clicking does nothing.
Let me know if that works for you or not :)
In that case, instead of creating an empty page for the parent item, just create a “Link” with the URL: #
No there is not an empty page, ther is some info on it.
For example Menuitem is Products with a page behind it which says what we offer and how. But if you hover over it you see all our products in the dropdown.
So what i have noticed is that people hover over the item for verry short until they think ok I have to click. Ususally clicking and dropdown happen at the same time, now they are surprised that a new page opens.
So I think I really need the no delay
But now your code is working ok!
Thank you verry much
Awesome! :)
Hi Tom,
same issue here but the code doesn't work for me, i think.
plugins/generate-simple-php/custom.php
<?php
/**
* All of your custom PHP can go in this file below this commented area
* Caution: Be sure to have access to your server via File Manager or FTP in case an error occurs
* Happy editing!
*/
add_action( 'wp_print_scripts', 'generate_dequeue_scripts', 1 );
function generate_dequeue_scripts() {
wp_dequeue_script( 'hoverIntent' );
}
But the delay is still there, set to 500.
Best,
Marco
Ah, things have changed.
Try adding this code into the wp_footer hook in GP Hooks:
<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>
Done. Works.
:-)
Thanks Tom!
You're welcome :)
Just a heads up that this jQuery function has been removed in GP 2.0 (being released this week).
The sub-menu uses CSS now, so it’s easier to adjust. Here’s an example: https://generatepress.com/forums/topic/disable-menu-animation-on-hover/#post-436051