zesik / react-splitter-layout

A simple split layout for React and modern browsers. https://zesik.com/react-splitter-layout
MIT License
428 stars 131 forks source link

Is there a way to get the initial size from the rendered DOM ? #20

Open julienw opened 6 years ago

julienw commented 6 years ago

Hi,

I have a layout where I'd like to initially position the splitter using flex (with a flex-basis set to auto to make it dependant on its content). But currently it's not possible as SplitterLayout forcibly sets a calculated or provided height (or width), unless I missed something.

julienw commented 6 years ago

Maybe a way could be to accept an initialSize without appending the unit, so that we could use auto or even a calc-based value.

zesik commented 6 years ago

Hi,

Auto initial size is not supported now. And without units, size values won't be valid. I'll check whether this is possible when I get some time.

julienw commented 6 years ago

And without units, size values won't be valid.

Yes, I think about it only for the initial size, not for subsequent sizes (after manually resizing) that would be in px.

zesik commented 6 years ago

Yes, I think about it only for the initial size, not for subsequent sizes (after manually resizing) that would be in px.

I prefer not setting invalid values at any time. Maybe it's possible to ignore initial values at all for such cases. Will do some tests about it.

julienw commented 6 years ago

I thought we could provide an initial size that could be a full string, like calc(100vh - 120px) or auto. It's not invalid in this case.

But because the code forcefully appends px or % to the size, it's not possible.

zesik commented 6 years ago

I thought we could provide an initial size that could be a full string, like calc(100vh - 120px) or auto. It's not invalid in this case.

This might need quite a few changes due to how the splitter is currently is implemented. I'll consider whether it's our best option.