Stop drive-by dropdown hovers

htt p://sa cr edsf.f inal sit e.c om/about

How can I make it so users must stay on the dropdown on the horizontal navigation for like, a second or so before the dropdown occurs? It is annoying right now that just drive-by’ing results in the page shift.

$("#fsHeader .fsBanner > .nav-main ul.fsNavLevel1 > li.fsNavParentPage").on("mouseenter",function() {
  var _self=this;
  $("#fsHeader .fsBanner > .nav-main").animate({
    "height":$("#fsHeader .fsBanner > .nav-main > .fsElementContent").outerHeight()
  $("#fsHeader .fsBanner > .nav-main").animate({
    "height":$("#fsHeader .fsBanner > .nav-main").outerHeight()+$(_self).find(">.fsNavPageInfo").outerHeight()

$("#fsHeader .fsBanner > .nav-main ul.fsNavLevel1 > li.fsNavParentPage").on("mouseleave",function() {
  $("#fsHeader .fsBanner > .nav-main").animate({
    "height":$("#fsHeader .fsBanner > .nav-main > .fsElementContent").outerHeight()

I know the JS could be improved (actually using the cached “this”, etc) but this was just a quick mockup I made a bit ago getting it to work.

Why not either a) make the menu overlay the picture (which stops the shift) or b) make the menu visible onClick (like SP does with theirs on the main site)

Unfortunately I do not have control over design aspects like this. This must be on hover and they wanted it to shift the page down :-/ .

Trust me, I do not like how it is set up now either.

How about a css transition delay.



Or use hover-intent plugin.

Due to the way this is set up, and the functionality of this (automated markup), I need JS to be the driving force behind this show/hide. I only change visibility via CSS (so you can’t see it overlaying) so I don’t think the transition delay would be of help, so I think I’ll need to mess around with the hover intent plugin. Thanks for that!

Yes the js can stay in place but the css delay will still take effect.

It appears that it’s screwing with the dropdown effect (albeit working in that aspect). You can see it live.

I tried putting the JS mouseenter in a setTimeout of 1 additional second, but that didn’t work. Also tried increasing the animation from 200, to 1200, but perhaps I’m missing something.

Perhaps this is better.

.fsNavigation{transition:height .5s ease 1s}

You also need to clear out the queue because the menu goes up and down a load of times if you run the mouse back and forth.

Could you provide more details about this?

Also, I did a separate transition delay for hovering on / off beceause when you hover off, I think it would be better for it to get closed faster. Let me know your thoughts! Thanks.

Before you call animate call .stop() so that any running animation is stopped otherwise they all chain and build up.

… -main").stop().animate(etc…

I actually just removed the animate() part a while ago and just did .css() because the CSS is handling the animation part of that. I was wondering if you were still seeing it, and if so, what you are doing to replicate it because I don’t.

I’m guessing you aren’t seeing it though because of my .css() change?

No, its ok now :smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.