views:

116

answers:

2

so I am using the .hover feature of jquery.. but im having a small issue. the drop downs stick and dont get hidden when yuo move the mouse over them very quickly (ff3). it seems like it is skipping the mouse out function if the previous function hadnt completed which is slideDown. anyway to fix this?

heres the test site: http://vasoshield.xcsit.com/index.html

the javascript:

 $(document).ready(function() {
    $('#mainNav ul li').hover(  
     function() {
      $(this).find('ul').slideDown(500);
     },
     function () {
      $(this).find('ul').hide(0);
     }
    );  
 });

menu html

<div id="mainNav">
 <ul>
  <li class="requestInfoLink">
   <a href="#">Request Info</a>
   <ul>
    <li><a href="#">Ordering</a></li>
    <li class="last"><a href="#">Contact Us</a></li>
   </ul>
  </li> 

  <li class="newsLink">
   <a href="#">News</a>
   <ul>
    <li class="last"><a href="#">Press Release</a></li>
   </ul>
  </li>
  <li class="productLink">
   <a href="#">Product</a>
   <ul>
    <li><a href="#">Overview</a></li>
    <li><a href="#">Physician</a></li>
    <li class="last"><a href="#">Patient</a></li>
   </ul>
  </li>    

 </ul>
</div>
A: 

Try hiding them in the $(document).ready for a start.

If not, then why not try .slideToggle()

I'm sure it's something small and dumb. Just try different things. I'd try the .slideToggle() first though. Or just .toggle()

Edit: I don't think the browser is liking the other function() on the hover.

Try making a blur event where it slides up. Should make for a more smooth and nicer looking result.

Michael Stone
im not sure why hiding it in the $(document).ready would resolve things. this only gets called ONCE right?
Roeland
Yes, but at the same time. if it's being hidden all the time ( with document.ready) then when you aren't hovering over it, it should be hidden.
Michael Stone
doing slideUp() instead of hide() fixed the problem
Roeland
I'm looking at the page now. You added a .hide() It's working because of that.
Michael Stone
The .hide() and the slideUp work. for viewing purposes. Maybe make it fade or slideUp("slow") it looks really fast at the moment. Just a thought. It's the little things like this that get me annoyed. I imagine you as well.
Michael Stone
A: 

I actually have a better working solution:

$(document).ready(function() {
$('#mainNav ul li').hover(  
    function() {
            $(this).find('ul').slideDown(500);
    },
    function () {
            $(this).find('ul').stop(false,true).hide(0);
    }
);          

});

So, on mouseout, it automatically STOPS the animation. STOP has two paramters, one of which clears all of the animation queue (not necessary), and the second for jumping straight to the end of the animation. In this case, you want to jump straight to the end of the animation and shut it down. This should remove all of your issues!

Jnicola