save-window-size-position
v1.0.1
Published
save and restore window size and position
Downloads
3
Readme
save-window-size-position
Save and restore window size and position
Usage
npm i 'save-window-size-position'
// window.html
import { saveWindowStateBeforeUnload, restoreWindowState } from 'save-window-size-position'
restoreWindowState();
saveWindowStateBeforeUnload();
or
// parent.html
import { getSavedWindowState } from 'save-window-size-position';
window.open('./test.html', undefined, `popup=1,${getSavedWindowState()}`);
// won't resize the window on open, but width and height are inaccurate (not only if the user zoomed)
// window.html
import { saveWindowStateBeforeUnload } from 'save-window-size-position'
// restoreWindowState(); // resize to make the window size accurate
saveWindowStateBeforeUnload();
Parameters
restoreWindowState(
defaultOuterWidth,
defaultOuterHeight,
defaultScreenX,
defaultScreenY,
);
getSavedWindowState(
defaultInnerWidth,
defaultInnerHeight,
defaultScreenX,
defaultScreenY,
);