@@ -20,7 +20,7 @@ interface IPrivateProps {
20
20
}
21
21
22
22
interface IAnchoredProps {
23
- size ?: number ,
23
+ size ?: number | string ,
24
24
order ?: number
25
25
}
26
26
@@ -36,12 +36,13 @@ interface IState {
36
36
adjustedSize : number ,
37
37
spaceTakers : ISpaceTaker [ ] ,
38
38
39
+ parsedSize ?: number ;
39
40
left ?: number ;
40
41
top ?: number ;
41
42
right ?: number ;
42
43
bottom ?: number ;
43
- width ?: number ;
44
- height ?: number ;
44
+ width ?: number | string ;
45
+ height ?: number | string ;
45
46
}
46
47
47
48
export const Fill : React . FC < IPublicProps > = ( props ) => < Space { ...props } />
@@ -78,6 +79,7 @@ class Space extends React.Component<AllProps, IState> {
78
79
adjustedSize : 0 ,
79
80
spaceTakers : [ ] ,
80
81
82
+ parsedSize : typeof props . size === "string" ? 0 : props . size as number | undefined ,
81
83
left : props . anchor !== AnchorType . Right ? 0 : undefined ,
82
84
top : props . anchor !== AnchorType . Bottom ? 0 : undefined ,
83
85
right : props . anchor !== AnchorType . Left ? 0 : undefined ,
@@ -95,8 +97,9 @@ class Space extends React.Component<AllProps, IState> {
95
97
96
98
const currentRect = this . divElementRef . current . getBoundingClientRect ( ) ;
97
99
this . setState ( {
98
- currentWidth : parseInt ( currentRect . width . toFixed ( ) , 10 ) ,
99
- currentHeight : parseInt ( currentRect . height . toFixed ( ) , 10 )
100
+ parsedSize : ! this . state . parsedSize ? currentRect . width : this . state . parsedSize ,
101
+ currentWidth : currentRect . width ,
102
+ currentHeight : currentRect . height
100
103
} ) ;
101
104
}
102
105
}
@@ -124,8 +127,8 @@ class Space extends React.Component<AllProps, IState> {
124
127
top : this . state . top ,
125
128
right : this . state . right ,
126
129
bottom : this . state . bottom ,
127
- width : this . isHorizontalSpace ( ) && this . state . adjustedSize !== 0 ? ( this . state . width || 0 ) + this . state . adjustedSize : this . state . width ,
128
- height : this . isVerticalSpace ( ) && this . state . adjustedSize !== 0 ? ( this . state . height || 0 ) + this . state . adjustedSize : this . state . height
130
+ width : this . isHorizontalSpace ( ) ? ( this . state . parsedSize || 0 ) + this . state . adjustedSize : undefined ,
131
+ height : this . isVerticalSpace ( ) ? ( this . state . parsedSize || 0 ) + this . state . adjustedSize : undefined
129
132
} ;
130
133
131
134
if ( parentContext ) {
@@ -182,7 +185,7 @@ class Space extends React.Component<AllProps, IState> {
182
185
id : this . state . id ,
183
186
order : this . props . order || 1 ,
184
187
anchorType : this . props . anchor ,
185
- size : this . props . size || ( this . isVerticalSpace ( ) ? this . state . currentHeight : this . state . currentWidth ) ,
188
+ size : ( this . state . parsedSize || 0 ) ,
186
189
adjustedSize : 0
187
190
} ) ;
188
191
}
@@ -217,7 +220,7 @@ class Space extends React.Component<AllProps, IState> {
217
220
< Resizable
218
221
type = { resizeType }
219
222
minimumAdjust = { - ( this . props . size || 0 ) + ( this . props . minimumSize || 20 ) }
220
- maximumAdjust = { this . props . maximumSize ? ( this . props . maximumSize - ( this . props . size || 0 ) ) : undefined }
223
+ maximumAdjust = { this . props . maximumSize ? ( this . props . maximumSize - ( this . state . parsedSize || 0 ) ) : undefined }
221
224
onResize = { ( adjustedSize ) => {
222
225
this . setState (
223
226
{ adjustedSize : adjustedSize } ,
0 commit comments