Completed formation tool

This commit is contained in:
Davide Passoni
2024-10-10 14:35:14 +02:00
parent e11f4a6c11
commit b13689c09a
3 changed files with 273 additions and 82 deletions

View File

@@ -44,8 +44,8 @@ export const useDrag = (props: { ref, initialPosition, count}) => {
const [parentTop, parentLeft, parentWidth, parentHeight] = [parentRect.top, parentRect.left, parentRect.width, parentRect.height];
setFinalPosition({
x: Math.max(width / 2, Math.min(mouseX - parentLeft, parentWidth - width / 2)),
y: Math.max(height / 2, Math.min(mouseY - parentTop, parentHeight - height / 2)),
x: Math.round(Math.max(width / 2, Math.min(mouseX - parentLeft, parentWidth - width / 2)) / 10) * 10,
y: Math.round(Math.max(height / 2, Math.min(mouseY - parentTop, parentHeight - height / 2)) / 10) * 10,
});
},
[isDragging, props.ref]