@@ -103,9 +103,10 @@ function ComponentResizer({children}): {|children: Function|} {
103
103
if ( componentsWrapperRef . current === null ) {
104
104
return RESIZE_DIRECTIONS . HORIZONTAL ;
105
105
}
106
+ const VERTICAL_MODE_MAX_WIDTH : number = 600 ;
106
107
const { width} = componentsWrapperRef . current . getBoundingClientRect ( ) ;
107
108
108
- return width > 600
109
+ return width > VERTICAL_MODE_MAX_WIDTH
109
110
? RESIZE_DIRECTIONS . HORIZONTAL
110
111
: RESIZE_DIRECTIONS . VERTICAL ;
111
112
} , [ componentsWrapperRef ] ) ;
@@ -141,27 +142,26 @@ function ComponentResizer({children}): {|children: Function|} {
141
142
resizeDirection === RESIZE_DIRECTIONS . HORIZONTAL
142
143
? e . clientX - left
143
144
: e . clientY - top ;
145
+ const BOUNDARY_PADDING : number = 40 ;
144
146
const boundary : { |
145
147
min : number ,
146
148
max : number ,
147
149
| } = {
148
- min : 40 ,
150
+ min : BOUNDARY_PADDING ,
149
151
max :
150
152
resizeDirection === RESIZE_DIRECTIONS . HORIZONTAL
151
- ? width - 40
152
- : height - 40 ,
153
+ ? width - BOUNDARY_PADDING
154
+ : height - BOUNDARY_PADDING ,
153
155
} ;
154
- const mousePositionInBounds : boolean =
156
+ const isMousePositionInBounds : boolean =
155
157
currentMousePosition > boundary . min &&
156
158
currentMousePosition < boundary . max ;
157
159
158
- if ( mousePositionInBounds ) {
160
+ if ( isMousePositionInBounds ) {
161
+ const resizedElementDimension : number =
162
+ resizeDirection === RESIZE_DIRECTIONS . HORIZONTAL ? width : height ;
159
163
const updatedFlexBasisValue : number =
160
- ( currentMousePosition /
161
- ( resizeDirection === RESIZE_DIRECTIONS . HORIZONTAL
162
- ? width
163
- : height ) ) *
164
- 100 ;
164
+ ( currentMousePosition / resizedElementDimension ) * 100 ;
165
165
166
166
resizeElementRef . current . style . flexBasis = `${ updatedFlexBasisValue } %` ;
167
167
0 commit comments