jquery - Queue, delay, stop queue -


i'm working on two-levels menu animation tabs: main menu tab items open tabbed sub-menus.

at load, default submenu opened, according current page location. user may choose open other subemenus browse through navigation. but, when user not care more of menu, default submenu should reappear after while match current location. code works correctly use:

$("#menu").mouseleave(function(){     settimeout(function(){         $("#menu").tabs( "option", "selected", index );},         2000);         });     }); 

here problem. if user comes on menu after timeout launched (in 2 seconds delay), default submenu appears anyway, may disturb user experience. great stop timeout when user comes menu.

i think better use queue, delay... don't know how since of documentation refers animation queuing...

thanks help...

you can stop started timeout cleartimeout, so:

var menutimeout; $("#menu").mouseleave(function(){  menutimeout = settimeout(function(){     $("#menu").tabs( "option", "selected", index );},     2000);     }); }); $("#menu").mouseenter(function(){   if(menutimeout) {       cleartimeout(menutimeout);   } }); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -