Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

Center first matched node on canvas

Burak Ozarslan5f6b97a1976b
diff --git a/src/hooks/useFocusNode.tsx b/src/hooks/useFocusNode.tsx
index 244be5ef..c53db98b 100644
--- a/src/hooks/useFocusNode.tsx
+++ b/src/hooks/useFocusNode.tsx
@@ -45,10 +45,12 @@ export const useFocusNode = () => {
const newPositionX =
(zoomPanPinch.offsetLeft - x) * newScale +
- firstMatchedNode.getBoundingClientRect().width;
+ zoomPanPinch.clientWidth / 2 -
+ firstMatchedNode.getBoundingClientRect().width / 2;
const newPositionY =
- (zoomPanPinch.offsetTop - y) * newScale +
- firstMatchedNode.getBoundingClientRect().height;
+ (zoomPanPinch.offsetLeft - y) * newScale +
+ zoomPanPinch.clientHeight / 2 -
+ firstMatchedNode.getBoundingClientRect().height / 2;
highlightMatchedNodes(matchedNodes);