From 0ab6bb6aed0412659b1f4ba9819cba53b311a491 Mon Sep 17 00:00:00 2001 From: ecarril6 <91155052+ecarril6@users.noreply.github.com> Date: Sun, 1 May 2022 21:17:26 -0600 Subject: [PATCH] CATALOG.md: add "Window Size and Position" section (PR #1349) --- CATALOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CATALOG.md b/CATALOG.md index 25ae2d7..115dca5 100644 --- a/CATALOG.md +++ b/CATALOG.md @@ -1,3 +1,25 @@ +# General Recipes + +## Window Size and Position + +- This allows the last set window size and position to be remembered and applied if application is closed. + +```sh +nativefier 'https://open.google.com/' + --inject window.js +``` +Notes: +- [Inject](https://github.com/nativefier/nativefier/blob/master/API.md#inject) the following javascript as `windows.js` to prevent the window size and position to reset. +```javascript +function storeWindowPos() { +window.localStorage.setItem('windowX', window.screenX); +window.localStorage.setItem('windowY', window.screenY); +} + +window.moveTo(window.localStorage.getItem('windowX'), window.localStorage.getItem('windowY')); +setInterval(storeWindowPos, 250); +``` + # Build Commands Catalog Below you'll find a list of build commands contributed by the Nativefier community. They are here as examples, to help you nativefy "complicated" apps that need a bit of elbow grease to work. We need your help to enrich it, as long as you follow these two guidelines: