Skip to content

amorriscode/use-overflow

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
May 16, 2020 10:02
May 16, 2020 10:02
May 16, 2020 10:02
May 16, 2020 10:10
May 16, 2020 10:02
May 16, 2020 10:02
January 10, 2022 06:51
April 7, 2023 17:48
May 16, 2020 10:02
May 16, 2020 10:02
May 16, 2020 10:02

use-overflow

A React Hook that allows you to detect X and Y overflow.

NPM JavaScript Style Guide

Install

npm install --save use-overflow
OR
yarn add use-overflow

Usage

Check out the live example.

import * as React from 'react'

import { useOverflow } from 'use-overflow'

const Example = () => {
  const horizontalRef = React.useRef(null);
  const { refXOverflowing, refXScrollBegin, refXScrollEnd } = useOverflow(horizontalRef);

  const verticalRef = React.useRef(null);
  const { refYOverflowing, refYScrollBegin, refYScrollEnd } = useOverflow(verticalRef);

  return (
    <div>
      {/* Conditional do stuff based on overflow! */}
    </div>
  )
}

License

MIT © amorriscode


This hook is created using create-react-hook.