Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have ability to set the scrollTop directly to Tree ref #194

Open
thomas-le183 opened this issue Nov 26, 2023 · 3 comments
Open

Have ability to set the scrollTop directly to Tree ref #194

thomas-le183 opened this issue Nov 26, 2023 · 3 comments

Comments

@thomas-le183
Copy link

Hello, I'm currently employing react-arborist for my Gantt chart. This library has a unique approach that restricts my ability to manipulate the Tree DOM, including setting the scrollTop property. Is there a way to synchronize scrolling between two different div elements in this context?

@jameskerr
Copy link
Member

You're right. It's not possible today. I'll consider adding this ability in a future release.

@vulevukusej
Copy link

Also interested :)

@vulevukusej
Copy link

My workaround in case anyone is interested (so far it works nicely):

function customScrollHandler(e: Event) {
     const target = e.target as HTMLElement;
     useGanttScroll.setState({ scrollPositionY: target.scrollTop });
 }
 
 useEffect(() => {
     const treeDiv = document.querySelector('[role="tree"]');
     if (treeDiv) {
         const child = treeDiv.firstChild as HTMLDivElement;
         child.addEventListener("scroll", customScrollHandler);
     }
 
     return () => {
         if (treeDiv) {
             const child = treeDiv.firstChild as HTMLDivElement;
             child.removeEventListener("scroll", customScrollHandler);
         }
     };
 }, []);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants