Skip to content

Commit

Permalink
fix : getPointFromEvent remove rect argument (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: myeonggyu.lee <[email protected]>
  • Loading branch information
billy5982 and myeonggyu.lee authored Oct 3, 2024
1 parent 7ae9ada commit f8fcc1e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/hooks/useSelectionLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ export function useSelectionLogic<T extends HTMLElement>({
* method to calculate point from event in context of the whole screen
*/
const getPointFromEvent = useCallback(
(event: MouseEvent, rect?: DOMRect): Point => {
if (!rect) {
rect = containerRef.current?.getParentBoundingClientRect();
}
(event: MouseEvent): Point => {
const rect = containerRef.current?.getParentBoundingClientRect();

return {
x: event.clientX - (typeof rect?.left === 'number' ? rect.left : 0),
Expand Down Expand Up @@ -157,7 +155,7 @@ export function useSelectionLogic<T extends HTMLElement>({
}

const rect = containerRef.current?.getParentBoundingClientRect();
endPoint.current = getPointFromEvent(event, rect);
endPoint.current = getPointFromEvent(event);
handleMouseMove(event, rect);
},
[handleMouseMove, getPointFromEvent, containerRef],
Expand Down

0 comments on commit f8fcc1e

Please sign in to comment.