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
|
@ -652,18 +652,36 @@ The following app commands are explicitly supported on Linux:
|
|||
* `browser-backward`
|
||||
* `browser-forward`
|
||||
|
||||
#### Event: 'scroll-touch-begin' _macOS_
|
||||
#### Event: 'scroll-touch-begin' _macOS_ _Deprecated_
|
||||
|
||||
Emitted when scroll wheel event phase has begun.
|
||||
|
||||
#### Event: 'scroll-touch-end' _macOS_
|
||||
> **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`](api/web-contents.md#event-input-event) event.
|
||||
|
||||
#### Event: 'scroll-touch-end' _macOS_ _Deprecated_
|
||||
|
||||
Emitted when scroll wheel event phase has ended.
|
||||
|
||||
#### Event: 'scroll-touch-edge' _macOS_
|
||||
> **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`](api/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`](api/web-contents.md#event-input-event) event.
|
||||
|
||||
#### Event: 'swipe' _macOS_
|
||||
|
||||
Returns:
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
# InputEvent Object
|
||||
|
||||
* `type` string - Can be `undefined`, `mouseDown`, `mouseUp`, `mouseMove`,
|
||||
`mouseEnter`, `mouseLeave`, `contextMenu`, `mouseWheel`, `rawKeyDown`,
|
||||
`keyDown`, `keyUp`, `char`, `gestureScrollBegin`, `gestureScrollEnd`,
|
||||
`gestureScrollUpdate`, `gestureFlingStart`, `gestureFlingCancel`,
|
||||
`gesturePinchBegin`, `gesturePinchEnd`, `gesturePinchUpdate`,
|
||||
`gestureTapDown`, `gestureShowPress`, `gestureTap`, `gestureTapCancel`,
|
||||
`gestureShortPress`, `gestureLongPress`, `gestureLongTap`,
|
||||
`gestureTwoFingerTap`, `gestureTapUnconfirmed`, `gestureDoubleTap`,
|
||||
`touchStart`, `touchMove`, `touchEnd`, `touchCancel`, `touchScrollStarted`,
|
||||
`pointerDown`, `pointerUp`, `pointerMove`, `pointerRawUpdate`,
|
||||
`pointerCancel` or `pointerCausedUaAction`.
|
||||
* `modifiers` string[] (optional) - An array of modifiers of the event, can
|
||||
be `shift`, `control`, `ctrl`, `alt`, `meta`, `command`, `cmd`, `isKeypad`,
|
||||
`isAutoRepeat`, `leftButtonDown`, `middleButtonDown`, `rightButtonDown`,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# KeyboardInputEvent Object extends `InputEvent`
|
||||
|
||||
* `type` string - The type of the event, can be `keyDown`, `keyUp` or `char`.
|
||||
* `type` string - The type of the event, can be `rawKeyDown`, `keyDown`, `keyUp` or `char`.
|
||||
* `keyCode` string - The character that will be sent
|
||||
as the keyboard event. Should only use the valid key codes in
|
||||
[Accelerator](../accelerator.md).
|
||||
|
|
|
@ -411,6 +411,16 @@ Emitted when a plugin process has crashed.
|
|||
|
||||
Emitted when `webContents` is destroyed.
|
||||
|
||||
#### Event: 'input-event'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `inputEvent` [InputEvent](structures/input-event.md)
|
||||
|
||||
Emitted when an input event is sent to the WebContents. See
|
||||
[InputEvent](structures/input-event.md) for details.
|
||||
|
||||
#### Event: 'before-input-event'
|
||||
|
||||
Returns:
|
||||
|
|
|
@ -12,6 +12,32 @@ This document uses the following convention to categorize breaking changes:
|
|||
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
|
||||
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
|
||||
|
||||
## Planned Breaking API Changes (23.0)
|
||||
|
||||
### Removed: BrowserWindow `scroll-touch-*` events
|
||||
|
||||
The deprecated `scroll-touch-begin`, `scroll-touch-end` and `scroll-touch-edge`
|
||||
events on BrowserWindow have been removed. Instead, use the newly available
|
||||
[`input-event` event](api/web-contents.md#event-input-event) on WebContents.
|
||||
|
||||
```js
|
||||
// Removed in Electron 23.0
|
||||
win.on('scroll-touch-begin', scrollTouchBegin)
|
||||
win.on('scroll-touch-edge', scrollTouchEdge)
|
||||
win.on('scroll-touch-end', scrollTouchEnd)
|
||||
|
||||
// Replace with
|
||||
win.webContents.on('input-event', (_, event) => {
|
||||
if (event.type === 'gestureScrollBegin') {
|
||||
scrollTouchBegin()
|
||||
} else if (event.type === 'gestureScrollUpdate') {
|
||||
scrollTouchEdge()
|
||||
} else if (event.type === 'gestureScrollEnd') {
|
||||
scrollTouchEnd()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Planned Breaking API Changes (22.0)
|
||||
|
||||
### Removed: WebContents `new-window` event
|
||||
|
@ -30,6 +56,30 @@ webContents.setWindowOpenHandler((details) => {
|
|||
})
|
||||
```
|
||||
|
||||
### Deprecated: BrowserWindow `scroll-touch-*` events
|
||||
|
||||
The `scroll-touch-begin`, `scroll-touch-end` and `scroll-touch-edge` events on
|
||||
BrowserWindow are deprecated. Instead, use the newly available [`input-event`
|
||||
event](api/web-contents.md#event-input-event) on WebContents.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
win.on('scroll-touch-begin', scrollTouchBegin)
|
||||
win.on('scroll-touch-edge', scrollTouchEdge)
|
||||
win.on('scroll-touch-end', scrollTouchEnd)
|
||||
|
||||
// Replace with
|
||||
win.webContents.on('input-event', (_, event) => {
|
||||
if (event.type === 'gestureScrollBegin') {
|
||||
scrollTouchBegin()
|
||||
} else if (event.type === 'gestureScrollUpdate') {
|
||||
scrollTouchEdge()
|
||||
} else if (event.type === 'gestureScrollEnd') {
|
||||
scrollTouchEnd()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Planned Breaking API Changes (20.0)
|
||||
|
||||
### Behavior Changed: V8 Memory Cage enabled
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue