From a6e8a3462ee1241b9fb5e24fb023cc43060b6b95 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 9 Mar 2016 02:38:59 -0800 Subject: [PATCH] don't use executeJavaScript() (fix for PR #107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s not *that* much cleaner, but executeJavaScript() feels too much like eval(). cc @flet --- main/windows.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main/windows.js b/main/windows.js index 5ea6b7b0..6196e691 100644 --- a/main/windows.js +++ b/main/windows.js @@ -48,9 +48,10 @@ function createMainWindow (menu) { win.on('close', function (e) { if (process.platform === 'darwin' && !isQuitting) { e.preventDefault() - win.webContents.executeJavaScript('dispatch("pause")', function () { - win.hide() - }) + // sendSync() ensures that video will pause before window is hidden, at which point + // the update() loop (which uses requestAnimationFrame) ceases to run + win.sendSync('dispatch', 'pause') + win.hide() } })