You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-use-rect

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-rect

Hook that measures element boundaries

1.0.0
Source
npmnpm
Version published
Weekly downloads
1.2K
-10.8%
Maintainers
1
Weekly downloads
 
Created
Source

react-use-rect

This hook makes it easy to measure a DOM element boundaries (DOMRect).

It's especially useful when it's needed to re-measure boundaries when element size changes, window resizes, parent element scrolls or transition ends as well.

Installation

npm install react-use-rect

Usage

import React from 'react';
import { useRect } from 'react-use-rect';

function Component() {
  const [rect, ref] = useRect();
  return <div ref={ref} />;
}

Options

The hook accepts an object of options.

useRect({ scroll: true, transitionEnd: true });

scroll

default: false

If enabled, element boundaries will be re-measured when the scroll took place.

transitionEnd

default: false

If enabled, element boundaries will be re-measured when transition ends.

FAQs

Package last updated on 20 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts