@@ -6,7 +6,10 @@ import { ChildProps, SizeInfo } from './types';
6
6
import { withResizerContext } from './context' ;
7
7
import { isValidNumber , omit } from './utils' ;
8
8
9
- type Props = ChildProps & React . HTMLAttributes < HTMLDivElement > ;
9
+ type Props = ChildProps &
10
+ React . HTMLAttributes < HTMLDivElement > & {
11
+ onSizeChanged ?: ( currentSize : number ) => void ;
12
+ } ;
10
13
11
14
class SectionComponent extends React . PureComponent < Props > {
12
15
private readonly defaultInnerRef = React . createRef < HTMLDivElement > ( ) ;
@@ -32,6 +35,7 @@ class SectionComponent extends React.PureComponent<Props> {
32
35
const { flexGrow, flexBasis } = this . getStyle ( sizeInfo , flexGrowRatio ) ;
33
36
this . ref . current . style . flexBasis = `${ flexBasis } px` ;
34
37
this . ref . current . style . flexGrow = `${ flexGrow } ` ;
38
+ this . onSizeChanged ( sizeInfo . currentSize ) ;
35
39
}
36
40
} ) ,
37
41
) ;
@@ -83,6 +87,12 @@ class SectionComponent extends React.PureComponent<Props> {
83
87
return < div { ...props } style = { style } ref = { this . ref } /> ;
84
88
}
85
89
90
+ private onSizeChanged ( currentSize : number ) {
91
+ if ( typeof this . props . onSizeChanged === 'function' ) {
92
+ this . props . onSizeChanged ( currentSize ) ;
93
+ }
94
+ }
95
+
86
96
private getStyle (
87
97
sizeInfo : SizeInfo | undefined = this . sizeInfo ,
88
98
flexGrowRatio : number = this . flexGrowRatio ,
0 commit comments