Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chemzqm/offset
Get the offset of an element relative to body
https://github.com/chemzqm/offset
Last synced: about 1 month ago
JSON representation
Get the offset of an element relative to body
- Host: GitHub
- URL: https://github.com/chemzqm/offset
- Owner: chemzqm
- Created: 2014-04-19T12:34:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-12T19:32:12.000Z (almost 9 years ago)
- Last Synced: 2024-10-29T12:30:27.958Z (about 2 months ago)
- Language: JavaScript
- Size: 36.1 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# offset
Get offset of a dom element within the viewport.
[demo](http://chemzqm.github.io/offset)
**No check for top-level document object**.
## Installation
$ component install chemzqm/offset
## API
### offset(el)
Get offset of an element within the viewport.
Example:
```js
var offset = require('offset')
var target = document.getElementById('target')
console.log(offset(target))
// => {top: 69, left: 108}
```## Credit
Code adapted from jQuery.
## License
MIT