chore(resizer): cleanup

This commit is contained in:
moklick
2025-06-11 10:44:59 +02:00
parent ec3ef27c90
commit 120a12baf4
3 changed files with 11 additions and 8 deletions
@@ -44,7 +44,7 @@ function ResizeControl({
maxHeight = Number.MAX_VALUE, maxHeight = Number.MAX_VALUE,
keepAspectRatio = false, keepAspectRatio = false,
resizeDirection, resizeDirection,
scaleControls = false, autoScale = true,
shouldResize, shouldResize,
onResizeStart, onResizeStart,
onResize, onResize,
@@ -55,7 +55,10 @@ function ResizeControl({
const store = useStoreApi(); const store = useStoreApi();
const resizeControlRef = useRef<HTMLDivElement>(null); const resizeControlRef = useRef<HTMLDivElement>(null);
const isHandleControl = variant === ResizeControlVariant.Handle; const isHandleControl = variant === ResizeControlVariant.Handle;
const scale = useStore(useCallback(scaleSelector(isHandleControl && !scaleControls), [isHandleControl]), shallow); const scale = useStore(
useCallback(scaleSelector(isHandleControl && autoScale), [isHandleControl, autoScale]),
shallow
);
const resizer = useRef<XYResizerInstance | null>(null); const resizer = useRef<XYResizerInstance | null>(null);
const controlPosition = position ?? defaultPositions[variant]; const controlPosition = position ?? defaultPositions[variant];
@@ -40,7 +40,7 @@ export function NodeResizer({
maxWidth = Number.MAX_VALUE, maxWidth = Number.MAX_VALUE,
maxHeight = Number.MAX_VALUE, maxHeight = Number.MAX_VALUE,
keepAspectRatio = false, keepAspectRatio = false,
scaleControls = false, autoScale = true,
shouldResize, shouldResize,
onResizeStart, onResizeStart,
onResize, onResize,
@@ -67,7 +67,7 @@ export function NodeResizer({
maxHeight={maxHeight} maxHeight={maxHeight}
onResizeStart={onResizeStart} onResizeStart={onResizeStart}
keepAspectRatio={keepAspectRatio} keepAspectRatio={keepAspectRatio}
scaleControls={scaleControls} autoScale={autoScale}
shouldResize={shouldResize} shouldResize={shouldResize}
onResize={onResize} onResize={onResize}
onResizeEnd={onResizeEnd} onResizeEnd={onResizeEnd}
@@ -87,7 +87,7 @@ export function NodeResizer({
maxHeight={maxHeight} maxHeight={maxHeight}
onResizeStart={onResizeStart} onResizeStart={onResizeStart}
keepAspectRatio={keepAspectRatio} keepAspectRatio={keepAspectRatio}
scaleControls={scaleControls} autoScale={autoScale}
shouldResize={shouldResize} shouldResize={shouldResize}
onResize={onResize} onResize={onResize}
onResizeEnd={onResizeEnd} onResizeEnd={onResizeEnd}
@@ -61,9 +61,9 @@ export type NodeResizerProps = {
keepAspectRatio?: boolean; keepAspectRatio?: boolean;
/** /**
* Scale the controls with the zoom level. * Scale the controls with the zoom level.
* @default false * @default true
*/ */
scaleControls?: boolean; autoScale?: boolean;
/** Callback to determine if node should resize. */ /** Callback to determine if node should resize. */
shouldResize?: ShouldResize; shouldResize?: ShouldResize;
/** Callback called when resizing starts. */ /** Callback called when resizing starts. */
@@ -87,7 +87,7 @@ export type ResizeControlProps = Pick<
| 'maxHeight' | 'maxHeight'
| 'keepAspectRatio' | 'keepAspectRatio'
| 'shouldResize' | 'shouldResize'
| 'scaleControls' | 'autoScale'
| 'onResizeStart' | 'onResizeStart'
| 'onResize' | 'onResize'
| 'onResizeEnd' | 'onResizeEnd'