Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jenslind/electron-positioner
:pushpin: Helps positioning your electron windows.
https://github.com/jenslind/electron-positioner
electron
Last synced: 7 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-01-11T21:08:39.816Z (14 days ago)
- Topics: electron
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 242
- Watchers: 4
- Forks: 19
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-electron - electron-positioner - Position windows at common spots. ![](https://img.shields.io/github/stars/jenslind/electron-positioner.svg?style=social&label=Star) (Library / Position/Size)
- awesome-electron-zh - electron-positioner - Position windows at common spots. (Tools / For Electron)
README
# Electron-positioner [![Build Status](https://travis-ci.org/jenslind/electron-positioner.svg?branch=master)](https://travis-ci.org/jenslind/electron-positioner) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](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