Skip to content

Commit

Permalink
Wait for 'ready-to-show' event before showing window (#959)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
feross authored and dcposch committed Sep 23, 2016
1 parent 5de39bd commit 6d375d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/windows/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
6 changes: 5 additions & 1 deletion src/main/windows/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6d375d5

Please sign in to comment.