You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: Focus graph on a node
It is now possible to set a "focusedNodeId" to the graph, which will
result in the selected node appearing on the center of the displayed
area of the graph.
Optionally, aside from centering the view on it, a certain zoom can be
applied while the node is focused on screen. No zoom is applied by
default, but that behaviour can be configured by using the new
"focusZoom" parameter in the config object. This setting should receive
a number with the zoom level to apply, so the larger it is, the bigger
the node will appear on screen.
* feat: Node focus feature example added to sandbox
* fix: Ensure that focusZoom is between minZoom and maxZoom
* fix: Avoid issue with id datatypes when searching for focused node
* refactor: Improve readability for focusZoom bounds
Nested ternary expressions replaced by a more readable if-else
expression when checking if the `focusZoom` property set by the user is
between the configured `minZoom` and `maxZoom`.
* refactor: Remove statements in library code
* revert: Removed blank lines in DOCUMENTATION.md
* docs: Added more information on focusZoom property
* feat: Customize focus animation length
* refactor: focusNodeId wrapped in data props
Instead of being a prop on its own, the 'focusedNodeId' must now be
included as part of the 'data' object received by the Graph component.
The sandbox code has been update to reflect this change.
* refactor: focus transformation function moved to graphHelper
The 'getCenterAndZoomTransformation' has been rellocated to the graph
helper file, instead of being part of the Graph component.
* docs: Updated jsdoc for getCenterAndZoomTransformation
* refactor: Renamed config param for focus animation duration
* test: Graph snapshot updated
* fix: Consider hidden links when obtaining matrix
The link matrix was not been properly updated when the collapsible
setting was enabled. This is because when obtaining its values it didn't
check whether the different links were hidden or not.
This change fixes the issue and prevents the link matrix from containing
wrong values which cause orphan nodes are not hidden properly during
collapse.
* fix: Reset transition duration after focus animation
The transition duration property was been applied to the graph container
at all times, which affected to every other transformations that
triggered on it. This included the default zoom or the drag and drop
functionality, among others.
In order to fix this, that transition duration value is set back to zero
after the focus and zoom animation has finished. Some actions on the
node do also cancel the animation in case it's still ongoing, like
trying to drag a node.
With this change, there's no longer a delay when moving a node to
another location or while performing a zoom.
* test: Graph snapshot updated with default transition duration
* fix: Drag & drop in focused node
There was an issue with the drag and drop feature when used along the
focus and zoom transformation.
The problem was that we were recalculating the transformation everytime
the page was rendered, which meant that a new transform value would be
created anytime the node moved to a new position.
This issue only affected the focused node itself, since the
`getCenterAndZoomTransformation` did only depend on that node
coordinates.
To avoid abnormal behaviours, the transformation is only obtained when the graph receives props. By doing this, the current view position is preserved until a new focused node is set. If the user drags the node around, current zoom and position will be unaffected by it. This matches the default behaviour we encounter in any other scenario, when moving any other nodes or not having activated the focus and zoom feature.
* refactor: Reset transition duration on drag start
The `enableFocusAnimation` property in Graph' state is now set to
`false` in the `dragStart` event instead of during `dragMove`. This
change should have a positive impact in the application's perfomance, as
the `enableFocusAnimation` value will only checked once instead of being
read in every position change during a drag operation.
* style: Added blank line after variable declaration
* chore: Browser environment added to ESLint config
* refactor: getCenterAndZoomTransformation receives d3Node object
* fix: Node not centered when focusing with zoom
One of the latest changes broke the focus feature in certain scenarios.
When a focus zoom different from one was applied, the view was not
properly centered in the selected node. The transformation obtained in
the 'getCenterAndZoomTransformation' did not work as expected. Applying
a single translate before scaling didn't seem to do the trick, and the
second translate is necessary for the view to display the selected node
in the center after scaling the graph.
* refactor: Store focusedNodeId in Graph component state
0 commit comments