mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
feat: Add will-resize event to TopLevelWindow (#13649)
The new `will-resize` event can be used to prevent the resize from happening before the native window is actually resized. This is in contrast to the existing the `resize` event, which is sent *after* the native window has already been resized. For apps with e.g. custom window snapping logic, the `resize` event is not sufficient because it will result in flickering between the dragged size and the snapped size. `will-resize` is only emitted on macOS and Windows.
This commit is contained in:
committed by
Cheng Zhao
parent
9af9634f7d
commit
c8dc2d3730
@@ -490,9 +490,20 @@ Emitted when the window is minimized.
|
||||
|
||||
Emitted when the window is restored from a minimized state.
|
||||
|
||||
#### Event: 'will-resize' _macOS_ _Windows_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `newBounds` [`Rectangle`](structures/rectangle.md) - Size the window is being resized to.
|
||||
|
||||
Emitted before the window is resized. Calling `event.preventDefault()` will prevent the window from being resized.
|
||||
|
||||
Note that this is only emitted when the window is being resized manually. Resizing the window with `setBounds`/`setSize` will not emit this event.
|
||||
|
||||
#### Event: 'resize'
|
||||
|
||||
Emitted when the window is being resized.
|
||||
Emitted after the window has been resized.
|
||||
|
||||
#### Event: 'move'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user