Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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