@reach/observe-rect
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Reach observeRect

Observe the rect of a DOM element.

Demo

Installation

npm install @reach/observe-rect
# or
yarn add @reach/observe-rect

Usage

import observeRect from "@reach/observe-rect";

let node = document.getElementById("some-node");

let rectObserver = observeRect(node, rect => {
  console.log("left", rect.left);
  console.log("top", rect.top);
  console.log("height", rect.height);
  console.log("width", rect.width);
});

// start observing
rectObserver.observe();

// stop observing
rectObserver.unobserve();

About

A lot of things can change the position or size of an element, like scrolling, content reflows and user input. This utility observes and notifies you when your element's rect changes.

Legal

MIT License Copyright (c) 2018-present, Ryan Florence

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.0501,042latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.0501,042
1.1.01,804
1.0.5613
1.0.41
1.0.3381
1.0.21
1.0.11
1.0.01

Package Sidebar

Install

npm i @reach/observe-rect

Weekly Downloads

503,844

Version

1.2.0

License

MIT

Unpacked Size

29.6 kB

Total Files

16

Last publish

Collaborators

  • blainekasten
  • chancestrickland
  • mjackson
  • ryanflorence