document-offset

1.0.4 • Public • Published

document-offset

Get offset of a DOM Element or Range within the document.

Installation

$ npm install document-offset

component(1):

$ component install timoxley/offset

API

offset(el)

Get offset of an element within the document (relative to the top left of the document).

Example:

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    3,557
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.4
    3,557
  • 1.0.3
    0
  • 1.0.2
    0

Package Sidebar

Install

npm i document-offset

Weekly Downloads

3,557

Version

1.0.4

License

MIT

Last publish

Collaborators

  • timoxley
  • tootallnate