-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Enable Hover and Click Events Anywhere #7707
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
base: master
Are you sure you want to change the base?
Changes from all commits
5ab032d
8d4562a
a92246d
1eb8d6e
fb4ccbe
a981ca5
2ba5ddb
19ac09c
5ba0f25
78305ac
7868ae9
dae94d4
7dfecf6
e93310f
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 |
|---|---|---|
|
|
@@ -167,6 +167,9 @@ exports.loneHover = function loneHover(hoverItems, opts) { | |
| y1: y1 + gTop | ||
| }; | ||
|
|
||
| eventData.xPixel = (_x0 + _x1) / 2; | ||
| eventData.yPixel = (_y0 + _y1) / 2; | ||
|
|
||
| if (opts.inOut_bbox) { | ||
| opts.inOut_bbox.push(eventData.bbox); | ||
| } | ||
|
|
@@ -473,6 +476,12 @@ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) { | |
| } | ||
| } | ||
|
|
||
| // Save coordinate values so clickanywhere can be used without hoveranywhere | ||
|
Contributor
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. Should we only do this step if |
||
| gd._hoverXVals = xvalArray; | ||
| gd._hoverYVals = yvalArray; | ||
| gd._hoverXAxes = xaArray; | ||
| gd._hoverYAxes = yaArray; | ||
|
|
||
| // the pixel distance to beat as a matching point | ||
| // in 'x' or 'y' mode this resets for each trace | ||
| var distance = Infinity; | ||
|
|
@@ -778,6 +787,17 @@ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) { | |
| createSpikelines(gd, spikePoints, spikelineOpts); | ||
| } | ||
| } | ||
|
|
||
| if (fullLayout.hoveranywhere && !noHoverEvent && eventTarget) { | ||
| gd.emit('plotly_hover', { | ||
| event: evt, | ||
| points: [], | ||
| xaxes: xaArray, | ||
| yaxes: yaArray, | ||
| xvals: xvalArray, | ||
| yvals: yvalArray | ||
| }); | ||
| } | ||
|
Comment on lines
+791
to
+800
Contributor
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. It would be more maintanable to have this I realize we do want to keep the early Maybe you could add a |
||
| return result; | ||
| } | ||
|
|
||
|
|
@@ -877,6 +897,9 @@ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) { | |
| y0: y0 + gTop, | ||
| y1: y1 + gTop | ||
| }; | ||
|
|
||
| eventData.xPixel = (_x0 + _x1) / 2; | ||
| eventData.yPixel = (_y0 + _y1) / 2; | ||
| } | ||
|
|
||
| pt.eventData = [eventData]; | ||
|
|
@@ -914,9 +937,10 @@ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) { | |
| } | ||
|
|
||
| // don't emit events if called manually | ||
| if (!eventTarget || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return; | ||
| var _hoverChanged = hoverChanged(gd, evt, oldhoverdata); | ||
| if (!eventTarget || noHoverEvent || (!_hoverChanged && !fullLayout.hoveranywhere)) return; | ||
|
|
||
| if (oldhoverdata) { | ||
| if (oldhoverdata && _hoverChanged) { | ||
|
Contributor
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. Does this mean that when |
||
| gd.emit('plotly_unhover', { | ||
| event: evt, | ||
| points: oldhoverdata | ||
|
|
||
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.
@alexshoe what's the purpose of these lines?