Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/hooks/useAlign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,13 @@ export default function useAlign(
popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);

if (scaleX === 1) {
nextOffsetX = Math.round(nextOffsetX);
offsetX4Right = Math.round(offsetX4Right);
nextOffsetX = Math.floor(nextOffsetX);
offsetX4Right = Math.floor(offsetX4Right);
Comment on lines -701 to +702
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

round改为floor我理解没什么副作用,唯一的弊端可能就是精度差异会变大,原来最多0.5px的差异,现在最大精度差可能为0.99px,但用户真能感知到吗(

}

if (scaleY === 1) {
nextOffsetY = Math.round(nextOffsetY);
offsetY4Bottom = Math.round(offsetY4Bottom);
nextOffsetY = Math.floor(nextOffsetY);
offsetY4Bottom = Math.floor(offsetY4Bottom);
}

const nextOffsetInfo = {
Expand Down
4 changes: 2 additions & 2 deletions tests/align.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe('Trigger.Align', () => {
});
});

it('round when decimal precision', async () => {
it('floor when decimal precision', async () => {
rectX = 22.6;
rectY = 33.4;
rectWidth = 33.7;
Expand All @@ -293,7 +293,7 @@ describe('Trigger.Align', () => {
await awaitFakeTimer();

expect(document.querySelector('.rc-trigger-popup')).toHaveStyle({
top: `56px`,
top: `55px`,
});
});

Expand Down
Loading