-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixes hover tooltip position with non-origin div position #1664
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
Conversation
@@ -125,13 +125,14 @@ module.exports = function plot(gd, calcData) { | |||
|
|||
var linkHoverFollow = function(element, d) { | |||
|
|||
var rootBBox = gd.getBoundingClientRect(); |
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.
Can you use fullLayout.width
and fullLayout.height
or even fullLayout._size
instead? Those getBoundingClientRect
calls are expensive.
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.
thanks, I'll check
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.
... maybe I could use help for a low-latency fix :-) the code needs to know the positions, not just the width/height - having said this, the speed impact is likely negligible as it's only triggered on one element at a time. Yet if there's a need to quickly switch, I could use suggestions for getting the right position without a bbox call.
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.
this matches the pattern we've had to use elsewhere. It's possible that both getBoundingClientRect
calls could be avoided by figuring out the position directly from the link/node element (or by caching it in the element's d3 data or something) but if you use getBoundingClientRect
for one you'd better use it for both. That could be an optimization later, this is good for now.
src/traces/sankey/plot.js
Outdated
x: hoverCenterX + window.scrollX, | ||
y: hoverCenterY + window.scrollY, | ||
x: hoverCenterX - rootBBox.left + window.scrollX, | ||
y: hoverCenterY - rootBBox.top + window.scrollY, |
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 the window.scrollX/Y
shifts still necessary now that you're using a getBoundingClientRect
differential?
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.
Looks good! Thanks for the quick turnaround. 💃
Issue reported by @alexcjohnson is #1662