@ -100,36 +100,27 @@ export function BaseNode({
const panelEl = settingsPanelRef . current ;
if ( ! panelEl ) return ;
let rafId : number | null = null ;
const observer = new ResizeObserver ( ( entries ) = > {
if ( rafId !== null ) cancelAnimationFrame ( rafId ) ;
rafId = requestAnimationFrame ( ( ) = > {
rafId = null ;
for ( const entry of entries ) {
const newPanelHeight = entry . contentRect . height ;
if ( newPanelHeight === 0 ) continue ;
const delta = newPanelHeight - trackedSettingsHeightRef . current ;
if ( Math . abs ( delta ) < 2 ) continue ; // Ignore sub-pixel changes
trackedSettingsHeightRef . current = newPanelHeight ;
setNodes ( ( nodes ) = >
nodes . map ( ( node ) = > {
if ( node . id !== id ) return node ;
const currentHeight = getNodeDimension ( node , "height" ) ;
const newHeight = Math . max ( minHeight , currentHeight + delta ) ;
return applyNodeDimensions ( node , getNodeDimension ( node , "width" ) , newHeight ) ;
} )
) ;
}
} ) ;
for ( const entry of entries ) {
const newPanelHeight = entry . contentRect . height ;
if ( newPanelHeight === 0 ) continue ;
const delta = newPanelHeight - trackedSettingsHeightRef . current ;
if ( Math . abs ( delta ) < 2 ) continue ; // Ignore sub-pixel changes
trackedSettingsHeightRef . current = newPanelHeight ;
setNodes ( ( nodes ) = >
nodes . map ( ( node ) = > {
if ( node . id !== id ) return node ;
const currentHeight = getNodeDimension ( node , "height" ) ;
const newHeight = Math . max ( minHeight , currentHeight + delta ) ;
return applyNodeDimensions ( node , getNodeDimension ( node , "width" ) , newHeight ) ;
} )
) ;
}
} ) ;
observer . observe ( panelEl ) ;
return ( ) = > {
if ( rafId !== null ) cancelAnimationFrame ( rafId ) ;
observer . disconnect ( ) ;
} ;
return ( ) = > observer . disconnect ( ) ;
// eslint-disable-next-line react-hooks/exhaustive-deps
} , [ settingsExpanded , settingsPanel ] ) ;