File tree Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ const TemplateTop: StoryFn<CubeResizablePanelProps> = (args) => {
4444
4545const TemplateControllable : StoryFn < CubeResizablePanelProps > = ( args ) => {
4646 const [ size , setSize ] = useState ( 200 ) ;
47-
4847 return (
4948 < ResizablePanel
5049 size = { size }
Original file line number Diff line number Diff line change @@ -217,19 +217,6 @@ function ResizablePanel(
217217 ) ;
218218 let [ visualSize , setVisualSize ] = useState < number | null > ( null ) ;
219219
220- useEffect ( ( ) => {
221- if ( ref . current ) {
222- const offsetProp = isHorizontal ? 'offsetWidth' : 'offsetHeight' ;
223- const containerSize = ref . current [ offsetProp ] ;
224-
225- if ( Math . abs ( containerSize - size ) < 1 && ! isDisabled ) {
226- setVisualSize ( size ) ;
227- } else {
228- setVisualSize ( containerSize ) ;
229- }
230- }
231- } , [ size , isDisabled ] ) ;
232-
233220 let { moveProps } = useMove ( {
234221 onMoveStart ( e ) {
235222 if ( isDisabled ) {
@@ -267,14 +254,27 @@ function ResizablePanel(
267254 } ,
268255 } ) ;
269256
257+ useEffect ( ( ) => {
258+ if ( ref . current ) {
259+ const offsetProp = isHorizontal ? 'offsetWidth' : 'offsetHeight' ;
260+ const containerSize = ref . current [ offsetProp ] ;
261+
262+ if ( Math . abs ( containerSize - size ) < 1 && ! isDisabled ) {
263+ setVisualSize ( size ) ;
264+ } else {
265+ setVisualSize ( containerSize ) ;
266+ }
267+ }
268+ } , [ size , isDisabled ] ) ;
269+
270270 useEffect ( ( ) => {
271271 if (
272- ( providedSize == null || Math . abs ( providedSize - size ) > 0.5 ) &&
272+ ( providedSize == null || Math . abs ( providedSize - visualSize ) > 0.5 ) &&
273273 ! isDragging
274274 ) {
275- onSizeChange ?.( Math . round ( size ) ) ;
275+ onSizeChange ?.( Math . round ( visualSize ) ) ;
276276 }
277- } , [ size ] ) ;
277+ } , [ visualSize ] ) ;
278278
279279 useEffect ( ( ) => {
280280 if ( providedSize && Math . abs ( providedSize - size ) > 0.5 ) {
You can’t perform that action at this time.
0 commit comments