node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

offset-in-viewport

offset

Get offset of a dom element within the viewport.

Installation

$ component install timoxley/offset

API

offset(el)

Get offset of an element within the viewport.

Example:

var offset = require('offset')
var target = document.getElementById('target')
console.log(offset(target))
// => {top: 69, left: 108} 

Credit

Code adapted from jQuery.

License

MIT