From ecb48c9149aa3d647095667744344253403c5e33 Mon Sep 17 00:00:00 2001 From: Tucker Bickler Date: Mon, 29 Apr 2013 17:47:59 -0500 Subject: [PATCH] Added tolerance support for submenus positioned above and below the main menu. --- jquery.menu-aim.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/jquery.menu-aim.js b/jquery.menu-aim.js index 0c32941..4ce27e6 100644 --- a/jquery.menu-aim.js +++ b/jquery.menu-aim.js @@ -205,7 +205,7 @@ var offset = $menu.offset(), upperLeft = { x: offset.left, - y: offset.top - options.tolerance + y: offset.top }, upperRight = { x: offset.left + $menu.outerWidth(), @@ -213,7 +213,7 @@ }, lowerLeft = { x: offset.left, - y: offset.top + $menu.outerHeight() + options.tolerance + y: offset.top + $menu.outerHeight() }, lowerRight = { x: offset.left + $menu.outerWidth(), @@ -230,6 +230,21 @@ prevLoc = loc; } + // Adjust the corner points to enable tolerance. + if (options.submenuDirection == "right") { + upperRight.y -= options.tolerance; + lowerRight.y += options.tolerance; + } else if (options.submenuDirection == "left") { + upperLeft.y -= options.tolerance; + lowerLeft.y += options.tolerance; + } else if (options.submenuDirection == "above") { + upperLeft.x -= options.tolerance; + upperRight.x += options.tolerance; + } else if (options.submenuDirection == "below") { + lowerLeft.x -= options.tolerance; + lowerRight.x += options.tolerance; + } + if (prevLoc.x < offset.left || prevLoc.x > lowerRight.x || prevLoc.y < offset.top || prevLoc.y > lowerRight.y) { // If the previous mouse location was outside of the entire