Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saintplay/element-relative-center
Get the x,y relative coordinates of an element's center
https://github.com/saintplay/element-relative-center
centering coordinates html
Last synced: 7 days ago
JSON representation
Get the x,y relative coordinates of an element's center
- Host: GitHub
- URL: https://github.com/saintplay/element-relative-center
- Owner: saintplay
- License: mit
- Created: 2017-12-12T06:18:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-13T14:39:32.000Z (about 7 years ago)
- Last Synced: 2024-12-11T21:24:29.388Z (about 1 month ago)
- Topics: centering, coordinates, html
- Language: JavaScript
- Size: 36.1 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# element-relative-center
> Get the x,y relative coordinates of an element's center
> Works well with elements with scroll overflow## Install ##
npm install --save element-relative-center
or
yarn add element-relative-center
## Example ##
If the element has a width: 1360px and height: 440
The relative center would be x: 680 and y: 220
*Note:* if the element has scroll overflow, the center will be readjusted## Usage ##
```js
var elementRelativeCenter = require('element-relative-center');
// or
import elementRelativeCenter from 'element-relative-center';var containerEl = document.getElementById('container')
elementRelativeCenter(containerEl)
//=> { x: 680, y: 220 }
```## License ##
MIT © [Diego Jara]([email protected])