Set timeout before hiding submenu

This commit is contained in:
ClemDee 2019-08-07 12:14:10 +02:00
parent 3191b3cbdd
commit 38e955e490

View File

@ -487,7 +487,9 @@ define([
var $el = $(el); var $el = $(el);
var $a = $el.children().filter("a"); var $a = $el.children().filter("a");
var $sub = $el.find(".dropdown-menu").first(); var $sub = $el.find(".dropdown-menu").first();
var timeoutId;
var showSubmenu = function () { var showSubmenu = function () {
clearTimeout(timeoutId);
$sub.toggleClass("left", $el.offset().left + $el.outerWidth() + $sub.outerWidth() > $(window).width()); $sub.toggleClass("left", $el.offset().left + $el.outerWidth() + $sub.outerWidth() > $(window).width());
$sub.show(); $sub.show();
}; };
@ -495,13 +497,16 @@ define([
$sub.hide(); $sub.hide();
$sub.removeClass("left"); $sub.removeClass("left");
}; };
var mouseOutSubmenu = function () {
timeoutId = setTimeout(hideSubmenu, 100);
}
// Add submenu expand icon // Add submenu expand icon
$a.append(h("span.dropdown-toggle")); $a.append(h("span.dropdown-toggle"));
// Show / hide submenu // Show / hide submenu
$el.hover(function () { $el.hover(function () {
showSubmenu(); showSubmenu();
}, function () { }, function () {
hideSubmenu(); mouseOutSubmenu();
}); });
// handle click event // handle click event
$el.click(function (e) { $el.click(function (e) {