A lightweight yet useful jQuery user intent detection plugin to extend the jQuery’s hover method that delays the handlerIn function until the user actually wants to hover over a specific element. Great for preventing the accidental firing of hover events when the mouse pointer enters and leaves the elements.
How to use it:
// The number of milliseconds hoverIntent waits between reading/comparing mouse coordinates.
// When the user's mouse first enters the element its coordinates are recorded.
// The soonest the "over" function can be called is after a single polling interval.
// Setting the polling interval higher will increase the delay before the first possible "over" call, but also increases the time to the next point of comparison.
// If the mouse travels fewer than this number of pixels between polling intervals, then the "over" function will be called.
// With the minimum sensitivity threshold of 1, the mouse must not move between polling intervals.
// With higher sensitivity thresholds you are more likely to receive a false positive. Note that hoverIntent r7 and earlier perform this comparison using rectilinear distance, whereas more recent versions compare against Euclidean (straight-line) distance for better accuracy and intuition.
// If you are upgrading from an older version, you may want to verify that the desired behavior is preserved.
// A simple delay, in milliseconds, before the "out" function is called.
// If the user mouses back over the element before the timeout has expired the "out" function will not be called (nor will the "over" function be called).
// This is primarily to protect against sloppy/human mousing trajectories that temporarily (and unintentionally) take the user off of the target element... giving them time to return.
v1.10.1: Fixes a possible race condition by checking for hoverIntent data before attempting to access it
This awesome jQuery plugin is developed by briancherne. For more Advanced Usages, please check the demo page or visit the official website.