@@ -10,7 +10,8 @@ interface IPublicProps {
10
10
id ?: string ,
11
11
className ?: string ,
12
12
style ?: React . CSSProperties ,
13
- scrollable ?: boolean
13
+ scrollable ?: boolean ,
14
+ trackSize ?: boolean
14
15
}
15
16
16
17
interface IPrivateProps {
@@ -88,20 +89,24 @@ class Space extends React.Component<AllProps, IState> {
88
89
89
90
public componentDidMount ( ) {
90
91
if ( this . divElementRef . current ) {
91
- this . resizeSensor = new ResizeSensor ( this . divElementRef . current , this . spaceResized ) ;
92
+ if ( this . props . trackSize ) {
93
+ this . resizeSensor = new ResizeSensor ( this . divElementRef . current , this . spaceResized ) ;
94
+ }
92
95
93
96
const currentRect = this . divElementRef . current . getBoundingClientRect ( ) ;
94
97
this . setState ( {
95
- currentWidth : currentRect . width ,
96
- currentHeight : currentRect . height
98
+ currentWidth : parseInt ( currentRect . width . toFixed ( ) , 10 ) ,
99
+ currentHeight : parseInt ( currentRect . height . toFixed ( ) , 10 )
97
100
} ) ;
98
101
}
99
102
}
100
103
101
104
public componentWillUnmount ( ) {
102
- if ( this . resizeSensor ) {
103
- this . resizeSensor . detach ( ) ;
104
- this . resizeSensor = undefined ;
105
+ if ( this . props . trackSize ) {
106
+ if ( this . resizeSensor ) {
107
+ this . resizeSensor . detach ( ) ;
108
+ this . resizeSensor = undefined ;
109
+ }
105
110
}
106
111
107
112
if ( this . onRemove ) {
@@ -232,7 +237,7 @@ class Space extends React.Component<AllProps, IState> {
232
237
style = { { ...style , ...this . props . style } } >
233
238
234
239
< SpaceContext . Provider value = { currentContext } >
235
- < SpaceInfoContext . Provider value = { { width : this . state . currentWidth , height : this . state . currentHeight } } >
240
+ < SpaceInfoContext . Provider value = { { width : Math . floor ( this . state . currentWidth ) , height : Math . floor ( this . state . currentHeight ) } } >
236
241
{ spaceRender }
237
242
</ SpaceInfoContext . Provider >
238
243
</ SpaceContext . Provider >
0 commit comments