diff --git a/jquery.menu-aim.js b/jquery.menu-aim.js index 0c32941..78fab4b 100644 --- a/jquery.menu-aim.js +++ b/jquery.menu-aim.js @@ -95,12 +95,15 @@ exit: $.noop, activate: $.noop, deactivate: $.noop, - exitMenu: $.noop + exitMenu: $.noop, + exitDelay: 0 }, opts); var MOUSE_LOCS_TRACKED = 3, // number of past mouse locations to track DELAY = 300; // ms delay when user appears to be entering submenu + var mouseleaveTimer; + /** * Keep track of the last few locations of the mouse. */ @@ -120,15 +123,16 @@ clearTimeout(timeoutId); } - // If exitMenu is supplied and returns true, deactivate the - // currently active row on menu exit. - if (options.exitMenu(this)) { - if (activeRow) { - options.deactivate(activeRow); + mouseleaveTimer = window.setTimeout(function () { + // If exitMenu is supplied and returns true, deactivate the + // currently active row on menu exit. + if (options.exitMenu(this)) { + if (activeRow) { + options.deactivate(activeRow); + } + activeRow = null; } - - activeRow = null; - } + }, options.exitDelay); }; /** @@ -140,6 +144,8 @@ clearTimeout(timeoutId); } + window.clearTimeout(mouseleaveTimer); + options.enter(this); possiblyActivate(this); },