views:

33

answers:

1

I have an html link that has uses hover() (well, the hoverIntent plugin...but same difference) to trigger a div to slidedown (I animate the CSS top attribute).

This all works and looks perfectly, except that when the mouse moves off of the hyperlink and onto the div that contains the menu links, it immediately triggers the mouseleave event and the menu vanishes.

Obviously, I felt kind of stupid after tweaking it endlessly before noticing this "bug".

The problem is: I can't really figure out a way to achieve the effect I want.

Here is a link to my work: http://clifgriffin.com/blockade

How would you, oh experts, accomplish what I'm trying to do?

I tried to separate the mouse enter and mouse leave functions...adding the former to the link and the latter to the div, but this doesn't work quite right, and even if I solved that quirk, it wouldn't trigger mouse leave properly when you hover the link and then move up.

Basically, as long as moving the mouse from the link to the menu doesn't trigger mouseleave, I'd be fine.

I really do not want to set a boolean for each menu, and setup a bunch of events on every element surrounding the menus to trigger certain actions. This has to be simpler than that.

Any ideas?

Thanks in advance, Clif

A: 

try this:

var accoIn = function(){
 topSlideIn($("#top_menu_slideout .aco"));
 $("#top_menu_links .accommodations").unbind("mouseover");      
};

$("#top_menu_links .accommodations").hoverIntent(accoIn,function(){});

$("#top_menu_slideout .aco").hoverIntent(function(){},function(){
 topSlideOut($("#top_menu_slideout .aco"));     
 $("#top_menu_links .accommodations").hoverIntent(accoIn,function(){});
});
Balint Pato
That actually works very well. Sliding up from the link that triggers the slideout obviously doesn't trigger it to retract, but I can take care of that by binding some events to the top div. Thank you. This is kind of like what I had in mind, but much more elegant.
clifgriffin
Ok, still having troubles getting this working perfectly.Basically, I need any hover over #top_hide to cause an expanded menu to retract. I also need any hover over menus other than the expanded one to cause the same effect. I tried to do this by:a) Setting global lastTrigger to the current menu when it slides down.b) Retracting lastTrigger when #top_hide is hovered. c) Retracting lastTrigger when any other menu item is hovered over.d) Readding events at various stages similar to your code.But, I'm having weird behavior. And the code is getting a bit out of hand. Any ideas?Clif
clifgriffin
ok, i'll check it out tomorrow...the main problem is that this tabbed structure is not really compatible with the "philosophy" of the hoverIntent structure. Think about redesigning it...
Balint Pato
I actually was able to solve this by setting a timer. Timer retracts menu automatically after 1 second. Hovering over menu div cancels timer. I agree...this is a messy approach, but it is working at least. I'm finding webkit browsers to be inconsistent in the way they handle the events though...going to be fun figuring that out. :(
clifgriffin
Glad to see you stepped forward :) This timer thing smells like hack as well, but at least it's working. Yeah, browser inconsistency is a nice thing to swallow.
Balint Pato
Timer ended up being way too big of a hack.I redid the menu using a container div for each menu. Inside that container was the title of the menu and the actual menu slideout div. This latter div is anchored to the bottom of the containing div.When you hover over the div, it expands to its full height (as recorded in the "original_height" attribute I add at page load). When you mouse out, it retracts to a predefined height. Everything else was just CSS. Works beautifully. :)
clifgriffin