@@ -103,9 +103,10 @@ function ComponentResizer({children}): {|children: Function|} {
103103 if ( componentsWrapperRef . current === null ) {
104104 return RESIZE_DIRECTIONS . HORIZONTAL ;
105105 }
106+ const VERTICAL_MODE_MAX_WIDTH : number = 600 ;
106107 const { width} = componentsWrapperRef . current . getBoundingClientRect ( ) ;
107108
108- return width > 600
109+ return width > VERTICAL_MODE_MAX_WIDTH
109110 ? RESIZE_DIRECTIONS . HORIZONTAL
110111 : RESIZE_DIRECTIONS . VERTICAL ;
111112 } , [ componentsWrapperRef ] ) ;
@@ -141,27 +142,26 @@ function ComponentResizer({children}): {|children: Function|} {
141142 resizeDirection === RESIZE_DIRECTIONS . HORIZONTAL
142143 ? e . clientX - left
143144 : e . clientY - top ;
145+ const BOUNDARY_PADDING : number = 40 ;
144146 const boundary : { |
145147 min : number ,
146148 max : number ,
147149 | } = {
148- min : 40 ,
150+ min : BOUNDARY_PADDING ,
149151 max :
150152 resizeDirection === RESIZE_DIRECTIONS . HORIZONTAL
151- ? width - 40
152- : height - 40 ,
153+ ? width - BOUNDARY_PADDING
154+ : height - BOUNDARY_PADDING ,
153155 } ;
154- const mousePositionInBounds : boolean =
156+ const isMousePositionInBounds : boolean =
155157 currentMousePosition > boundary . min &&
156158 currentMousePosition < boundary . max ;
157159
158- if ( mousePositionInBounds ) {
160+ if ( isMousePositionInBounds ) {
161+ const resizedElementDimension : number =
162+ resizeDirection === RESIZE_DIRECTIONS . HORIZONTAL ? width : height ;
159163 const updatedFlexBasisValue : number =
160- ( currentMousePosition /
161- ( resizeDirection === RESIZE_DIRECTIONS . HORIZONTAL
162- ? width
163- : height ) ) *
164- 100 ;
164+ ( currentMousePosition / resizedElementDimension ) * 100 ;
165165
166166 resizeElementRef . current . style . flexBasis = `${ updatedFlexBasisValue } %` ;
167167
0 commit comments