refactor(node-resizer): rename onBeforeResize to shouldResize, cleanup types

This commit is contained in:
moklick
2023-01-16 14:39:11 +01:00
parent e6b71d474f
commit 1ab7a0f0d9
5 changed files with 29 additions and 23 deletions
+10 -8
View File
@@ -32,8 +32,8 @@ function ResizeControl({
color,
minWidth = 10,
minHeight = 10,
shouldResize,
onResizeStart,
onBeforeResize,
onResize,
onResizeEnd,
}: ResizeControlProps) {
@@ -146,12 +146,6 @@ function ResizeControl({
return;
}
const onBeforeResizeResult = onBeforeResize?.(event, { ...prevValues.current });
if (onBeforeResizeResult === false) {
return;
}
const direction = getDirection({
width: prevValues.current.width,
prevWidth,
@@ -161,7 +155,15 @@ function ResizeControl({
invertY,
});
onResize?.(event, { ...prevValues.current, direction });
const nextValues = { ...prevValues.current, direction };
const callResize = shouldResize?.(event, nextValues);
if (callResize === false) {
return;
}
onResize?.(event, nextValues);
triggerNodeChanges(changes);
}
})