Skip to content

Commit

Permalink
Return null instead of undefined and enhance tsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Oct 30, 2023
1 parent 36d34c0 commit badbeec
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/dom.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
* Finds overlay element that is visible under the cursor
* @param e Mouse event containing cursor position
*
* @param {MouseEvent} e Mouse event containing cursor position
* @returns {Element|null} Element if one is visible under the cursor, null otherwise
*/
export function visibleUnderCursor(e: MouseEvent) {
export function visibleUnderCursor(e: MouseEvent): Element | null {
// Get all the elements under the mouse
const elements = document.elementsFromPoint(e.clientX, e.clientY);

Expand All @@ -18,4 +20,6 @@ export function visibleUnderCursor(e: MouseEvent) {
return element;
}
}

return null;
}

0 comments on commit badbeec

Please sign in to comment.