fix
This commit is contained in:
@@ -380,8 +380,7 @@ const useDocumentDrag = () => {
|
||||
const localPointerOffsetX = pointerOffsetX * cosInitial - pointerOffsetY * sinInitial;
|
||||
const localPointerOffsetY = pointerOffsetX * sinInitial + pointerOffsetY * cosInitial;
|
||||
|
||||
const stackRandom = () => Math.random();
|
||||
const groupItems = groupDocIds.map((id, index) => {
|
||||
const groupItems = groupDocIds.map((id) => {
|
||||
const itemDoc = documentLookup.get(id);
|
||||
const itemSize = ensureDocumentSize(itemDoc) || sizeInfo;
|
||||
const itemWidth = itemSize.width || docWidth;
|
||||
@@ -391,10 +390,8 @@ const useDocumentDrag = () => {
|
||||
typeof itemEntry?.centerX === 'number' ? itemEntry.centerX : canvasPadding + itemWidth / 2;
|
||||
const itemCenterY =
|
||||
typeof itemEntry?.centerY === 'number' ? itemEntry.centerY : canvasPadding + itemHeight / 2;
|
||||
const radius = index === 0 ? 0 : 24 + index * 8;
|
||||
const offsetAngle = (index * 1.618 + stackRandom() * 0.5) * Math.PI;
|
||||
const offsetX = Math.cos(offsetAngle) * radius;
|
||||
const offsetY = Math.sin(offsetAngle) * radius;
|
||||
const baseOffsetX = itemCenterX - centerX;
|
||||
const baseOffsetY = itemCenterY - centerY;
|
||||
const initialRotation = itemEntry?.rotation ?? 0;
|
||||
const targetRotation = initialRotation;
|
||||
return {
|
||||
@@ -403,8 +400,10 @@ const useDocumentDrag = () => {
|
||||
height: itemHeight,
|
||||
currentCenterX: itemCenterX,
|
||||
currentCenterY: itemCenterY,
|
||||
offsetX,
|
||||
offsetY,
|
||||
baseOffsetX,
|
||||
baseOffsetY,
|
||||
offsetX: baseOffsetX,
|
||||
offsetY: baseOffsetY,
|
||||
initialRotation,
|
||||
displayRotation: initialRotation,
|
||||
targetRotation,
|
||||
@@ -599,14 +598,15 @@ const useDocumentDrag = () => {
|
||||
if (isPrimary) {
|
||||
item.currentCenterX = centerX;
|
||||
item.currentCenterY = centerY;
|
||||
item.offsetX *= 0.92;
|
||||
item.offsetY *= 0.92;
|
||||
item.offsetX = item.baseOffsetX ?? 0;
|
||||
item.offsetY = item.baseOffsetY ?? 0;
|
||||
item.displayRotation = state.rotation ?? item.displayRotation ?? 0;
|
||||
} else {
|
||||
item.offsetX *= 0.92;
|
||||
item.offsetY *= 0.92;
|
||||
if (Math.abs(item.offsetX) < 1) item.offsetX = 0;
|
||||
if (Math.abs(item.offsetY) < 1) item.offsetY = 0;
|
||||
const decay = 0.82;
|
||||
const currentOffsetX = (item.offsetX ?? item.baseOffsetX ?? 0) * decay;
|
||||
const currentOffsetY = (item.offsetY ?? item.baseOffsetY ?? 0) * decay;
|
||||
item.offsetX = Math.abs(currentOffsetX) < 0.5 ? 0 : currentOffsetX;
|
||||
item.offsetY = Math.abs(currentOffsetY) < 0.5 ? 0 : currentOffsetY;
|
||||
|
||||
const targetX = centerX + item.offsetX;
|
||||
const targetY = centerY + item.offsetY;
|
||||
|
||||
Reference in New Issue
Block a user