Skip to content

Commit

Permalink
Merge pull request #49 from usmonster/11-copy-current-mouse-coordinates
Browse files Browse the repository at this point in the history
copy current mouse coords to `over` handler event
  • Loading branch information
usmonster committed Nov 22, 2015
2 parents 057aa4e + d6d8a11 commit 46277f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jquery.hoverIntent.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ <h1>Known Defects</h1>

<h1>Release History</h1>
<ul>
<li>v1.9.0 = (2015) Refactored plugin to fix a long-standing bug that prevented multiple instances of the plugin to be active on the same element. Exports plugin as an <a href="http://requirejs.org/docs/whyamd.html">AMD</a> module so it can be used with AMD loaders.</li>
<li>v1.9.0 = (2015) Refactored plugin to fix a long-standing bug that prevented multiple instances of the plugin to be active on the same element. Exports plugin as an <a href="http://requirejs.org/docs/whyamd.html">AMD</a> module so it can be used with AMD loaders. The <code>pageX</code> and <code>pageY</code> properties of the event passed to the "over" handler now reflect current mouse position. Note that this may be a breaking change for some; if your "over" handler requires the unmodified coordinates from original mouseover, you can read them from the <code>event.originalEvent</code>.</li>
<li>v1.8.1 = (2014) Minor update: fixes bower.json to indicate that the plugin works with all versions of jQuery >= 1.9.1.</li>
<li>v1.8.0 = (2014) Changed to <a href="http://semver.org">Semantic Versioning</a> (from r8 to v1.8.0). Removed <a href="https://en.wikipedia.org/wiki/Zero-width_no-break_space">U+FEFF character</a> from beginning of JS file. Removed stray "jQuery" in favor of "$" for noConflict situations. Changed measurements to use euclidean (instead of rectilinear) distance. Thanks to <a href="https://github.com/briancherne/jquery-hoverIntent/graphs/contributors">the GitHub community</a> for patches, suggestions, and fixes!</li>
<li>r7 = (2013) Added event delegation via "selector" param/property. Added namespaced events for better isolation. Added handlerInOut support.</li>
Expand Down
8 changes: 5 additions & 3 deletions jquery.hoverIntent.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
// current X and Y position of mouse, updated during mousemove tracking (shared across instances)
var cX, cY;

// saves the current pointer position coordinated based on the given mouse event
// saves the current pointer position coordinates based on the given mousemove event
var track = function(ev) {
cX = ev.pageX;
cY = ev.pageY;
Expand All @@ -65,9 +65,11 @@
if ( Math.sqrt( (s.pX-cX)*(s.pX-cX) + (s.pY-cY)*(s.pY-cY) ) < cfg.sensitivity ) {
$el.off('mousemove.hoverIntent'+s.namespace,track);
delete s.timeoutId;
// set hoverIntent state as active for this element (so `out` handler can eventually be called)
// set hoverIntent state as active for this element (permits `out` handler to trigger)
s.isActive = true;
// clear coordinate data
// overwrite old mouseenter event coordinates with most recent pointer position
ev.pageX = cX; ev.pageY = cY;
// clear coordinate data from state object
delete s.pX; delete s.pY;
return cfg.over.apply($el[0],[ev]);
} else {
Expand Down

0 comments on commit 46277f2

Please sign in to comment.