Delay with hoverintent
Asked Answered
S

2

7
var config = {    
     sensitivity: 3,    
     interval: 5000,     
     timeout: 5000,    
};

$("#cart-summary").hoverIntent(function () {
        $('.flycart').slideDown('fast');
}, function() {
        $('.flycart').slideUp('fast');
}).find('a.close').click(function(){
   $(this).parents('.flycart').hide();
});

...this works, but two issues:

  1. It doesn't seem to wait 5 seconds like it should, opens almost instantly no matter what I Set.

  2. Affects all elements using the hoverintent plugin on the same page.

I'd really appreciate any help. Thanks!

Skillful answered 2/10, 2009 at 17:14 Comment(0)
M
8

You're not passing the config object to hoverIntent, so it's using defaults: http://cherne.net/brian/resources/jquery.hoverIntent.html

To clarify,

var config = {
     sensitivity: 3,
     interval: 5000,
     timeout: 5000
};

$("#cart-summary").hoverIntent(function () {
    $('.flycart').slideDown('fast');
}, function() {
    $('.flycart').slideUp('fast');
}).find('a.close').click(function () {
    $(this).parents('.flycart').hide();
}, config);
Mohr answered 2/10, 2009 at 17:23 Comment(1)
$("#cart-summary").hoverIntent(config, function() { ... ?Skillful
H
2

This might be more clearer

function liMouseOverTrigger() {
    $(this).addClass('hover');
}

function liMouseOutTrigger() {
    $(this).removeClass('hover');
}

function tabHoverDelay() {

        var config = {
            sensitivity: 1,
            interval: 100,
            timeout: 400,
            over: liMouseOverTrigger,
            out: liMouseOutTrigger
        },
            config2 = {
                sensitivity: 1,
                interval: 350,
                timeout: 600,
                over: liMouseOverTrigger,
                out: liMouseOutTrigger
            };


        $('.js-navTabHover li').each(function () {
            $(this).hoverIntent(config);
        });

        $('.js-navTabHoverContent li').each(function () {
            $(this).hoverIntent(config2);
        });

    }

$(document).ready(function () {
    tabHoverDelay();
});
Haines answered 3/9, 2014 at 9:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.