npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-animate-onview

v0.1.2

Published

A lightweight React component for adding smooth, customizable animations to elements as they enter the viewport.

Downloads

34

Readme

React Animate OnView

npm version License: MIT

A lightweight React component for adding smooth, customizable animations to elements as they enter the viewport. Built with Framer Motion, this package makes it easy to create engaging scroll-based animations in your React applications.

Features

  • Easy to use React component
  • Customizable animation types (fade, slide, zoom, rotate)
  • Configurable animation duration and delay
  • Viewport detection for triggering animations
  • Staggered animations for multiple elements
  • TypeScript support

Installation

npm install react-animate-onview framer-motion

or

yarn add react-animate-onview framer-motion

Usage

Here's a basic example of how to use the AnimateOnView component:

import React from "react";
import { AnimateOnView } from "react-animate-onview";

const MyComponent = () => {
  return (
    <AnimateOnView animation="fadeInFromBottom" duration={0.5} delay={0.2}>
      <h1>This will animate when it enters the viewport</h1>
    </AnimateOnView>
  );
};

export default MyComponent;

API

The AnimateOnView component accepts the following props:

  • animation (required): The type of animation to apply. Options include:
    • "fadeInFromBottom"
    • "fadeInFromLeft"
    • "fadeInFromRight"
    • "zoomIn"
    • "rotateIn"
  • duration (optional): The duration of the animation in seconds. Default is 0.5.
  • delay (optional): The delay before the animation starts in seconds. Default is 0.
  • staggerDelay (optional): The delay between each child element's animation when using staggered animations. Default is 0.1.
  • viewportOnce (optional): If true, the animation only happens once when the element comes into view. Default is false.
  • viewportAmount (optional): The amount of the element that needs to be in view before the animation triggers. Default is 0.1.

Examples

Fade in from bottom

<AnimateOnView animation="fadeInFromBottom">
  <p>This paragraph will fade in from the bottom</p>
</AnimateOnView>

Zoom in with delay

<AnimateOnView animation="zoomIn" duration={0.7} delay={0.3}>
  <img src="example.jpg" alt="Example" />
</AnimateOnView>

Rotate in once

<AnimateOnView animation="rotateIn" viewportOnce={true}>
  <div className="card">
    <h2>Rotating Card</h2>
    <p>This card will rotate in once when it enters the viewport</p>
  </div>
</AnimateOnView>

Staggered animation for multiple elements

<AnimateOnView animation="fadeInFromBottom" staggerDelay={0.2}>
  <h2>Staggered Animation</h2>
  <p>This paragraph appears after the heading</p>
  <button>This button comes last</button>
</AnimateOnView>

Complex layout with mixed animations

<div className="container">
  <AnimateOnView animation="fadeInFromLeft">
    <h1>Welcome to My Site</h1>
  </AnimateOnView>

  <AnimateOnView animation="fadeInFromBottom" staggerDelay={0.15}>
    <p>Here's some introductory text.</p>
    <button>Call to Action</button>
    <div className="image-gallery">
      <img src="image1.jpg" alt="Image 1" />
      <img src="image2.jpg" alt="Image 2" />
      <img src="image3.jpg" alt="Image 3" />
    </div>
  </AnimateOnView>

  <AnimateOnView animation="zoomIn" viewportAmount={0.3}>
    <footer>
      <p>© 2024 My Company</p>
    </footer>
  </AnimateOnView>
</div>

Contributing

Contributions are always welcome! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and adhere to the existing coding style.

Development

To set up the development environment:

  1. Clone the repository
  2. Install dependencies with npm install
  3. Run the build process with npm run build
  4. To test your changes, you can use npm link in the package directory and then npm link react-animate-onview in your test project

Reporting Issues

If you find a bug or have a feature request, please open an issue on the GitHub repository. Provide as much information as possible, including steps to reproduce the issue if applicable.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to Framer Motion for providing the animation capabilities.
  • Inspired by the need for simple, reusable animation components in React applications.

Made with ❤️ by Randil Withanage