mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(gesture): onEnd now correctly fires even if the event target was removed from the DOM (#23713)
resolves #22819 Co-authored-by: Falingorn <falingorn@users.noreply.github.com>
This commit is contained in:
@ -30,11 +30,21 @@ export const createPointerEvents = (
|
||||
if (!rmTouchMove && pointerMove) {
|
||||
rmTouchMove = addEventListener(el, 'touchmove', pointerMove, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Events are dispatched on the element that is tapped and bubble up to
|
||||
* the reference element in the gesture. In the event that the element this
|
||||
* event was first dispatched on is removed from the DOM, the event will no
|
||||
* longer bubble up to our reference element. This leaves the gesture in an
|
||||
* unusable state. To account for this, the touchend and touchcancel listeners
|
||||
* should be added to the event target so that they still fire even if the target
|
||||
* is removed from the DOM.
|
||||
*/
|
||||
if (!rmTouchEnd) {
|
||||
rmTouchEnd = addEventListener(el, 'touchend', handleTouchEnd, options);
|
||||
rmTouchEnd = addEventListener(ev.target, 'touchend', handleTouchEnd, options);
|
||||
}
|
||||
if (!rmTouchCancel) {
|
||||
rmTouchCancel = addEventListener(el, 'touchcancel', handleTouchEnd, options);
|
||||
rmTouchCancel = addEventListener(ev.target, 'touchcancel', handleTouchEnd, options);
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user