Skip to content

improvement for getting correct submenu's height (when menu's height doesn't equal to submenu's) #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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