Giter Club home page Giter Club logo

react-animated-css's Introduction

React-Animated-CSS

React component to show or hide elements with animations using Animated.css

npm version npm downloads

Demo

https://digital-flowers.github.io/react-animated-css.html

Install

npm i react-animated-css --save

Note You have to include Animated.css in your html page, this component is just a wrapper for it.

<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
</head>

How to use

very easy to use, just wrap your content with the animated component

import {Animated} from "react-animated-css";

<Animated animationIn="bounceInLeft" animationOut="fadeOut" isVisible={true}>
    <div>
        hello world ;)
    </div>
</Animated>

then you can just toggle the isVisible property to see the animation.

Properties

  • animationIn animation in name, default "fadeIn"
  • animationOut animation out name, default "fadeOut"
  • animationInDelay animation in delay (milliseconds), default 0
  • animationOutDelay animation out delay (milliseconds), default 0
  • animationInDuration animation in duration (milliseconds), default 1000
  • animationOutDuration animation out duration (milliseconds), default 1000
  • style react style property for the inner component
  • isVisible if the component is visible or not, default true
  • innerRef react ref property for the inner component
  • className react className property for the inner component
  • animateOnMount apply animationIn on mount or not, default true

List of animation

All the following animation from animated.css are supported.

Animation Name
bounce
flash
pulse
rubberBand
shake
headShake
swing
tada
wobble
jello
bounceIn
bounceInDown
bounceInLeft
bounceInRight
bounceInUp
bounceOut
bounceOutDown
bounceOutLeft
bounceOutRight
bounceOutUp
fadeIn
fadeInDown
fadeInDownBig
fadeInLeft
fadeInLeftBig
fadeInRight
fadeInRightBig
fadeInUp
fadeInUpBig
fadeOut
fadeOutDown
fadeOutDownBig
fadeOutLeft
fadeOutLeftBig
fadeOutRight
fadeOutRightBig
fadeOutUp
fadeOutUpBig
flipInX
flipInY
flipOutX
flipOutY
lightSpeedIn
lightSpeedOut
rotateIn
rotateInDownLeft
rotateInDownRight
rotateInUpLeft
rotateInUpRight
rotateOut
rotateOutDownLeft
rotateOutDownRight
rotateOutUpLeft
rotateOutUpRight
hinge
jackInTheBox
rollIn
rollOut
zoomIn
zoomInDown
zoomInLeft
zoomInRight
zoomInUp
zoomOut
zoomOutDown
zoomOutLeft
zoomOutRight
zoomOutUp
slideInDown
slideInLeft
slideInRight
slideInUp
slideOutDown
slideOutLeft
slideOutRight
slideOutUp

Give a try

Its 100% smoothly and it looks really nice in some components

note:

From React 17.x.x componentWillReceiveProps will be deprecated and a different strategy is introduced.

react-animated-css's People

Contributors

ashishxvenom avatar cguess avatar dependabot[bot] avatar digital-flowers avatar drochag avatar kuzdogan avatar laysent avatar manu-st avatar mrf345 avatar pranjaligharat avatar rachit995 avatar xuanduc987 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-animated-css's Issues

refresh list

When I refresh list via Ajax, it does not animate again after reloading the array of divs again..

animate an array, always apply the animations to last element even when I unshift new item into first position

I have a list of items. Parent component inserts an item at position 0.
The expected behavior is the animation to be applied to inserted item at position 0. Instead, the animation is being applied to the last item. Am I missing out something, or the library is not ready to reason that?

const list= (props) => {
    return (
      <div>
          {props.items.map((el) =>
              <div key={props.id}>
                  <Animated animationIn="fadeInDown">
                      <Item {...el}  />
                  </Animated>
              </div
         )}
      </div>
    );
};
export default list;

Ps. Great job on the library. Super easy to work with :)

loop for the effect

Hello there,

is there any chance to set it in loop, for example to build Interval that refreshing animation every let's say 10sec? Was trying to mount isVisible true/false with Interval but it didnt helped. If you can help in that case, it would be really great. Thanks in advance!

Animation when mapping individual images.

Animation seems to group together all my items in my array when I am trying to have each individual item animate as is its rendered. Anything I am doing wrong?

 const gallery = images.map((obj, i) => {
      return (
        <Animated key={i} animationIn="bounceInRight" animationOut="fadeOut" animationInDelay={40} isVisible={true} animateOnMount={true}>
          <div key={i} className={`` + obj.category} data-category={obj.category}>
            <img alt=""
              className=""
              onClick={(e) => this.openLightbox(i, e)}
              src={obj.thumbnail}
              style={{ width: "100%", height: "auto", display: "block" }}
            />
          </div>
        </Animated>
      );

animation on scroll

How do I animate the object on scrolling, I'm still a beginner at coding.

property children does not exist

while using the library on a new react app created with newest node
npx create-react-app my-app --template typescript

when just adding newest library via yarn (1.2.1) and using the simplest test code


hello world ;)

I get this error message

TS2769: No overload matches this call.
Overload 1 of 2, '(props: AnimatedProps | Readonly): Animated', gave the following error.
Type '{ children: Element; animationIn: "bounceInLeft"; animationOut: "fadeOut"; isVisible: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.
Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.
Overload 2 of 2, '(props: AnimatedProps, context: any): Animated', gave the following error.
Type '{ children: Element; animationIn: "bounceInLeft"; animationOut: "fadeOut"; isVisible: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.
Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.

I tried other versions starting from 1.0.0 and always I get the same error message.

Did I miss something? thanks in advance

animated div shows under other content.

I'm looking to have the animated div contents show on top of any other content. I tried adding a className to animated and give it a large z-index but it still shows up underneath other content.

Warning: componentWillReceiveProps has been renamed, and is not recommended for use ... Please update the following components: Animated

When using [email protected] (with react 16.10.2), I get this warning:

backend.js:6 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

Please update the following components: Animated

If I drop react-animated-css from my project, the warning disappears.

What do you suggest me to do?

Not able to hide animation on reload

How to hide animation during initial page reload?

When I set animateOnMount: false, it will not animate during initial page load indeed, but every single time when you perform animation after that, after animation the animated block will disappear.

Basically, idea is to have element hidden initially, and then animate (in and out) for specific events.

Any ideas how to resolve this?

"this.props" vs "nextProps"

Are you sure that's OK to use this.props in the 103 line? I need to have different animationOut effects for two different buttons and this.props disable this ability. When I changed it to nextProps it start work fine.

error if i used typescript

No overload matches this call.
Overload 1 of 2, '(props: AnimatedProps | Readonly): Animated', gave the following error.
Type '{ children: Element; animationIn: "bounceInLeft"; animationOut: "fadeOut"; isVisible: true; Read: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.
Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.
Overload 2 of 2, '(props: AnimatedProps, context: any): Animated', gave the following error.
Type '{ children: Element; animationIn: "bounceInLeft"; animationOut: "fadeOut"; isVisible: true; Read: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.
Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly'.

It render when page loads

It renders when the page loads so bottom sections does not show any animation, how to show it view time?

How to use it with react router

There's an issue with me using react-animated-css with react-router. I am currently wrapping Components with like this: <Animated animationIn="slideInRight" animationOut="slideOutLeft" isVisible={true}> <Route exact path="/somepath" component={someComponent} /> </Animated>
It works fine when I am using it with components not defined on explicit routes but when I am using It on components while changing routes the animations don't work on init. However when I reload the same component the animation works on init.

Compiled with problems:

Compiled with problems:X

ERROR in ./node_modules/react-animated-css/lib/index.js 39:16-37

Module not found: Error: Can't resolve './prefixer' in 'D:\OnGoing Projects\xnation-reactjs\node_modules\react-animated-css\lib'

image

Careful with ie

This package is not working on IE for me… any workaround?

Safari animation issue

Hi there

I am having an issue wth safari where the bounce effect is going crazy. The animations is extremely fast. These are the code snippets I have been using

//JSX
<Animated animationIn="bounce" animationOut="bounce" isVisible={true} style={styles.animationTime}> <VisaContainer /> </Animated>

//css
animationDuration: '15s, 30s, 200ms', animationIterationCount: 'infinite',

It works fine on Chrome

Unable to build with GatsbyJS due to react-prefixer using window and document

Hello,

I've been playing around with GatsbyJS lately and have built an example site for learning. I've always used animated.css for animations and never had a problem. Unfortunately, due to one of your dependencies react-prefixer which is no longer maintained: https://www.npmjs.com/package/react-prefixer it accesses window and document which in the GatsbyJS world at build time doesn't exist as its in Node and not in a browser.

PR: rapid7/react-prefixer#10

The fix is actually quite simple and I have created a PR to solve this but as the package is no longer maintained I don't know if this will ever be merged. Are you able to use a different package or remove it entirely?

I'm happy to help where I can, just let me know :)

animation on component update.

I am using react-animated-css, for simple animation in react. I have a list which I am rendering in a

    tag. I am adding animation to the first element of the list.

    This list is getting updated every 3 seconds. And new element is added at the first position in the array. The problem is, on load the animation is happening but not on update.

    Here is full code : https://codesandbox.io/embed/ecstatic-cloud-qdpcj

Animation is over

The library is awesome I love the implementation. I was just wondering if there is a way to know if the animation is over?

animationOut not working

Hey , I m using the zoomIn and ZoomOut the issue is zoomOut is not working
here is the my code snippet

Mobile not working

Hi. Do you know how make this work in mobile browsers? Even the examples do not animate. Thanks

TypeScript definition file

I came up with the following TypeScript definition file:

// Type definitions for react-animated-css 1.0.1
// Project: https://github.com/digital-flowers/react-animated-css

// <reference types="react" />

declare namespace ReactAnimated
{
   type AnimationString =
      "bounce" | "flash" | "pulse" | "rubberBand" | "shake" | "headShake" | "swing" | "tada" | "wobble" |
      "jello" | "bounceIn" | "bounceInDown" | "bounceInLeft" | "bounceInRight" | "bounceInUp" | "bounceOut" |
      "bounceOutDown" | "bounceOutLeft" | "bounceOutRight" | "bounceOutUp" | "fadeIn" | "fadeInDown" | "fadeInDownBig" |
      "fadeInLeft" | "fadeInLeftBig" | "fadeInRight" | "fadeInRightBig" | "fadeInUp" | "fadeInUpBig" | "fadeOut" | "fadeOutDown" |
      "fadeOutDownBig" | "fadeOutLeft" | "fadeOutLeftBig" | "fadeOutRight" | "fadeOutRightBig" | "fadeOutUp" | "fadeOutUpBig" |
      "flipInX" | "flipInY" | "flipOutX" | "flipOutY" | "lightSpeedIn" | "lightSpeedOut" | "rotateIn" | "rotateInDownLeft" |
      "rotateInDownRight" | "rotateInUpLeft" | "rotateInUpRight" | "rotateOut" | "rotateOutDownLeft" | "rotateOutDownRight" |
      "rotateOutUpLeft" | "rotateOutUpRight" | "hinge" | "jackInTheBox" | "rollIn" | "rollOut" | "zoomIn" | "zoomInDown" |
      "zoomInLeft" | "zoomInRight" | "zoomInUp" | "zoomOut" | "zoomOutDown" | "zoomOutLeft" | "zoomOutRight" | "zoomOutUp" |
      "slideInDown" | "slideInLeft" | "slideInRight" | "slideInUp" | "slideOutDown" | "slideOutLeft" | "slideOutRight" | "slideOutUp";

   class Animated extends React.Component<AnimatedProps>
   {
   }

   interface AnimatedProps
   {
      /**
       * The animation-in style.
      * @default "fadeIn"
      */
      animationIn: AnimationString;

      /**
       * The animation-out style.
      * @default "fadeOut"
      */
      animationOut: AnimationString;

      animationInDelay?: number;
      animationOutDelay?: number;
      style?: object;
      isVisible: boolean;
      innerRef?: React.Ref<Animated>;
      className?: string;
      animateOnMount?: boolean;
   }
}

declare module "react-animated-css"
{
   import Animated = ReactAnimated.Animated;

   export = { Animated: Animated };
}

and then you can do in your react TSX file

import Animated = require ("react-animated-css");

....

<Animated.Animated ....>
</Animated.Animated>

Might be good to improve on this and include a TypeScript index.d.ts as part of the project.

Thanks!

animations not working

import React from 'react';
import 'animate.css';
import './style.css';
import { useEffect,useState } from 'react';
import { Image } from '@components';
import { images } from '../ReferenceImages';
import { Animated } from 'react-animated-css';
import 'animate.css'

export const LoginAnimation = () => {
const[isVisi,setISVisi]=useState(false)
console.log(isVisi,"hfvckxbk")

return (




<h1 className='' style={{ height: '500px' }}>
demo

  <div className='col-6'>
 <Animated animationIn="slideInRight" animationOut="fadeOutLeftBig" animationInDuration={800} animationOutDuration={800} isVisible={isVisi} >
    <div> <h1>demo</h1></div>
 </Animated> 
 <button onClick={()=>{setISVisi(!isVisi)}}>click</button>
 <Image src={images.loginImage} className='bg-primary' height={'500px'} />
  </div>
  </div>

</div>

);
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.