Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bug 615889] Add hover delay and decrease hide delay.

  • Loading branch information...
commit b7f845bfc0c9ae8e9d34edd6fbc49780e46810af 1 parent ceff6c7
@pcraciunoiu pcraciunoiu authored
Showing with 28 additions and 16 deletions.
  1. +1 −1  headerfooter.css
  2. +27 −15 menu.js
View
2  headerfooter.css
@@ -151,7 +151,7 @@ body {
opacity: 0;
}
-#nav-main li:hover ul,
+.no-js #nav-main li:hover ul,
#nav-main li.sfhover ul {
margin-top: 57px;
left: 0;
View
42 menu.js
@@ -1,27 +1,39 @@
/* Adds delay on hiding submenu of header */
// Use closure to avoid globals
(function () {
-var HIDE_TIMEOUT = 750, // hide timeout, in milliseconds
- SHOWING = 'sfhover', // CSS class for showing submenu
- showing = null, // reference to last parent showing its submenu
- timeout = null; // reference to timeout event from setTimeout
+var HIDE_TIMEOUT = 500, // hide timeout, in milliseconds
+ SHOW_TIMEOUT = 300, // show timeout, in milliseconds
+ SHOWING = 'sfhover', // CSS class for showing submenu
+ $showing = null, // reference to last parent showing its submenu
+ h_timeout = null, // reference to hide event from setTimeout
+ s_timeout = null; // reference to show event from setTimeout
$('#nav-main > ul > li').mouseover(function () {
+ var on_menu = (null !== $showing);
// Ensures only one submenu displays
- if (null !== showing) {
- showing.removeClass(SHOWING);
- showing = null;
- clearTimeout(timeout);
+ if (on_menu) {
+ $showing.removeClass(SHOWING);
+ $showing = null;
+ clearTimeout(h_timeout);
+ clearTimeout(s_timeout);
+ }
+ $showing = $(this);
+ // If already on menu, show right away. Else, show with delay. Rhyme!
+ if (on_menu) {
+ $showing.addClass(SHOWING);
+ } else {
+ s_timeout = setTimeout(function () {
+ $showing.addClass(SHOWING);
+ }, SHOW_TIMEOUT);
}
- // Fixes drop downs not showing on IE6
- $(this).addClass(SHOWING);
}).mouseout(function () {
- showing = $(this);
- showing.addClass(SHOWING);
+ // We're outta here, don't show anything that's been queued.
+ clearTimeout(s_timeout);
+ $showing = $(this);
// Hide submenu HIDE_TIMEOUT ms
- timeout = setTimeout(function () {
- showing.removeClass(SHOWING);
- showing = null;
+ h_timeout = setTimeout(function () {
+ $showing.removeClass(SHOWING);
+ $showing = null;
}, HIDE_TIMEOUT);
});
}());
Please sign in to comment.
Something went wrong with that request. Please try again.