mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
fix(util): UIEventManager should handle touchcancel event
This commit is contained in:
@ -1,8 +1,6 @@
|
|||||||
import {ElementRef} from '@angular/core';
|
import {ElementRef} from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@ -10,6 +8,7 @@ export class PointerEvents {
|
|||||||
private rmTouchStart: Function = null;
|
private rmTouchStart: Function = null;
|
||||||
private rmTouchMove: Function = null;
|
private rmTouchMove: Function = null;
|
||||||
private rmTouchEnd: Function = null;
|
private rmTouchEnd: Function = null;
|
||||||
|
private rmTouchCancel: Function = null;
|
||||||
|
|
||||||
private rmMouseStart: Function = null;
|
private rmMouseStart: Function = null;
|
||||||
private rmMouseMove: Function = null;
|
private rmMouseMove: Function = null;
|
||||||
@ -26,8 +25,8 @@ export class PointerEvents {
|
|||||||
private zone: boolean,
|
private zone: boolean,
|
||||||
private option: any) {
|
private option: any) {
|
||||||
|
|
||||||
this.rmTouchStart = listenEvent(ele, 'touchstart', zone, option, (ev: any) => this.handleTouchStart(ev));
|
this.rmTouchStart = listenEvent(ele, 'touchstart', zone, option, this.handleTouchStart.bind(this));
|
||||||
this.rmMouseStart = listenEvent(ele, 'mousedown', zone, option, (ev: any) => this.handleMouseDown(ev));
|
this.rmMouseStart = listenEvent(ele, 'mousedown', zone, option, this.handleMouseDown.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleTouchStart(ev: any) {
|
private handleTouchStart(ev: any) {
|
||||||
@ -38,8 +37,12 @@ export class PointerEvents {
|
|||||||
if (!this.rmTouchMove) {
|
if (!this.rmTouchMove) {
|
||||||
this.rmTouchMove = listenEvent(this.ele, 'touchmove', this.zone, this.option, this.pointerMove);
|
this.rmTouchMove = listenEvent(this.ele, 'touchmove', this.zone, this.option, this.pointerMove);
|
||||||
}
|
}
|
||||||
|
let handleTouchEnd = (ev: any) => this.handleTouchEnd(ev);
|
||||||
if (!this.rmTouchEnd) {
|
if (!this.rmTouchEnd) {
|
||||||
this.rmTouchEnd = listenEvent(this.ele, 'touchend', this.zone, this.option, (ev: any) => this.handleTouchEnd(ev));
|
this.rmTouchEnd = listenEvent(this.ele, 'touchend', this.zone, this.option, handleTouchEnd);
|
||||||
|
}
|
||||||
|
if (!this.rmTouchCancel) {
|
||||||
|
this.rmTouchCancel = listenEvent(this.ele, 'touchcancel', this.zone, this.option, handleTouchEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,35 +63,38 @@ export class PointerEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private handleTouchEnd(ev: any) {
|
private handleTouchEnd(ev: any) {
|
||||||
this.rmTouchMove && this.rmTouchMove();
|
this.stopTouch();
|
||||||
this.rmTouchMove = null;
|
|
||||||
this.rmTouchEnd && this.rmTouchEnd();
|
|
||||||
this.rmTouchEnd = null;
|
|
||||||
|
|
||||||
this.pointerUp(ev);
|
this.pointerUp(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleMouseUp(ev: any) {
|
private handleMouseUp(ev: any) {
|
||||||
this.rmMouseMove && this.rmMouseMove();
|
this.stopMouse();
|
||||||
this.rmMouseMove = null;
|
|
||||||
this.rmMouseUp && this.rmMouseUp();
|
|
||||||
this.rmMouseUp = null;
|
|
||||||
|
|
||||||
this.pointerUp(ev);
|
this.pointerUp(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
private stopTouch() {
|
||||||
this.rmTouchMove && this.rmTouchMove();
|
this.rmTouchMove && this.rmTouchMove();
|
||||||
this.rmTouchEnd && this.rmTouchEnd();
|
this.rmTouchEnd && this.rmTouchEnd();
|
||||||
|
this.rmTouchCancel && this.rmTouchCancel();
|
||||||
|
|
||||||
this.rmTouchMove = null;
|
this.rmTouchMove = null;
|
||||||
this.rmTouchEnd = null;
|
this.rmTouchEnd = null;
|
||||||
|
this.rmTouchCancel = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private stopMouse() {
|
||||||
this.rmMouseMove && this.rmMouseMove();
|
this.rmMouseMove && this.rmMouseMove();
|
||||||
this.rmMouseUp && this.rmMouseUp();
|
this.rmMouseUp && this.rmMouseUp();
|
||||||
|
|
||||||
this.rmMouseMove = null;
|
this.rmMouseMove = null;
|
||||||
this.rmMouseUp = null;
|
this.rmMouseUp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
this.stopTouch();
|
||||||
|
this.stopMouse();
|
||||||
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.rmTouchStart && this.rmTouchStart();
|
this.rmTouchStart && this.rmTouchStart();
|
||||||
this.rmTouchStart = null;
|
this.rmTouchStart = null;
|
||||||
|
Reference in New Issue
Block a user