javascript - jquery menu slideshow verify hover function -
i have been trying tune menu slideshow , have part of code shown below have each of 4 items in menu respectively. made if move cursor on given menu item corresponding div shown in display. added timeout if moved 1 menu item doesn't switch 1 div quickly. question have make work desired how make checks whether cursor still hovering on given menu item after 200 milliseconds example before switching menu item? comments or appreciated. thanks.
$("div#menu .reps").hover(function() { window.cleartimeout(timeoutid); timeoutid = window.settimeout(hoverfunctionreps, 280); }); function hoverfunctionreps(){ if(current_slide != "reps"){ $(".arrow").animate({"left":"135px"}); if(current_slide == "clients"){ $(".clients_display").stop(true,true).fadeout().hide(); $(".reps_display").fadein().show(); current_slide = "reps"; } else if(current_slide == "services"){ $(".services_display").stop(true,true).fadeout().hide(); $(".reps_display").fadein().show(); current_slide = "reps"; } else{ $(".training_display").stop(true,true).fadeout().hide(); $(".reps_display").fadein().show(); current_slide = "reps"; } } }
perhaps this:
http://jsfiddle.net/lucuma/zgnkg/
var timeoutid;
$(document).ready(function() { $("a").hover(function() { window.cleartimeout(timeoutid); $(this).data('hashover', '1'); var = this; timeoutid=window.settimeout( (function() { hoverfunctionreps(that); }), 280); }, function() { $('span', this).hide(); $(this).data('hashover', '0'); }); function hoverfunctionreps(me) { if ($(me).data('hashover') == '1') { $('span', me).show(); } } });
Comments
Post a Comment