nathancahill / split

Unopinionated utilities for resizeable split views
https://split.js.org/
MIT License
6.1k stars 448 forks source link

Option to set maxSize/minSize to % rather than px #762

Open CrumpetsNTea opened 1 year ago

CrumpetsNTea commented 1 year ago

Hi! I was wondering if it would be possible to set maxSize/minSize to a percentage value? I thought this would make sense, since the sizes option is measured in percentage. It would be far more convenient to have maxSize/minSize available to be set as a responsive measurement rather than px.

The primary issue with this is that when I resize the window, it causes a bug where I can no longer resize the columns, it just jumps to one size when I click the gutter. This is resolved by refreshing the page, however this is highly inconvenient. This is likely because of the pixel value changing on window resize. I do not believe this would happen if the value was percentage.

CrumpetsNTea commented 1 year ago

I was able to resolve this by having a resize event listener in a useEffect, which then updated a state variable with the window.innerWidth. I then used this state variable to set the minSize.

This makes minSize dynamically set to the appropriate size based on the window width, versus being hardcoded to a px value.

Ultimately, I believe being able to set the minSize/maxSize values to % rather than px would also resolve this.