When I create basic application and initialize it using electron
command, it shows me a blank window and a moment later loads the content.
Which event and which object should be used to show the window after the content is fully loaded?
did-finish-load
on a window.webContent
object? Or maybe dom-ready
? Or maybe something else?
app.js:
var app = require('app'),
Window = require('browser-window'),
mainWindow = null;
require('crash-reporter').start();
app.on('ready', function() {
mainWindow = new Window({ width: 600, height: 400, show: false });
mainWindow.loadUrl('file://' + __dirname + '/index.html');
mainWindow.show();
//
// mainWindow.webContent.on('did-finish-load', function() {
// something like that is a proper way?
// });
//
});
You can try to load the content in invisible iframe and then create window and transfer content to window from iframe.
OK, I found an answer myself. The proper event is
did-finish-load
and should be used like this:For people finding this answer - here you can check official electron documentation on this topic:
This way works, however best practice is to use
ready-to-show
stated by the API documentation:and please note:
Lastly you should update the background color to match as close to the content background of your window. Here is an example:
You can also add quick css fade to make content snap less. Just add this too your css and set .ui.container to whatever class your root DOM element is. Note, doesn't work if you set it to
<body/>
see these links for more information: https://electron.atom.io/docs/all/#using-ready-to-show-event https://www.christianengvall.se/electron-white-screen-app-startup/