Browse Source

chore: remove deprecated `scroll-touch-{begin,end,edge}` events (#39814)

* chore: remove deprecated `scroll-touch-{begin,end,edge}` events

* update spec/ts-smoke

---------

Co-authored-by: John Kleinschmidt <[email protected]>
Milan Burda 1 year ago
parent
commit
c9eb3deab5
3 changed files with 7 additions and 53 deletions
  1. 0 30
      docs/api/browser-window.md
  2. 0 23
      lib/browser/api/browser-window.ts
  3. 7 0
      spec/ts-smoke/electron/main.ts

+ 0 - 30
docs/api/browser-window.md

@@ -367,36 +367,6 @@ The following app commands are explicitly supported on Linux:
 * `browser-backward`
 * `browser-forward`
 
-#### Event: 'scroll-touch-begin' _macOS_ _Deprecated_
-
-Emitted when scroll wheel event phase has begun.
-
-> **Note**
-> This event is deprecated beginning in Electron 22.0.0. See [Breaking
-> Changes](../breaking-changes.md#deprecated-browserwindow-scroll-touch--events)
-> for details of how to migrate to using the [WebContents
-> `input-event`](./web-contents.md#event-input-event) event.
-
-#### Event: 'scroll-touch-end' _macOS_ _Deprecated_
-
-Emitted when scroll wheel event phase has ended.
-
-> **Note**
-> This event is deprecated beginning in Electron 22.0.0. See [Breaking
-> Changes](../breaking-changes.md#deprecated-browserwindow-scroll-touch--events)
-> for details of how to migrate to using the [WebContents
-> `input-event`](./web-contents.md#event-input-event) event.
-
-#### Event: 'scroll-touch-edge' _macOS_ _Deprecated_
-
-Emitted when scroll wheel event phase filed upon reaching the edge of element.
-
-> **Note**
-> This event is deprecated beginning in Electron 22.0.0. See [Breaking
-> Changes](../breaking-changes.md#deprecated-browserwindow-scroll-touch--events)
-> for details of how to migrate to using the [WebContents
-> `input-event`](./web-contents.md#event-input-event) event.
-
 #### Event: 'swipe' _macOS_
 
 Returns:

+ 0 - 23
lib/browser/api/browser-window.ts

@@ -1,6 +1,5 @@
 import { BaseWindow, WebContents, BrowserView, TouchBar } from 'electron/main';
 import type { BrowserWindow as BWT } from 'electron/main';
-import * as deprecate from '@electron/internal/common/deprecate';
 const { BrowserWindow } = process._linkedBinding('electron_browser_window') as { BrowserWindow: typeof BWT };
 
 Object.setPrototypeOf(BrowserWindow.prototype, BaseWindow.prototype);
@@ -53,28 +52,6 @@ BrowserWindow.prototype._init = function (this: BWT) {
     this.on(event as any, visibilityChanged);
   }
 
-  const warn = deprecate.warnOnceMessage('\'scroll-touch-{begin,end,edge}\' are deprecated and will be removed. Please use the WebContents \'input-event\' event instead.');
-  this.webContents.on('input-event', (_, e) => {
-    if (e.type === 'gestureScrollBegin') {
-      if (this.listenerCount('scroll-touch-begin') !== 0) {
-        warn();
-        this.emit('scroll-touch-edge');
-        this.emit('scroll-touch-begin');
-      }
-    } else if (e.type === 'gestureScrollUpdate') {
-      if (this.listenerCount('scroll-touch-edge') !== 0) {
-        warn();
-        this.emit('scroll-touch-edge');
-      }
-    } else if (e.type === 'gestureScrollEnd') {
-      if (this.listenerCount('scroll-touch-end') !== 0) {
-        warn();
-        this.emit('scroll-touch-edge');
-        this.emit('scroll-touch-end');
-      }
-    }
-  });
-
   // Notify the creation of the window.
   app.emit('browser-window-created', { preventDefault () {} }, this);
 

+ 7 - 0
spec/ts-smoke/electron/main.ts

@@ -1284,6 +1284,13 @@ win4.loadURL('http://github.com');
 // @ts-expect-error Removed API
 win4.webContents.getPrinters();
 
+// @ts-expect-error Removed API
+win4.webContents.on('scroll-touch-begin', () => {});
+// @ts-expect-error Removed API
+win4.webContents.on('scroll-touch-edge', () => {});
+// @ts-expect-error Removed API
+win4.webContents.on('scroll-touch-end', () => {});
+
 // TouchBar
 // https://github.com/electron/electron/blob/main/docs/api/touch-bar.md