Skip to content

add exitMenu delay #83

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 2 commits 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: 15 additions & 9 deletions jquery.menu-aim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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);
};

/**
Expand All @@ -140,6 +144,8 @@
clearTimeout(timeoutId);
}

window.clearTimeout(mouseleaveTimer);

options.enter(this);
possiblyActivate(this);
},
Expand Down