提交 46842f0e 编写于 作者: I isidor

touch: prevent default and stop propagating if found an appropriat target to dispatch

fixes #39180
上级 0287d832
......@@ -70,6 +70,7 @@ export class Gesture implements IDisposable {
private static INSTANCE: Gesture;
private static HOLD_DELAY = 700;
private dispatched: boolean;
private targets: HTMLElement[];
private toDispose: IDisposable[];
private handle: IDisposable;
......@@ -137,6 +138,12 @@ export class Gesture implements IDisposable {
evt.pageY = touch.pageY;
this.dispatchEvent(evt);
}
if (this.dispatched) {
e.preventDefault();
e.stopPropagation();
this.dispatched = false;
}
}
private onTouchEnd(e: TouchEvent): void {
......@@ -197,6 +204,12 @@ export class Gesture implements IDisposable {
// forget about this touch
delete this.activeTouches[touch.identifier];
}
if (this.dispatched) {
e.preventDefault();
e.stopPropagation();
this.dispatched = false;
}
}
private newGestureEvent(type: string, intialTarget?: EventTarget): GestureEvent {
......@@ -210,6 +223,7 @@ export class Gesture implements IDisposable {
this.targets.forEach(target => {
if (event.initialTarget instanceof Node && target.contains(event.initialTarget)) {
target.dispatchEvent(event);
this.dispatched = true;
}
});
}
......@@ -280,5 +294,11 @@ export class Gesture implements IDisposable {
data.rollingPageY.push(touch.pageY);
data.rollingTimestamps.push(timestamp);
}
if (this.dispatched) {
e.preventDefault();
e.stopPropagation();
this.dispatched = false;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册