Skip to content

Commit decac3c

Browse files
fix: 弹出窗口因为窗口变化从bottomLeft对齐到topRight对齐时,箭头对齐错误
1 parent 8abc4f9 commit decac3c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/hooks/useAlign.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ export default function useAlign(
323323
const [popupPoint, targetPoint] = placementInfo.points || [];
324324
const targetPoints = splitPoints(targetPoint);
325325
const popupPoints = splitPoints(popupPoint);
326+
let tmpTargetPoints = targetPoints;
327+
let tmpPopupPoints = popupPoints;
326328

327329
const targetAlignPoint = getAlignPoint(targetRect, targetPoints);
328330
const popupAlignPoint = getAlignPoint(popupRect, popupPoints);
@@ -399,6 +401,11 @@ export default function useAlign(
399401
}
400402
syncNextPopupPosition();
401403

404+
function updateTmpPopupPointsAndTmpTargetPoints() {
405+
tmpPopupPoints = splitPoints(nextAlignInfo.points[0]);
406+
tmpTargetPoints = splitPoints(nextAlignInfo.points[1]);
407+
}
408+
402409
// >>>>>>>>>> Top & Bottom
403410
const needAdjustY = supportAdjust(adjustY);
404411

@@ -443,9 +450,10 @@ export default function useAlign(
443450
popupOffsetY = -popupOffsetY;
444451

445452
nextAlignInfo.points = [
446-
reversePoints(popupPoints, 0),
447-
reversePoints(targetPoints, 0),
453+
reversePoints(tmpPopupPoints, 0),
454+
reversePoints(tmpTargetPoints, 0),
448455
];
456+
updateTmpPopupPointsAndTmpTargetPoints();
449457
} else {
450458
prevFlipRef.current.bt = false;
451459
}
@@ -489,9 +497,10 @@ export default function useAlign(
489497
popupOffsetY = -popupOffsetY;
490498

491499
nextAlignInfo.points = [
492-
reversePoints(popupPoints, 0),
493-
reversePoints(targetPoints, 0),
500+
reversePoints(tmpPopupPoints, 0),
501+
reversePoints(tmpTargetPoints, 0),
494502
];
503+
updateTmpPopupPointsAndTmpTargetPoints();
495504
} else {
496505
prevFlipRef.current.tb = false;
497506
}
@@ -542,9 +551,10 @@ export default function useAlign(
542551
popupOffsetX = -popupOffsetX;
543552

544553
nextAlignInfo.points = [
545-
reversePoints(popupPoints, 1),
546-
reversePoints(targetPoints, 1),
554+
reversePoints(tmpPopupPoints, 1),
555+
reversePoints(tmpTargetPoints, 1),
547556
];
557+
updateTmpPopupPointsAndTmpTargetPoints();
548558
} else {
549559
prevFlipRef.current.rl = false;
550560
}
@@ -588,9 +598,10 @@ export default function useAlign(
588598
popupOffsetX = -popupOffsetX;
589599

590600
nextAlignInfo.points = [
591-
reversePoints(popupPoints, 1),
592-
reversePoints(targetPoints, 1),
601+
reversePoints(tmpPopupPoints, 1),
602+
reversePoints(tmpTargetPoints, 1),
593603
];
604+
updateTmpPopupPointsAndTmpTargetPoints();
594605
} else {
595606
prevFlipRef.current.lr = false;
596607
}

0 commit comments

Comments
 (0)