Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timoxley/offset
Get offset of an element within the document
https://github.com/timoxley/offset
Last synced: 6 days 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 (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-19T22:12:39.000Z (over 9 years ago)
- Last Synced: 2024-10-17T00:11:03.155Z (28 days 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