Skip to content

Commit 44cb4a7

Browse files
committed
Fixed resizing constraints
1 parent 0967b83 commit 44cb4a7

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

demo/src/docs/Resizable.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,31 @@ export const Resizable = () => {
8787
{
8888
"const App = () => (\r\n" +
8989
" <Space.Fixed height={400}>\r\n" +
90-
" <Space.LeftResizable size={100} minimumSize={50} maximumSize={150} />\r\n" +
90+
" <Space.LeftResizable size=\"20%\" minimumSize={50} maximumSize={150} />\r\n" +
9191
" <Space.Fill />\r\n" +
92-
" <Space.RightResizable size={100} minimumSize={50} maximumSize={150} />\r\n" +
92+
" <Space.RightResizable size=\"20%\" minimumSize={50} maximumSize={150} />\r\n" +
9393
" </Space.Fixed>\r\n" +
9494
")"
9595
}
9696
</SyntaxHighlighter>
9797

9898
<Space.Fixed height={400}>
99-
<Space.LeftResizable trackSize={true} size={100} minimumSize={50} maximumSize={150} style={{ backgroundColor: '#e0eee0' }}>
100-
{Description("Left", "L")}
99+
<Space.LeftResizable trackSize={true} size="20%" minimumSize={50} maximumSize={150} style={{ backgroundColor: '#e0eee0' }}>
100+
{Description("Left", "L")}
101101
</Space.LeftResizable>
102-
<Space.Fill trackSize={true} style={{ backgroundColor: '#eee0e0' }}>
103-
{Description("Fill", "F")}
104-
</Space.Fill>
105-
<Space.RightResizable trackSize={true} size={100} minimumSize={50} maximumSize={150} style={{ backgroundColor: '#e0eee0' }}>
106-
{Description("Right", "R")}
102+
<Space.Fill>
103+
<Space.TopResizable trackSize={true} size="20%" minimumSize={50} maximumSize={150} style={{ backgroundColor: '#e0eeee' }}>
104+
{Description("Top", "T")}
105+
</Space.TopResizable>
106+
<Space.Fill trackSize={true} style={{ backgroundColor: '#eee0e0' }}>
107+
{Description("Fill", "F")}
108+
</Space.Fill>
109+
<Space.BottomResizable trackSize={true} size="20%" minimumSize={50} maximumSize={150} style={{ backgroundColor: '#e0eeee' }}>
110+
{Description("Bottom", "B")}
111+
</Space.BottomResizable>
112+
</Space.Fill>
113+
<Space.RightResizable trackSize={true} size="20%" minimumSize={50} maximumSize={150} style={{ backgroundColor: '#e0eee0' }}>
114+
{Description("Right", "R")}
107115
</Space.RightResizable>
108116
</Space.Fixed>
109117

react-spaces/src/components/Space.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ class Space extends React.Component<AllProps, IState> {
100100

101101
const currentRect = this.divElementRef.current.getBoundingClientRect();
102102
this.setState({
103-
parsedSize: !this.state.parsedSize ? currentRect.width : this.state.parsedSize,
103+
parsedSize:
104+
!this.state.parsedSize ?
105+
this.isHorizontalSpace() ? currentRect.width : currentRect.height :
106+
this.state.parsedSize,
104107
currentWidth: currentRect.width,
105108
currentHeight: currentRect.height
106109
});
@@ -246,7 +249,7 @@ class Space extends React.Component<AllProps, IState> {
246249
<>
247250
<Resizable
248251
type={resizeType}
249-
minimumAdjust={ -(this.props.size || 0) + (this.props.minimumSize || 20) }
252+
minimumAdjust={ -(this.state.parsedSize || 0) + (this.props.minimumSize || 20) }
250253
maximumAdjust={ this.props.maximumSize ? (this.props.maximumSize - (this.state.parsedSize || 0)) : undefined}
251254
onResize={(adjustedSize) => {
252255
this.setState(

0 commit comments

Comments
 (0)