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-with-css

v1.2.3

Published

React library to animate elements using [Animate.css](https://animate.style/) or your own CSS animation.

Downloads

37

Readme

react-animate-with-css

React library to animate elements using Animate.css or your own CSS animation.

Github repository

How to use

Install

npm i react-animate-with-css

Wrap your App with AnimationContextProvider

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import { AnimationContextProvider } from "react-animate-with-css";

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
  <React.StrictMode>
    <AnimationContextProvider>
        <App />
    </AnimationContextProvider>
  </React.StrictMode>
);

Animate when component is first rendering

import { Animation } from "react-animate-with-css";

export default function App() {
    return (
        <div>
            <Animation animateIn={{ name: "backInLeft" }}>
                <img src="/logo.svg" alt="" />
            </Animation>
        </div>
    );
}

Important:

  • You can't animate the position of components that has a position CSS property fixed or absolute, unless you create your own CSS animation that supports it.
  • I strongly recommend you to always use display flex, it will be much easier to make your CSS to work properly.
  • Keep in mind that the Animation component will try to mimic its parent inheriting the following CSS properties: width, height, display, justify-content and align-items.
  • You can always change this properties passing a style like this: <Animation style={{ width: "40px", justifyContent: "flex-end" }}></Animation>

Animate using ID

import { Animation, useAnimate } from "react-animate-with-css";

export default function App() {
    const { animate } = useAnimate();

    return (
        <div>
            <Animation id="logo-icon">
                <img
                    src="/logo.svg"
                    alt=""
                    onClick={() => {
                        animate({
                            id: "logo-icon",
                            name: "tada",
                        });
                    }}
                />
            </Animation>

            <button
                onClick={() => {
                    animate({
                        id: "logo-icon",
                        name: "backInLeft",
                        duration: 1500,
                        direction: "reverse",
                        removeAfter: true,
                    });
                }}
            >
            </button>
        </div>
    );
}

Properties

animate()

Type: function

A function that allows you to animate any Animation element using its ID.

This is a global function, so it can be called at any line of your code.

[ id ]

Type: string

[ name ]

Type: string

Check Animate.css for demonstrations.

| - Attention seekers - | -        Back        - | -      Bouncings      - | -         Rotating         - | -        Fading In        - | -        Fading Out        - | | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | "bounce" "flash" "pulse" "rubberBand" "shakeX" "shakeY" "headShake" "swing" "tada" "wobble" "jello" "heartBeat" | "backInDown" "backInLeft" "backInRight" "backInUp" "backOutDown" "backOutLeft" "backOutRight" "backOutUp" | "bounceIn" "bounceInDown" "bounceInLeft" "bounceInRight" "bounceInUp" "bounceOut" "bounceOutDown" "bounceOutLeft" "bounceOutRight" "bounceOutUp" | "rotateIn" "rotateInDownLeft" "rotateInDownRight" "rotateInUpLeft" "rotateInUpRight" "rotateOut" "rotateOutDownLeft" "rotateOutDownRight" "rotateOutUpLeft" "rotateOutUpRight" | "fadeIn" "fadeInDown" "fadeInDownBig" "fadeInLeft" "fadeInLeftBig" "fadeInRight" "fadeInRightBig" "fadeInUp" "fadeInUpBig" "fadeInTopLeft" "fadeInTopRight" "fadeInBottomLeft" "fadeInBottomRight" | "fadeOut" "fadeOutDown" "fadeOutDownBig" "fadeOutLeft" "fadeOutLeftBig" "fadeOutRight" "fadeOutRightBig" "fadeOutUp" "fadeOutUpBig" "fadeOutTopLeft" "fadeOutTopRight" "fadeOutBottomRight" "fadeOutBottomLeft" |

| - Flippers - | -     Lightspeed     - | -   Specials   - | - Zooming entrances - | - Zooming exits - | - Sliding entrances - | - Sliding exits - | | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------: | | "flip" "flipInX" "flipInY" "flipOutX" "flipOutY" | "lightSpeedInRight" "lightSpeedInLeft" "lightSpeedOutRight" "lightSpeedOutLeft" | "hinge" "jackInTheBox" "rollIn" "rollOut" | "zoomIn" "zoomInDown" "zoomInLeft" "zoomInRight" "zoomInUp" | "zoomOut" "zoomOutDown" "zoomOutLeft" "zoomOutRight" "zoomOutUp" | "slideInDown" "slideInLeft" "slideInRight" "slideInUp" | "slideOutDown" "slideOutLeft" "slideOutRight" "slideOutUp" |

[ duration? ]

Type: number

[ delay? ]

Type: number

[ repeat? ]

Type: number

[ direction? ]

Type: "normal" | "reverse" | "alternate" | "alternate-reverse"

[ timing? ]

Type: string | "ease" | "ease-in" | "ease-out" | "ease-in-out" | "linear" | "step-start" | "step-end"

[ removeAfter? ]

Type: boolean

animations

Type: object

An object that contains all Animation elements and their current state props.

Example:

{
  icon: { element: <img src="./logo" alt="" />, isAnimating: false, isRemoved: false },
  headerTxt: { element: <p>Title</p>, isAnimating: true, isRemoved: false },
}