Skip to content

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

Merged
merged 2 commits into from
May 10, 2017

Conversation

monfera
Copy link
Contributor

@monfera monfera commented May 10, 2017

Issue reported by @alexcjohnson is #1662

@monfera monfera self-assigned this May 10, 2017
@monfera monfera requested a review from alexcjohnson May 10, 2017 17:47
@monfera monfera added status: reviewable bug something broken labels May 10, 2017
@@ -125,13 +125,14 @@ module.exports = function plot(gd, calcData) {

var linkHoverFollow = function(element, d) {

var rootBBox = gd.getBoundingClientRect();
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I'll check

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

x: hoverCenterX + window.scrollX,
y: hoverCenterY + window.scrollY,
x: hoverCenterX - rootBBox.left + window.scrollX,
y: hoverCenterY - rootBBox.top + window.scrollY,
Copy link
Collaborator

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?

Copy link
Collaborator

@alexcjohnson alexcjohnson left a 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. 💃

@monfera monfera merged commit 9d149c3 into master May 10, 2017
@monfera monfera deleted the sankey-fix-label-position-with-offset-div branch May 10, 2017 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants