@@ -10,7 +10,8 @@ interface IPublicProps {
1010 id ?: string ,
1111 className ?: string ,
1212 style ?: React . CSSProperties ,
13- scrollable ?: boolean
13+ scrollable ?: boolean ,
14+ trackSize ?: boolean
1415}
1516
1617interface IPrivateProps {
@@ -88,20 +89,24 @@ class Space extends React.Component<AllProps, IState> {
8889
8990 public componentDidMount ( ) {
9091 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+ }
9295
9396 const currentRect = this . divElementRef . current . getBoundingClientRect ( ) ;
9497 this . setState ( {
95- currentWidth : currentRect . width ,
96- currentHeight : currentRect . height
98+ currentWidth : parseInt ( currentRect . width . toFixed ( ) , 10 ) ,
99+ currentHeight : parseInt ( currentRect . height . toFixed ( ) , 10 )
97100 } ) ;
98101 }
99102 }
100103
101104 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+ }
105110 }
106111
107112 if ( this . onRemove ) {
@@ -232,7 +237,7 @@ class Space extends React.Component<AllProps, IState> {
232237 style = { { ...style , ...this . props . style } } >
233238
234239 < 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 ) } } >
236241 { spaceRender }
237242 </ SpaceInfoContext . Provider >
238243 </ SpaceContext . Provider >
0 commit comments