react-d3-tree icon indicating copy to clipboard operation
react-d3-tree copied to clipboard

Auto-centering inside treeContainer when tree is changed

Open LarsLiden opened this issue 6 years ago • 5 comments

Are you reporting a bug, or opening a feature request?

May be a feature request or just help with implementation

What is the actual behavior/output?

I'm centering the tree using the suggested method. The user then scrolls the page to select a node off to the side of the graph. I then replace the "data" element of the Tree with a smaller subsection of the entire tree. It renders correctly, but now the tree is in the old centered position which is outside of the window (so the user sees a blank screen)

What is the behavior/output you expect?

I'd like to reset the Tree's translation, however, getBoundingClientRect() does not appear to be updated even when I change the Tree's data field. Is there a way for me to cause this to be recalculated when the Tree is changed? Thank you!

What version of react-d3-tree are you using

1.12.2

LarsLiden avatar Mar 18 '19 16:03 LarsLiden

+1

yoyoyohamapi avatar Jul 05 '19 01:07 yoyoyohamapi

+1

erfling avatar Jul 24 '19 19:07 erfling

+1

balramkhichar avatar Aug 07 '19 12:08 balramkhichar

It's a bit of a trick, but I don't know if it might help.

    this.setState({ translate: { x: 0, y: 0 } });
    this.setState({
      translate: {
        y: 100,
        x: dimensions.width / 2
      }
    });

Parkseokje avatar Mar 04 '20 03:03 Parkseokje