element-relative-center
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

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

Package Sidebar

Install

npm i element-relative-center

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • saintplay