feat(core): do not snap to invalid handles
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
export const isMouseEvent = (event: MouseEvent | TouchEvent): event is MouseEvent => 'clientX' in event
|
||||
|
||||
export const getEventPosition = (event: MouseEvent | TouchEvent, bounds?: DOMRect) => {
|
||||
const isMouseTriggered = isMouseEvent(event)
|
||||
const evtX = isMouseTriggered ? event.clientX : event.touches?.[0].clientX
|
||||
const evtY = isMouseTriggered ? event.clientY : event.touches?.[0].clientY
|
||||
|
||||
return {
|
||||
x: evtX - (bounds?.left ?? 0),
|
||||
y: evtY - (bounds?.top ?? 0),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user