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
Hi, Really sorry if I wasn't suppose to ask this question. But I really tried everything I could to center a node on render. But couldn't.
I saw the example on code sandbox. It is setting the dimention of tree container. I have also set dimention like that.
consthandleCenterUser=()=>{constuser=document.getElementById("isuser");if(user&&containerRef.current){const{ x, y }=user.getBoundingClientRect();const{ height, width }=containerRef.current.getBoundingClientRect();}};
I am able to get height and width of the container and the x & y cordinates of the node that I want to center. But I am unable to center the node using translate. When I translate using those cordinates I can't move the tree freely.
The text was updated successfully, but these errors were encountered:
Just weighing in to say, that I also want to be able to trigger centering/focus on a node externally. User clicks a "show me" button, and the tree centers on their node.
Any update on this? Implementing a "search" functionality and would need to A) open the search result node if it is closed, and B) need to center to it
The way I wound up doing it is making a list of all the nodes with a queryselector. Each node has a "transform" attribute that has the values you must subtract from the container values like so (and then pass in translate as the translate prop on the Tree)
Hi, Really sorry if I wasn't suppose to ask this question. But I really tried everything I could to center a node on render. But couldn't.
I saw the example on code sandbox. It is setting the dimention of tree container. I have also set dimention like that.
I am able to get height and width of the container and the x & y cordinates of the node that I want to center. But I am unable to center the node using translate. When I translate using those cordinates I can't move the tree freely.
The text was updated successfully, but these errors were encountered: