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

react-use-rect

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-rect

Hook that measures element boundaries

1.1.0-alpha.1
Version published
Weekly downloads
1.1K
-8.37%
Maintainers
1
Weekly downloads
 
Created

react-use-rect

The hook that measures a DOM element boundaries (DOMRect).

It responds to a target element and window size changes, parent elements scroll changes and transition ends as well.

Installation

npm install react-use-rect

Usage

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

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

Options

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

scroll

default: false

If enabled, it will respond to scroll changes.

NOTE: Please, use this option only if you're sure you intend to update an element boundaries on scroll changes. Ubiquitous usage of this option can have a negative impact on scroll performance.

transitionEnd

default: false

If enabled, it will respond to transition ends.

FAQs

Package last updated on 06 Apr 2021

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