From 6d375d5b5b0a19c91b591586458a74c6269efdc8 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 23 Sep 2016 11:59:22 +0200 Subject: [PATCH] Wait for 'ready-to-show' event before showing window (#959) This gets rid of the light gray to dark gray background color change on the main window at startup. Makes the window show slightly later, but it's gray for less time. Doesn't affect overall startup time. Feels less jank IMO. From the Electron docs: > While loading the page, the 'ready-to-show' event will be emitted when renderer process has done drawing for the first time, showing window after this event will have no visual flash. --- src/main/windows/about.js | 2 +- src/main/windows/main.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/windows/about.js b/src/main/windows/about.js index 3c89c542ce..83cc5155a7 100644 --- a/src/main/windows/about.js +++ b/src/main/windows/about.js @@ -32,7 +32,7 @@ function init () { // No menu on the About window win.setMenu(null) - win.webContents.once('did-finish-load', function () { + win.once('ready-to-show', function () { win.show() }) diff --git a/src/main/windows/main.js b/src/main/windows/main.js index 5f46274c9c..c0c9dd8e32 100644 --- a/src/main/windows/main.js +++ b/src/main/windows/main.js @@ -38,13 +38,17 @@ function init (state, options) { title: config.APP_WINDOW_TITLE, titleBarStyle: 'hidden-inset', // Hide title bar (Mac) useContentSize: true, // Specify web page size without OS chrome - show: !options.hidden, + show: false, width: initialBounds.width, height: initialBounds.height, x: initialBounds.x, y: initialBounds.y }) + win.once('ready-to-show', function () { + if (!options.hidden) win.show() + }) + win.loadURL(config.WINDOW_MAIN) if (win.setSheetOffset) win.setSheetOffset(config.UI_HEADER_HEIGHT)