Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions jquery.menu-aim.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@
mouseLocs = [],
lastDelayLoc = null,
timeoutId = null,
leaveMenuTimeoutId = null,
options = $.extend({
rowSelector: "> li",
submenuSelector: "*",
submenuDirection: "right",
submenuMaxHeight: $(this).outerHeight(), // submenu maximum height
tolerance: 75, // bigger = more forgivey when entering submenu
enter: $.noop,
exit: $.noop,
Expand All @@ -116,6 +118,13 @@
* Cancel possible row activations when leaving the menu entirely
*/
var mouseleaveMenu = function() {
// don't deactivate if mouse is moving to submenu, delay and check again later
var delay = activationDelay();
if(delay){
leaveMenuTimeoutId = setTimeout(function() {
mouseleaveMenu();
}, delay);
} else {
if (timeoutId) {
clearTimeout(timeoutId);
}
Expand All @@ -127,8 +136,12 @@
options.deactivate(activeRow);
}

activeRow = null;
activeRow = null;
}

}


};

/**
Expand All @@ -139,6 +152,9 @@
// Cancel any previous activation delays
clearTimeout(timeoutId);
}
if(leaveMenuTimeoutId) {
clearTimeout(leaveMenuTimeoutId);
}

options.enter(this);
possiblyActivate(this);
Expand Down Expand Up @@ -208,16 +224,16 @@
y: offset.top - options.tolerance
},
upperRight = {
x: offset.left + $menu.outerWidth(),
x: offset.left + $menu.find(options.rowSelector).outerWidth(),
y: upperLeft.y
},
lowerLeft = {
x: offset.left,
y: offset.top + $menu.outerHeight() + options.tolerance
},
lowerRight = {
x: offset.left + $menu.outerWidth(),
y: lowerLeft.y
x: upperRight.x,
y: offset.top + options.submenuMaxHeight + options.tolerance
},
loc = mouseLocs[mouseLocs.length - 1],
prevLoc = mouseLocs[0];
Expand Down