Prevent back/forward gestures on macos

This commit is contained in:
Alex Dima
2019-09-16 15:54:49 +02:00
parent 449b87dad8
commit aa1e29286a
3 changed files with 12 additions and 7 deletions

View File

@@ -205,14 +205,14 @@ class DomListener implements IDisposable {
private _handler: (e: any) => void;
private _node: Element | Window | Document;
private readonly _type: string;
private readonly _useCapture: boolean;
private readonly _options: boolean | AddEventListenerOptions;
constructor(node: Element | Window | Document, type: string, handler: (e: any) => void, useCapture?: boolean) {
constructor(node: Element | Window | Document, type: string, handler: (e: any) => void, options?: boolean | AddEventListenerOptions) {
this._node = node;
this._type = type;
this._handler = handler;
this._useCapture = (useCapture || false);
this._node.addEventListener(this._type, this._handler, this._useCapture);
this._options = (options || false);
this._node.addEventListener(this._type, this._handler, this._options);
}
public dispose(): void {
@@ -221,7 +221,7 @@ class DomListener implements IDisposable {
return;
}
this._node.removeEventListener(this._type, this._handler, this._useCapture);
this._node.removeEventListener(this._type, this._handler, this._options);
// Prevent leakers from holding on to the dom or handler func
this._node = null!;
@@ -231,7 +231,8 @@ class DomListener implements IDisposable {
export function addDisposableListener<K extends keyof GlobalEventHandlersEventMap>(node: Element | Window | Document, type: K, handler: (event: GlobalEventHandlersEventMap[K]) => void, useCapture?: boolean): IDisposable;
export function addDisposableListener(node: Element | Window | Document, type: string, handler: (event: any) => void, useCapture?: boolean): IDisposable;
export function addDisposableListener(node: Element | Window | Document, type: string, handler: (event: any) => void, useCapture?: boolean): IDisposable {
export function addDisposableListener(node: Element | Window | Document, type: string, handler: (event: any) => void, useCapture: AddEventListenerOptions): IDisposable;
export function addDisposableListener(node: Element | Window | Document, type: string, handler: (event: any) => void, useCapture?: boolean | AddEventListenerOptions): IDisposable {
return new DomListener(node, type, handler, useCapture);
}