No longer firing canvas-drag-end if there is no canvas-drag preceding

This commit is contained in:
Ian Gilman 2021-11-18 13:45:50 -08:00
parent f15d5a2bff
commit c4904fb460

View File

@ -271,7 +271,10 @@
lastPinchDist: 0, lastPinchDist: 0,
currentPinchDist: 0, currentPinchDist: 0,
lastPinchCenter: null, lastPinchCenter: null,
currentPinchCenter: null currentPinchCenter: null,
// Tracking for drag
sentDragEvent: false
}; };
this.hasGestureHandlers = !!( this.pressHandler || this.nonPrimaryPressHandler || this.hasGestureHandlers = !!( this.pressHandler || this.nonPrimaryPressHandler ||
@ -1446,6 +1449,8 @@
for ( i = 0; i < pointerListCount; i++ ) { for ( i = 0; i < pointerListCount; i++ ) {
delegate.activePointersLists.pop(); delegate.activePointersLists.pop();
} }
delegate.sentDragEvent = false;
} }
/** /**
@ -3476,7 +3481,7 @@
} }
// Drag End // Drag End
if ( tracker.dragEndHandler ) { if ( tracker.dragEndHandler && delegate.sentDragEvent ) {
tracker.dragEndHandler( tracker.dragEndHandler(
{ {
eventSource: tracker, eventSource: tracker,
@ -3492,6 +3497,9 @@
); );
} }
// We want to clear this flag regardless of whether we fired the dragEndHandler
delegate.sentDragEvent = false;
// Click / Double-Click // Click / Double-Click
if ( ( tracker.clickHandler || tracker.dblClickHandler ) && updateGPoint.insideElement ) { if ( ( tracker.clickHandler || tracker.dblClickHandler ) && updateGPoint.insideElement ) {
quick = releaseTime - updateGPoint.contactTime <= tracker.clickTimeThreshold && quick = releaseTime - updateGPoint.contactTime <= tracker.clickTimeThreshold &&
@ -3679,6 +3687,7 @@
} }
); );
eventInfo.preventDefault = true; eventInfo.preventDefault = true;
delegate.sentDragEvent = true;
} }
} else if ( pointsList.contacts === 2 ) { } else if ( pointsList.contacts === 2 ) {
// Move (2 contacts, use center) // Move (2 contacts, use center)