Skip to content

Commit

Permalink
feat(utils): getPosition mouse 计算允许加上 clientY
Browse files Browse the repository at this point in the history
  • Loading branch information
moecasts committed Dec 5, 2024
1 parent 94e21e2 commit d3152bc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion js/utils/getPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const getPosition = (
contentEle: HTMLElement,
placement: Partial<Placement>,
clientX?: Number,
clientY?: Number,
): { left: number; top: number } => {
const targetRect = targetEle.getBoundingClientRect() as DOMRect;
const contentRect = contentEle.getBoundingClientRect() as DOMRect;
Expand All @@ -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;
// 后续有需要可以再扩展
}
Expand Down

0 comments on commit d3152bc

Please sign in to comment.