https://github.com/jenslind/electron-positioner
:pushpin: Helps positioning your electron windows.
https://github.com/jenslind/electron-positioner
electron
Last synced: 10 days ago
JSON representation
:pushpin: Helps positioning your electron windows.
- Host: GitHub
- URL: https://github.com/jenslind/electron-positioner
- Owner: jenslind
- Created: 2015-08-16T10:47:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-08-24T22:03:48.000Z (over 5 years ago)
- Last Synced: 2025-03-29T02:05:58.700Z (17 days ago)
- Topics: electron
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 243
- Watchers: 3
- Forks: 19
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-electron - electron-positioner - Position windows at common spots.  (Library / Position/Size)
- awesome-electron-zh - electron-positioner - Position windows at common spots. (Tools / For Electron)
README
# Electron-positioner [](https://travis-ci.org/jenslind/electron-positioner) [](https://github.com/feross/standard)
> Helps positioning your electron windows.## Install
```
npm install --save electron-positioner
```## Usage
```Javascript
var Positioner = require('electron-positioner')
var positioner = new Positioner(browserWindow)// Moves the window top right on the screen.
positioner.move('topRight')// Returns `{x,y}`
positioner.calculate('trayCenter', trayBounds)
```Note, `trayBounds` is only required with the positions that starts with `tray`.
## Docs
#### new Positioner (browserWindow)
Constructor##### BrowserWindow
The [BrowserWindow](https://github.com/atom/electron/blob/master/docs/api/browser-window.md) instance.#### calculate (position, trayBounds)
Returns coordinates `{x,y}`.#### move (position, trayBounds)
Moves the window with `BrowserWindow.setPosition()`##### position
A string telling where to place the window.
Allowed values:
- `trayLeft`
- `trayBottomLeft`
- `trayRight`
- `trayBottomRight`
- `trayCenter`
- `trayBottomCenter`
- `topLeft`
- `topRight`
- `bottomLeft`
- `bottomRight`
- `topCenter`
- `bottomCenter`
- `leftCenter`
- `rightCenter`
- `center`##### trayBounds
Tray bounds, only needed for the following positions:
- `trayLeft`
- `trayBottomLeft`
- `trayRight`
- `trayBottomRight`
- `trayCenter`
- `trayBottomCenter`## Tests
```
npm test
```## License
MIT