From d3152bcb9933b85c92135cf491958c05e3f30727 Mon Sep 17 00:00:00 2001 From: moecasts Date: Thu, 5 Dec 2024 11:27:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(utils):=20getPosition=20mouse=20=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=85=81=E8=AE=B8=E5=8A=A0=E4=B8=8A=20clientY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/utils/getPosition.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/utils/getPosition.ts b/js/utils/getPosition.ts index 06a92a1ea7..675383d9cc 100644 --- a/js/utils/getPosition.ts +++ b/js/utils/getPosition.ts @@ -5,6 +5,7 @@ const getPosition = ( contentEle: HTMLElement, placement: Partial, clientX?: Number, + clientY?: Number, ): { left: number; top: number } => { const targetRect = targetEle.getBoundingClientRect() as DOMRect; const contentRect = contentEle.getBoundingClientRect() as DOMRect; @@ -28,7 +29,9 @@ const getPosition = ( break; case 'mouse': position.left += Number(clientX); - position.top += targetRect.top + targetRect.height + 8; + position.top += typeof clientY !== 'undefined' + ? Number(clientY) + 16 + : targetRect.top + targetRect.height + 8; break; // 后续有需要可以再扩展 }