[Resolved] Delay on hover over menu item

Home Forums Support [Resolved] Delay on hover over menu item

Home Forums Support Delay on hover over menu item

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #98148
    Patrick

    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

    #98288
    Tom
    Lead Developer
    Lead Developer

    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 ๐Ÿ™‚

    #98918
    Patrick

    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

    #98919
    Tom
    Lead Developer
    Lead Developer

    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 ๐Ÿ™‚

    #98953
    Patrick

    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

    #99026
    Patrick

    But now your code is working ok!

    Thank you verry much

    #99143
    Tom
    Lead Developer
    Lead Developer

    Awesome! ๐Ÿ™‚

    #193704
    Marco

    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

    #193803
    Tom
    Lead Developer
    Lead Developer

    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>
    #195294
    Marco

    Done. Works.
    ๐Ÿ™‚
    Thanks Tom!

    #195383
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

    #441851
    Tom
    Lead Developer
    Lead Developer

    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

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.