Skip to content

amorriscode/use-overflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 8, 2023
44e45e6 · Apr 8, 2023

History

52 Commits
Aug 19, 2022
May 16, 2020
May 16, 2020
May 16, 2020
May 16, 2020
May 16, 2020
May 16, 2020
Jan 10, 2022
Apr 8, 2023
May 16, 2020
May 16, 2020
May 16, 2020
Aug 19, 2022

Repository files navigation

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.