mawie81 / electron-window-state

A library to store and restore window sizes and positions for your Electron app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to specify default x and y?

synic opened this issue · comments

commented

The docs do not show it, and I couldn't glean it from reading the code (I'm a JS noob).

Can we also specify the default coordinates?

No, it doesn't look like it. But agreed: it seems reasonable for the app to provide a default x, y in the same manner that it does width and height. Perhaps placed in the center of the screen.

But you can easily code around it: just check to see if the x, y values returned in windowStateKeeper(...) are undefined or not, if they are, set them. For all future updates, that info will be automatically saved in state by the library.

Something like this:

const { x, y, height, width } = windowStateKeeper({
  defaultWidth: 1000,
  defaultHeight: 500
});
if (x === undefined) {
  x = 100;
}
if (y === undefined) {
  y = 100;
}