Created
June 6, 2017 12:53
-
-
Save tudisco/ef68e59e0b1c87a5376eed79a65b958a to your computer and use it in GitHub Desktop.
Electron Save Window Position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {app, BrowserWindow} = require('electron') | |
const Config = require('electron-config') | |
const config = new Config() | |
let win | |
app.on('ready', () => { | |
let opts = {show: false} | |
Object.assign(opts, config.get('winBounds')) | |
win = new BrowserWindow(opts) | |
win.loadURL(`file://${__dirname}/app/index.html`) | |
win.once('ready-to-show', win.show) | |
// save window size and position | |
win.on('close', () => { | |
config.set('winBounds', win.getBounds()) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment