From f613db0226e4da82b04ae2279be65d78ae7addc1 Mon Sep 17 00:00:00 2001 From: zhipenglin Date: Sat, 27 Jan 2024 21:56:31 +0800 Subject: [PATCH] fix: fix Affix placeholder height anomaly when browser zoom is 80% Signed-off-by: zhipenglin --- components/affix/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/affix/utils.ts b/components/affix/utils.ts index 2e911e873e..750fe9bc85 100644 --- a/components/affix/utils.ts +++ b/components/affix/utils.ts @@ -7,7 +7,7 @@ export function getTargetRect(target: BindElement): DOMRect { } export function getFixedTop(placeholderRect: DOMRect, targetRect: DOMRect, offsetTop?: number) { - if (offsetTop !== undefined && targetRect.top > placeholderRect.top - offsetTop) { + if (offsetTop !== undefined && Math.round(targetRect.top) > Math.round(placeholderRect.top) - offsetTop) { return offsetTop + targetRect.top; } return undefined; @@ -18,7 +18,7 @@ export function getFixedBottom( targetRect: DOMRect, offsetBottom?: number, ) { - if (offsetBottom !== undefined && targetRect.bottom < placeholderRect.bottom + offsetBottom) { + if (offsetBottom !== undefined && Math.round(targetRect.bottom) < Math.round(placeholderRect.bottom) + offsetBottom) { const targetBottomOffset = window.innerHeight - targetRect.bottom; return offsetBottom + targetBottomOffset; }