npm.io
1.0.0 • Published 10 years ago

@f/element-rect

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0
Stars
1

element-rect

Build status Git tag NPM version Code style

Get the bounding rect of an element, optionally relative to a particular parent

Installation

$ npm install @f/element-rect

Usage

Use this to get the offset of an element relative to another on the page. This is useful for positioning things like tooltips and other overlays that appear near another element.

API

elementRect(node, offsetParent)
  • node - The node who's rect you want to get
  • offsetParent - The parent node you want the offset relative to. Usually node.offsetParent (passing true is shorthand for this).

Returns: The rect {top, left, width, height} of node relative to offsetParent (or absolute, if unspecified).

License

MIT