From 8801a87a58361c1a3eea7fef15f5fd7b0795b76d Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Tue, 4 Oct 2016 22:19:40 -0700 Subject: [PATCH] Throttle browser-window 'move' and 'resize' events Fixes: https://github.com/feross/webtorrent-desktop/issues/1011 --- src/main/windows/main.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/windows/main.js b/src/main/windows/main.js index 44e9f9c4..9da3bb58 100644 --- a/src/main/windows/main.js +++ b/src/main/windows/main.js @@ -15,6 +15,7 @@ const main = module.exports = { } const electron = require('electron') +const debounce = require('debounce') const app = electron.app @@ -83,13 +84,13 @@ function init (state, options) { win.setMenuBarVisibility(true) }) - win.on('move', function (e) { + win.on('move', debounce(function (e) { send('windowBoundsChanged', e.sender.getBounds()) - }) + }, 1000)) - win.on('resize', function (e) { + win.on('resize', debounce(function (e) { send('windowBoundsChanged', e.sender.getBounds()) - }) + }, 1000)) win.on('close', function (e) { if (process.platform !== 'darwin') {