javascript - Mouse leave event keeps firing in navigation menu -


here link item in question: http://www.nychukdesign.com/uploads/dynamic-top-bar-nav-menu.html

all html, javascript , css in 1 html file

functionality description: simple dynamic horizontal navigation bar intended disappear when user scrolls down page, in trigger activated when user mouses area, of slides down , reappears, , disappears once more upon mousing out. when user scrolls top navigation returns it's default (static) state...which problem comes in.

problem description: (and yes can not re-create problem every time) when return top of page, , navigation returns it's default state, when mouse leaves area (without scrolling down again) navigation slide , disappear. sometime happen on first try, after several, , in firefox 2.0, although have had happen once or twice in safari.

my thoughts: baffled this, , why seeking help. advice appreciated.

to re-create problem update: discovered how re-create problem. must scroll down , trigger menu @ least once, before scrolling top, in mousing on menu reason make disappear.

code:

<script type="text/javascript"> // use short notation of dom ready  $(function(){  // assign variables menu, trigger , menu position (relative document) var menu = $('#menu'),     menutrigger = $('#menu-trigger'),     pos = menu.offset();      // listen scroll event     $(window).scroll(function(){         // if scroll past position of menu's height , has it's default style, hide menu.          if($(this).scrolltop() > pos.top+menu.height() && menu.hasclass('default')){             menu.fadeout('fast', function(){                   // remove default class , replace fixed class                   $(this).removeclass('default').addclass('fixed');              });             // initiate trigger show , hide menu mouse event                    $(menutrigger).removeclass('hidden').addclass('block').mouseenter(function(){                 $(menu).slidedown('fast').mouseleave(function(){                 $(menu).slideup('fast');                 });                 });         // if scroll top , menu has fixed class, fadein menu         } else if($(this).scrolltop() <= pos.top && menu.hasclass('fixed')){             menu.fadein('fast', function(){                 // hide trigger                 $(menutrigger).removeclass('block').addclass('hidden');                  // give menu default style                 $(this).removeclass('fixed').addclass('default');             });         }     });  }); </script> 


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -