From aa1e29286a8c00df0ffdceeb4603fbabf67b7893 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 16 Sep 2019 15:54:49 +0200 Subject: [PATCH] Prevent back/forward gestures on macos --- src/vs/base/browser/dom.ts | 13 +++++++------ .../viewParts/editorScrollbar/editorScrollbar.ts | 1 - src/vs/workbench/browser/web.main.ts | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index 3e141077dce8f..9887331522f8b 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -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(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); } diff --git a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts index 4c95ac9934cb4..d816f1265e829 100644 --- a/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts +++ b/src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts @@ -36,7 +36,6 @@ export class EditorScrollbar extends ViewPart { const fastScrollSensitivity = options.get(EditorOption.fastScrollSensitivity); const scrollbarOptions: ScrollableElementCreationOptions = { - alwaysConsumeMouseWheel: true, listenOnDomNode: viewDomNode.domNode, className: 'editor-scrollable' + ' ' + getThemeTypeSelector(context.theme.type), useShadows: false, diff --git a/src/vs/workbench/browser/web.main.ts b/src/vs/workbench/browser/web.main.ts index dc2ea7b6a7bf1..be720535c8575 100644 --- a/src/vs/workbench/browser/web.main.ts +++ b/src/vs/workbench/browser/web.main.ts @@ -75,6 +75,11 @@ class CodeRendererMain extends Disposable { // Layout this._register(addDisposableListener(window, EventType.RESIZE, () => workbench.layout())); + // Prevent the back/forward gestures in macOS + this._register(addDisposableListener(this.domElement, EventType.WHEEL, (e) => { + e.preventDefault(); + }, { passive: false })); + // Workbench Lifecycle this._register(workbench.onBeforeShutdown(event => { if (services.storageService.hasPendingUpdate) {