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; // 后续有需要可以再扩展 }