[bug 615889] Add hover delay and decrease hide delay.
This commit is contained in:
Родитель
ceff6c726b
Коммит
b7f845bfc0
|
@ -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;
|
||||
|
|
42
menu.js
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);
|
||||
});
|
||||
}());
|
||||
|
|
Загрузка…
Ссылка в новой задаче