Add drag leave/drop handler to drag tool

When using the drag tool, a common use case for us is to take some kind of action when the drag stops based on the final location of the cursor, such as sending the final position or collision detection information back to our application so that we can do things based on that result. It’d be easier to implement if this was built in to the drag tool as opposed to using a disjointed tool such as mouse up and tracking when something is dragging to filter the mouse up events.

My proposal would be something similar to the following when creating the drag tool with a new handleDrop handler option:

{
    key: "drag",
    active: true,
    enabled: true,
    handlers: {
        drag: (event: IMouseEvent) => {
            ...
            return {
                handle: (event: IMouseEvent) => { do stuff while dragging },
                handleDrop: (event: IMouseEvent) => { do something when user stops dragging }
            }
        }
    }
}
1 Like