javascript - fadeIn starts from the beginning after mouseleave (setTimeout) -


i looking solution navigation menu working. here jsfiddle can see working code.

the fadein effect needs happen on nav-item hover, happening while mouseleave bottom, left or right side of menu.

it looks want is: when move mouse tab tab, don't want fade-out , in happen.

in case, it's because you're not keeping track of whether or not menu open. should fading if menu not open, otherwise hide , show no fade.

code:

var timer; var ismenuopen = false; $('.nav-item').hover(     function() {         $('.subnav--main').hide();         $('.promoted-content--main').hide();         cleartimeout(timer);         if(ismenuopen){             $(this).find('ul').show();         }         else{             ismenuopen = true;             $(this).find('ul').fadein( 'slow' );         }     },     function() {         timer = settimeout(function() {             $('.subnav--main').fadeout( 'fast' );             $('.promoted-content--main').fadeout( 'fast' );             ismenuopen = false;         }, 1000);     } ); 

and jsfiddle: http://jsfiddle.net/qdafe3uw/


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -