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

Initial size based on content? #806

Open
dkozar opened this issue Nov 25, 2021 · 2 comments
Open

Initial size based on content? #806

dkozar opened this issue Nov 25, 2021 · 2 comments

Comments

@dkozar
Copy link

dkozar commented Nov 25, 2021

Hi,

I'd like to use the split pane in horizontal mode (first panel above, second one below).

When the split pane is mounted, I'd like to determine the top/bottom section sizes based on their contents (so there are no individual scrollbars apart from the page scrollbar).

Is this possible to do?

Thanks!

@cwellsx
Copy link

cwellsx commented Feb 9, 2024

It's possible.

  • React.useRef to get a ref which you associate with your element you want to measure.
  • React.useEffect to run some code after your component renders for the first time
  • In the useEffect, read the properties of the HTML element e.g. its clientHeight
  • Use that height, now that you know it, to set/reset the size of the pane
  • And maybe [once, setOnce = React.useState(false) which you use to ensure that you do the above only once/initially

@rickIsHere-199
Copy link

I'm searching similar, share if any body found it

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