feat: replace scroll-touch* with generic input-event (#35531)
This commit is contained in:
parent
dfb8a2d804
commit
f82a863f65
20 changed files with 253 additions and 138 deletions
|
@ -1,5 +1,6 @@
|
|||
import { BaseWindow, WebContents, Event, 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);
|
||||
|
@ -44,6 +45,28 @@ 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.
|
||||
const event = process._linkedBinding('electron_browser_event').createEmpty();
|
||||
app.emit('browser-window-created', event, this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue