use-reveal

1.0.0 • Public • Published

use-reveal

Scroll-reveal react hook for creating beautifuly timed animations

Install

npm install --save use-reveal

Usage

import React from 'react'

import useReveal from 'use-reveal'

const Example = () => {
  const {ref, isRevealed, delay} = useReveal()
  return (
    <div
      ref={ref}
      className={isRevealed ? 'revealed' : 'hidden'}
      data-delay={delay}
    />
  )
}

The useReveal() hook returns an object with these properties:

ref let's you choose the element to be detected by passing it to the ref prop.

isRevealed returns false by default. Once the element enters the view, isRevealed changes to true.

delay makes it easy to beautifully timed animations. Elements visible on load have delay from 0 to 1. Elements entering on scroll have delay of .2, because it simply looks good.

Package Sidebar

Install

npm i use-reveal

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

2.54 kB

Total Files

3

Last publish

Collaborators

  • wolfrobert35