react-split-pane icon indicating copy to clipboard operation
react-split-pane copied to clipboard

If I set the pane1Style width style, the resizer stop working

Open vcardins opened this issue 5 years ago • 2 comments
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>

vcardins avatar Jun 09 '20 16:06 vcardins

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?

YiyuanYin avatar Jun 28 '20 16:06 YiyuanYin

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)}>

vcardins avatar Jun 29 '20 16:06 vcardins