Skip to content

Commit

Permalink
docs(kitify): Update detectMouseDirection angle calculation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Marinerer committed Dec 24, 2024
1 parent 84a79bc commit b6f8ae6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libs/kitify/src/dom/detectMouseDirection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export default function detectMouseDirection(
const dx = x2 - x1
const dy = y2 - y1
if (action === 'enter') {
// 添加 PI 来反转角度,使其对应进入方向而不是移动方向
//`+ Math.PI`: 添加 PI 来反转角度,使其对应进入方向而不是移动方向
//`% (2 * Math.PI)`: 对结果取模运算,以保角度在 0 到 2π 的范围内
return (Math.atan2(dy, dx) + Math.PI) % (2 * Math.PI)
}
return Math.atan2(dy, dx)
Expand Down

0 comments on commit b6f8ae6

Please sign in to comment.