Skip to content
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

Add delay (hover intent) to _mouseOverHandler and settings options #40

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
19 changes: 13 additions & 6 deletions js/jquery-accessibleMegaMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ limitations under the License.
panelGroupClass: "accessible-megamenu-panel-group", // default css class for a group of items within a megamenu panel
hoverClass: "hover", // default css class for the hover state
focusClass: "focus", // default css class for the focus state
openClass: "open" // default css class for the open state
openClass: "open", // default css class for the open state
mouseOverDelay: 0, // default delay in milliseconds to determine hover intent so menu doesn't drop when mouse is simply passing over the menu
mouseOutDelay: 250 // default delay in milliseconds when menu will close after mouse exits
},
Keyboard = {
BACKSPACE: 8,
Expand Down Expand Up @@ -647,11 +649,16 @@ limitations under the License.
* @private
*/
_mouseOverHandler = function (event) {
clearTimeout(this.mouseTimeoutID);
$(event.target)
var that = this;
$(event.target)
.addClass(this.settings.hoverClass);
_togglePanel.call(this, event);
if ($(event.target).is(':tabbable')) {

that.mouseTimeoutID = setTimeout(function () {
if ($(event.target).is(':hover')) { // if still hovering, then show menu...
_togglePanel.call(that, event);
}
}, this.settings.mouseOverDelay);
if ($(event.target).is(':tabbable')) {
$('html').on('keydown.accessible-megamenu', $.proxy(_keyDownHandler, event.target));
}
};
Expand All @@ -671,7 +678,7 @@ limitations under the License.

that.mouseTimeoutID = setTimeout(function () {
_togglePanel.call(that, event, true);
}, 250);
}, this.settings.mouseOutDelay );
if ($(event.target).is(':tabbable')) {
$('html').off('keydown.accessible-megamenu');
}
Expand Down