0.8.0 • Published 3 months ago

simple-reveal v0.8.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

SimpleReveal

npm.io npm.io npm.io npm.io npm.io

A simple scroll animation library in React

  • Zero-dependency
  • No additional DOM element
  • Simple and predictable API
  • SSR Support (Next.js, Gatsby)
  • Automatically compensates transition delay
    • The delay only works when it is first revealed, and disables the delay when it is revealed when scrolling.
  • TypeScript Support
  • Respect @media (prefers-reduced-motion)

Demo

Edit SimpleReveal Demo

Getting started

$ yarn add simple-reveal

How to use

If you have a component like this:

import React from "react";

const MyComponent: React.FC = () => {
  return (
    <div>
      <h1 className="title">I want to put a reveal animation here</h1>
    </div>
  );
};

You can add animations using <SimpleReveal /> component like this:

import "simple-reveal/index.css";

import React from "react";
import { SimpleReveal } from "simple-reveal";

const MyComponent: React.FC = () => {
  return (
    <div>
      <SimpleReveal
        render={({ ref, cn, style }) => (
          <h1 ref={ref} className={cn("title")} style={style}>
            I want to put a reveal animation here
          </h1>
        )}
        // options (optional)
        duration={500}
        delay={0}
        initialTransform="translateY(1rem)"
      />
    </div>
  );
};

Or you can use animation using useSimpleReveal() hook like this:

import "simple-reveal/index.css";

import React from "react";
import { useSimpleReveal } from "simple-reveal";

const MyComponent: React.FC = () => {
  const { ref, cn, style } = useSimpleReveal({
    duration: 500,
    delay: 0,
    initialTransform: "translateY(1rem)",
  });

  return (
    <div>
      <h1 ref={ref} className={cn("title")} style={style}>
        I want to put a reveal animation here
      </h1>
    </div>
  );
};

Contributors

0.8.0

3 months ago

0.7.1

9 months ago

0.7.0

10 months ago

0.6.0

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago