fix: add centerNode to demo, fix 'horizontal' Orientation bug #384
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes two issues
Add Center Nodes on Click button to demo application
I used the same
Switch
component as the other toggle buttons to create this addition. When clicked, the tree will be centered on a node when it is clicked using thedimensions
tree prop.Fixed the
horizontal
orientation centering bugAfter testing the new
centerNode
function more thoroughly, I noticed a slight bug with the way we calculate the new x,y coordinates for thehorizontal
orientation.Before, we were simply flipping x and y if the orientation was horizontal, but still adding width and height the same. But if we flip x and y, we must also flip the dimension we are adding the original coordinate.
So instead of this for horizontal:
we must do this for horizontal:
This PR takes care of those two issues.