2009-10-02 8 views
5
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(); 
}); 

... questo funziona, ma due problemi:ritardo con hoverIntent

  1. E non sembra attendere 5 secondi come dovrebbe, si apre quasi istantaneamente, non importa quello che ho impostato.

  2. Influisce su tutti gli elementi che utilizzano il plugin hoverintent nella stessa pagina.

Apprezzerei davvero qualsiasi aiuto. Grazie!

risposta

6

Non stai passando l'oggetto di configurazione per hoverIntent, quindi è utilizzando le impostazioni predefinite: http://cherne.net/brian/resources/jquery.hoverIntent.html

Per chiarire,

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); 
+0

$ (" # cart-summary "). hoverIntent (config, function() {...? – 3zzy

1

Questo potrebbe essere più chiara

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(); 
});