Skip to content

Commit

Permalink
made drag offset optional
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-toy committed Oct 29, 2020
1 parent 8eb6896 commit 683d5ff
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/dragdrop/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,12 +828,18 @@ namespace Private {

/**
* Find the drag scroll target under the mouse, if any.
*
* @param event - The mouse event related to the action.
*
* @param dragOffsetX - the number of pixels to offset the drag in the x direction.
*
* @param dragOffsetY - the number of pixels to offset the drag in the y direction.
*/
export
function findScrollTarget(event: MouseEvent, dragOffsetX: number, dragOffsetY: number): IScrollTarget | null {
function findScrollTarget(event: MouseEvent, dragOffsetX?: number, dragOffsetY?: number): IScrollTarget | null {
// Look up the client mouse position.
const x = event.clientX + dragOffsetX;
const y = event.clientY + dragOffsetY;
const x = event.clientX + (dragOffsetX !== undefined ? dragOffsetX : 0);
const y = event.clientY + (dragOffsetY !== undefined ? dragOffsetY : 0);

// Get the element under the mouse.
let element: Element | null = document.elementFromPoint(x, y);
Expand Down

0 comments on commit 683d5ff

Please sign in to comment.