Skip to content

Commit 32d8430

Browse files
authored
fix: popup container scroll due to precision (#602)
* fix: popup container scroll due to precision * chore: adjust
1 parent edea4d2 commit 32d8430

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/hooks/useAlign.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,13 @@ export default function useAlign(
698698
popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
699699

700700
if (scaleX === 1) {
701-
nextOffsetX = Math.round(nextOffsetX);
702-
offsetX4Right = Math.round(offsetX4Right);
701+
nextOffsetX = Math.floor(nextOffsetX);
702+
offsetX4Right = Math.floor(offsetX4Right);
703703
}
704704

705705
if (scaleY === 1) {
706-
nextOffsetY = Math.round(nextOffsetY);
707-
offsetY4Bottom = Math.round(offsetY4Bottom);
706+
nextOffsetY = Math.floor(nextOffsetY);
707+
offsetY4Bottom = Math.floor(offsetY4Bottom);
708708
}
709709

710710
const nextOffsetInfo = {

tests/align.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe('Trigger.Align', () => {
272272
});
273273
});
274274

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

295295
expect(document.querySelector('.rc-trigger-popup')).toHaveStyle({
296-
top: `56px`,
296+
top: `55px`,
297297
});
298298
});
299299

0 commit comments

Comments
 (0)