-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix issues related to panning to a node #824
Conversation
When a user selects a node that is out of view, the graph explorer pans to it and centers it. Unfortunately, this feature had some issues. 0. Panning happened before graph expansion completed. This led to pan target calculations that relied on incorrect, outdated measurements. We fix by waiting 250ms (the default duration for animations in the graph explorer) before panning in order to give enough time for node expansion to complete. 1. The graph explorer did not take into account the position of the graph's root SVG element with respect to the viewport. This led to panning calculations that were slightly off. We fix by taking that into account. 2. Nodes could sometimes be occluded by the minimap - those nodes are strictly speaking still in the view of the graph explorer, so we previously did not pan to nodes occluded by the minimap. Now, we do. There are still issues related to panning that are not fixed. For instance, we do not pan to extracted nodes. Panning sometimes yields a console error: ```js Error: <text> attribute x: Expected length, "NaN". ``` However, this PR does fix several big issues.
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 for this, @chihuahua! This is definitely improvement from before. But I am still seeing some buggy behavior, probably what this PR isn't intended to fix. I think we can check this in first (after addressing the other comment) and tackle the remaining issues later.
isOutsideOfBounds(pointTL.y, pointBR.y, svgRect.height)) { | ||
|
||
// Subtract to make sure that the node is not hidden behind the minimap. | ||
const horizontalBound = svgRect.left + svgRect.width - 320; |
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.
Is there a way to avoid these magic numbers?
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.
I moved the numbers to constants.
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.
Let me know what other issues you see! Indeed, lets resolve these issues first in this PR.
isOutsideOfBounds(pointTL.y, pointBR.y, svgRect.height)) { | ||
|
||
// Subtract to make sure that the node is not hidden behind the minimap. | ||
const horizontalBound = svgRect.left + svgRect.width - 320; |
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.
I moved the numbers to constants.
When a user selects a node that is out of view, the graph explorer pans
to it and centers it. Unfortunately, this feature had some issues.
Panning happened before graph expansion completed. This led to pan
target calculations that relied on incorrect, outdated measurements. We
fix by waiting 250ms (the default duration for animations in the graph
explorer) before panning in order to give enough time for node expansion
to complete.
The graph explorer did not take into account the position of the
graph's root SVG element with respect to the viewport. This led to
panning calculations that were off by a constant amount along the X and Y
dimensions. We fix by taking those 2 values into account.
Nodes could sometimes be occluded by the minimap - those nodes are
strictly speaking still in the view of the graph explorer, so we
previously did not pan to nodes occluded by the minimap. Now, we do.
Screenshot:
There are still issues related to panning that are not fixed. For
instance, we do not pan to extracted nodes.
Also, Panning sometimes yields a console error:
However, this PR does fix several big issues.