don't use executeJavaScript() (fix for PR #107)

It’s not *that* much cleaner, but executeJavaScript() feels too much
like eval().

cc @flet
This commit is contained in:
Feross Aboukhadijeh
2016-03-09 02:38:59 -08:00
parent 944a47be72
commit a6e8a3462e

View File

@@ -48,9 +48,10 @@ function createMainWindow (menu) {
win.on('close', function (e) { win.on('close', function (e) {
if (process.platform === 'darwin' && !isQuitting) { if (process.platform === 'darwin' && !isQuitting) {
e.preventDefault() e.preventDefault()
win.webContents.executeJavaScript('dispatch("pause")', function () { // sendSync() ensures that video will pause before window is hidden, at which point
win.hide() // the update() loop (which uses requestAnimationFrame) ceases to run
}) win.sendSync('dispatch', 'pause')
win.hide()
} }
}) })