react-split-pane
react-split-pane copied to clipboard
If I set the pane1Style width style, the resizer stop working
trafficstars
By setting the panel1 style I can no longer resize the panels.
My config
const showIframe = <condition_to_whether_show_panel_2>;
let splitPos = localStorage.getItem('splitPos');
splitPos = splitPos
? parseInt(splitPos, 10).toString()
: showIframe ? '50%' : '100%';
<SplitPane
split="vertical"
minSize={300}
allowResize={showIframe}
onDragStarted={() => setIsDragging(true)}
onDragFinished={() => setIsDragging(false)}
defaultSize={splitPos}
pane1Style={{width: showIframe ? '50%' : '100%'}}
pane2Style={{width: showIframe ? '50%' : '0'}}
onChange={(size: number) => localStorage.setItem('splitPos', size.toString())}
>
<Pane id="pane1"></Pane>
<Pane id="pane2"></Pane>
</SplitPane>
I came up with the same problem, one solution is that when isDragging is true, you set the pane1Style to null, but this solution results in a problem of dragging. Have you solved this problem yet?
I ended up with the config:
<SplitPane
split="vertical"
minSize={400}
primary="second"
defaultSize={showIframe ? '50%' : '100%'}
maxSize="60%"
allowResize={showIframe}
onDragStarted={() => setIsDragging(true)}
onDragFinished={() => setIsDragging(false)}>