Skip to content

Commit 7a880a3

Browse files
authored
Merge pull request #118 from arduino/feature/splashscreen
Feature/splashscreen
2 parents 180cb19 + 2b36cfa commit 7a880a3

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

index.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const registerIPCHandlers = require('./backend/ipc.js')
66
const registerMenu = require('./backend/menu.js')
77

88
let win = null // main window
9+
let splash = null
10+
let splashTimestamp = null
911

1012
// START APP
1113
function createWindow () {
@@ -17,23 +19,42 @@ function createWindow () {
1719
nodeIntegration: false,
1820
webSecurity: true,
1921
enableRemoteModule: false,
20-
preload: path.join(__dirname, "preload.js")
22+
preload: path.join(__dirname, "preload.js"),
23+
show: false
2124
}
2225
})
2326
// and load the index.html of the app.
2427
win.loadFile('ui/arduino/index.html')
2528

29+
// If the app takes a while to open, show splash screen
30+
// Create the splash screen
31+
splash = new BrowserWindow({
32+
width: 450,
33+
height: 140,
34+
transparent: true,
35+
frame: false,
36+
alwaysOnTop: true
37+
});
38+
splash.loadFile('ui/arduino/splash.html')
39+
splashTimestamp = Date.now()
40+
41+
win.once('ready-to-show', () => {
42+
if (Date.now()-splashTimestamp > 1000) {
43+
splash.destroy()
44+
} else {
45+
setTimeout(() => {
46+
splash.destroy()
47+
}, 500)
48+
}
49+
win.show()
50+
})
51+
2652
registerIPCHandlers(win, ipcMain, app)
2753
registerMenu(win)
2854

2955
app.on('activate', () => {
3056
if (BrowserWindow.getAllWindows().length === 0) createWindow()
3157
})
32-
// app.on('window-all-closed', () => {
33-
// if (process.platform !== 'darwin') app.quit()
34-
// })
3558
}
3659

37-
38-
// TODO: Loading splash screen
39-
app.whenReady().then(createWindow)
60+
app.on('ready', createWindow)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy