https://github.com/timoxley/offset
Get offset of an element within the document
https://github.com/timoxley/offset
Last synced: about 1 month ago
JSON representation
Get offset of an element within the document
- Host: GitHub
- URL: https://github.com/timoxley/offset
- Owner: timoxley
- License: mit
- Created: 2012-10-25T05:18:22.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-19T22:12:39.000Z (almost 10 years ago)
- Last Synced: 2025-01-12T14:24:49.692Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 263 KB
- Stars: 59
- Watchers: 6
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# document-offset
Get offset of a DOM Element or Range within the document.
## Installation
```
$ npm install document-offset
```### [component(1)](http://component.io):
```
$ component install timoxley/offset
```## API
### offset(el)
Get offset of an element within the document (relative to the top left
of the document).Example:
```js
var offset = require('document-offset')
var target = document.getElementById('target')
console.log(offset(target))
// => {top: 69, left: 108}
```## Credit
Code adapted from jQuery.
## License
MIT