fix(core): fall back to changedTouches for touchend events (#1830)
* fix(core): fall back to changedTouches for touchend events Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
5
.changeset/wild-bobcats-wash.md
Normal file
5
.changeset/wild-bobcats-wash.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@vue-flow/core": patch
|
||||
---
|
||||
|
||||
Fall back to using changedTouches when passing a touchend or touchcancel event to getEventPosition.
|
||||
@@ -12,8 +12,23 @@ export function isUseDragEvent(event: any): event is UseDragEvent {
|
||||
export function getEventPosition(event: MouseEvent | TouchEvent, bounds?: DOMRect) {
|
||||
const isMouse = isMouseEvent(event)
|
||||
|
||||
const evtX = isMouse ? event.clientX : event.touches?.[0].clientX
|
||||
const evtY = isMouse ? event.clientY : event.touches?.[0].clientY
|
||||
let evtX: number
|
||||
let evtY: number
|
||||
|
||||
if (isMouse) {
|
||||
evtX = event.clientX
|
||||
evtY = event.clientY
|
||||
} else if ('touches' in event && event.touches.length > 0) {
|
||||
evtX = event.touches[0].clientX
|
||||
evtY = event.touches[0].clientY
|
||||
} else if ('changedTouches' in event && event.changedTouches.length > 0) {
|
||||
evtX = event.changedTouches[0].clientX
|
||||
evtY = event.changedTouches[0].clientY
|
||||
} else {
|
||||
// fallback for other cases
|
||||
evtX = 0
|
||||
evtY = 0
|
||||
}
|
||||
|
||||
return {
|
||||
x: evtX - (bounds?.left ?? 0),
|
||||
|
||||
@@ -122,7 +122,7 @@ export function getClosestHandle(
|
||||
return closestHandles[0]
|
||||
}
|
||||
|
||||
// checks if and returns connection in form of an object { source: 123, target: 312 }
|
||||
// checks if and returns connection in form of an object { source: 123, target: 312 }
|
||||
export function isValidHandle(
|
||||
event: MouseEvent | TouchEvent,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user