mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-11 15:51:06 +00:00
Fix FOUC #159
This commit is contained in:
parent
f9bf66caa5
commit
c3ae29a0ea
@ -131,7 +131,19 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
|||||||
|
|
||||||
mainWindow.webContents.on('did-finish-load', () => {
|
mainWindow.webContents.on('did-finish-load', () => {
|
||||||
mainWindow.webContents.send('params', JSON.stringify(options));
|
mainWindow.webContents.send('params', JSON.stringify(options));
|
||||||
|
// remove the injection of css the moment the page is loaded
|
||||||
|
mainWindow.webContents.removeListener('did-get-response-details', injectCss);
|
||||||
|
});
|
||||||
|
|
||||||
|
const injectCss = () => {
|
||||||
mainWindow.webContents.insertCSS(getCssToInject());
|
mainWindow.webContents.insertCSS(getCssToInject());
|
||||||
|
}
|
||||||
|
|
||||||
|
// on every page navigation inject the css
|
||||||
|
mainWindow.webContents.on('did-start-loading', () => {
|
||||||
|
// we have to inject the css in did-get-response-details to prevent the fouc
|
||||||
|
// will run multiple times
|
||||||
|
mainWindow.webContents.on('did-get-response-details', injectCss);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options.counter) {
|
if (options.counter) {
|
||||||
|
Loading…
Reference in New Issue
Block a user