-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Cache the last mousemove event #1304
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
Changes from 5 commits
05e3687
5881ad5
18b36a6
99e718b
7df021e
bfaf905
77aa54c
9ad97e4
bfa5500
6711827
554d7ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,21 @@ fx.init = function(gd) { | |
xa._length, ya._length, 'ns', 'ew'); | ||
|
||
maindrag.onmousemove = function(evt) { | ||
// This is on `gd._fullLayout`, *not* fullLayout because the reference | ||
// changes by the time this is called again. | ||
gd._fullLayout._rehover = function() { | ||
if(gd._fullLayout._hoversubplot === plotinfo.id) { | ||
fx.hover(gd, evt, subplot); | ||
} | ||
}; | ||
|
||
// Track the hovered subplot. This prevents rehover from accidetally | ||
// reapplying a hover label after the mouse has left the plot or if | ||
// the mouse has entered another subplot. | ||
gd._fullLayout._hoversubplot = plotinfo.id; | ||
|
||
gd._fullLayout._rehover(); | ||
|
||
fx.hover(gd, evt, subplot); | ||
fullLayout._lasthover = maindrag; | ||
fullLayout._hoversubplot = subplot; | ||
|
@@ -129,6 +144,11 @@ fx.init = function(gd) { | |
maindrag.onmouseout = function(evt) { | ||
if(gd._dragging) return; | ||
|
||
// When the mouse leaves this maindrag, unset the hovered subplot. | ||
// This may cause problems if it leaves the subplot directly *onto* | ||
// another subplot, but that's a tiny corner case at the moment. | ||
gd._fullLayout._hoversubplot = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inset plots seem like a not-so-tiny corner case. But does this actually cause problems? Presumably There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, which happens first was the question. If mouseover and then mouseout, it would end up unset, but the only time that could happen is if you move exactly one pixel outside of the inset region, which is where it started to seem like a small corner case. The second pixel moved will immediately fix things. |
||
|
||
dragElement.unhover(gd, evt); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1934,7 +1934,11 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts) | |
} | ||
} | ||
|
||
var seq = [plots.previousPromises, interruptPreviousTransitions, prepareTransitions, executeTransitions]; | ||
function rehover() { | ||
plots.rehover(gd); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wrapper isn't necessary, as all the items get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, thanks. Wondered about that but assumed the opposite. |
||
|
||
var seq = [plots.previousPromises, interruptPreviousTransitions, prepareTransitions, rehover, executeTransitions]; | ||
|
||
var transitionStarting = Lib.syncOrAsync(seq, gd); | ||
|
||
|
@@ -2057,6 +2061,12 @@ plots.doCalcdata = function(gd, traces) { | |
} | ||
}; | ||
|
||
plots.rehover = function(gd) { | ||
if(gd._fullLayout._rehover) { | ||
gd._fullLayout._rehover(); | ||
} | ||
}; | ||
|
||
plots.generalUpdatePerTraceModule = function(subplot, subplotCalcData, subplotLayout) { | ||
var traceHashOld = subplot.traceHash, | ||
traceHash = {}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are this
fx.hover
andfullLayout._hoversubplot = subplot
still necessary then?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! Good catch. I change this back and forth and accidentally left both. Fixed in the commit below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Yeah, you're right. There's still an extra item or two there. Fixing (and looking at the full diff when doing so this time)