Throttle browser-window 'move' and 'resize' events
Fixes: https://github.com/feross/webtorrent-desktop/issues/1011
This commit is contained in:
@@ -15,6 +15,7 @@ const main = module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
|
const debounce = require('debounce')
|
||||||
|
|
||||||
const app = electron.app
|
const app = electron.app
|
||||||
|
|
||||||
@@ -83,13 +84,13 @@ function init (state, options) {
|
|||||||
win.setMenuBarVisibility(true)
|
win.setMenuBarVisibility(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
win.on('move', function (e) {
|
win.on('move', debounce(function (e) {
|
||||||
send('windowBoundsChanged', e.sender.getBounds())
|
send('windowBoundsChanged', e.sender.getBounds())
|
||||||
})
|
}, 1000))
|
||||||
|
|
||||||
win.on('resize', function (e) {
|
win.on('resize', debounce(function (e) {
|
||||||
send('windowBoundsChanged', e.sender.getBounds())
|
send('windowBoundsChanged', e.sender.getBounds())
|
||||||
})
|
}, 1000))
|
||||||
|
|
||||||
win.on('close', function (e) {
|
win.on('close', function (e) {
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
|
|||||||
Reference in New Issue
Block a user