Code Monkey home page Code Monkey logo

react-animations's Introduction

Maintenance Status

react-animations

A collection of animations that can be used with any inline style library that supports using objects to define keyframe animations, such as Radium or Aphrodite. React-animations implements all animations from animate.css.

Check out the interactive demo.

Explore component collection.

Usage

You can import each animation directly from the main package

import { fadeIn } from 'react-animations'

or you can import a specific animation directly

import fadeIn from 'react-animations/lib/fade-in'

Usage with Radium

import React from 'react';
import { bounce } from 'react-animations';
import Radium, {StyleRoot} from 'radium';

const styles = {
  bounce: {
    animation: 'x 1s',
    animationName: Radium.keyframes(bounce, 'bounce')
  }
}

class Test extends React.Component {
  render() {
    <StyleRoot>
      <div className="test" style={styles.bounce}>
      </div>
    </StyleRoot>
  }
}

Usage with Aphrodite

import { bounce } from 'react-animations';
import { StyleSheet, css } from 'aphrodite';

const styles = StyleSheet.create({
  bounce: {
    animationName: bounce,
    animationDuration: '1s'
  }
})

Usage with JSS

import { bounce } from 'react-animations';
import jss from 'jss'
import preset from 'jss-preset-default'

jss.setup(preset())

const {classes} = jss.createStyleSheet({
  '@keyframes bounce': bounce,
  bounce: {
    animationName: 'bounce',
    animationDuration: '1s',
  },
}).attach()
import styled, { keyframes } from 'styled-components';
import { bounce } from 'react-animations';

const bounceAnimation = keyframes`${bounce}`;

const BouncyDiv = styled.div`
  animation: 1s ${bounceAnimation};
`;

Usage with fela-js

import React from 'react';
import { render } from 'react-dom';
import { createRenderer } from 'fela';
import { createComponent, Provider } from 'react-fela';
import { bounce } from 'react-animations';

const mapStylesToProps = ({ background, height, width }, renderer) => ({
	animationName: renderer.renderKeyframe(() => bounce, {}),
	animationDuration: '2s',
	background,
	height,
	width,
});

const BouncingDiv = createComponent(mapStylesToProps, 'div');

render(
	<Provider renderer={createRenderer()}>
		<BouncingDiv background="red" height="100px" width="100px" />
	</Provider>,
	document.getElementById('root'),
);

Animations

Below is a list of all available animations

bounceOut

bounce

bounceIn

bounceInDown

bounceInLeft

bounceInRight

bounceInUp

bounceOutDown

bounceOutLeft

bounceOutRight

bounceOutUp

fadeIn

fadeInDown

fadeInDownBig

fadeInLeft

fadeInLeftBig

fadeInRight

fadeInRightBig

fadeInUp

fadeInUpBig

fadeOut

fadeOutDown

fadeOutDownBig

fadeOutLeft

fadeOutLeftBig

fadeOutRight

fadeOutRightBig

fadeOutUp

fadeOutUpBig

flash

flip

flipInX

flipInY

flipOutX

flipOutY

headShake

hinge

jello

lightSpeedIn

lightSpeedOut

pulse

rollIn

rollOut

rotateIn

rotateInDownLeft

rotateInDownRight

rotateInUpLeft

rotateInUpRight

rotateOut

rotateOutDownLeft

rotateOutDownRight

rotateOutUpLeft

rotateOutUpRight

rubberBand

shake

slideInDown

slideInLeft

slideInRight

slideInUp

slideOutDown

slideOutLeft

slideOutRight

slideOutUp

swing

tada

wobble

zoomIn

zoomInDown

zoomInLeft

zoomInRight

zoomInUp

zoomOut

zoomOutDown

zoomOutLeft

zoomOutRight

zoomOutUp

Merge

react-animations also exports a merge function that takes two animations and returns a new animation that combines the transforms from both. This is experimental and wont work (well) with animations that have conflicting transforms, such as fadeIn and fadeOut. The merged animation can be used just like any of the imported animations.

import { merge, tada, flip } from 'react-animations';
const tadaFlip = merge(tada, flip);

Maintenance Status

Archived: This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!

react-animations's People

Contributors

aweary avatar boygirl avatar drenther avatar gksander avatar joshk2 avatar jpdriver avatar mbrookes avatar michaeljamie avatar mxstbr avatar rishabhtayal avatar ryan-roemer 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  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

react-animations's Issues

Fade in -> Fade out Animation

Hi.

Looking to animate a modal window with this. I've gotten fadeIn to work, but not sure how I can get it to fade out as well. I'm using Radium.

I've tried:

container: {
    display: 'block',

    hidden: {
      animationName: Radium.keyframes(fadeIn, 'fadeIn')
    },

    visible: {
      animationName: Radium.keyframes(fadeOut, 'fadeOut')
    }
}

And then in my class:

 <div
   role="dialog"
   style={[
   defaultStyles.container,
   rendered ? defaultStyles.container.visible : defaultStyles.container.hidden
   ]}
 >

But does the fadeIn, then the fadeOut, then fadesIn again. Any ideas?

when hide or remove element, animatations not work

when the animate is run over, then the element will be back,
for example:

fadeOutDown: {
    animation: 'x 1s',
    animationName: Radium.keyframes(fadeOutDown, 'fadeOutDown'),
  }

when element is fadeOutDown, then is will be show .

if add display: 'none'
animate not work

Animation Delay?

Any way to delay animations?

import { slideInLeft } from 'react-animations';
import { StyleSheet, css } from 'aphrodite';

const styles = StyleSheet.create({
  slideInLeft: {
    animationDelay: '2s',
    animationName: slideInLeft,
    animationDuration: '3s'
  }
});

Adding the animation delay property did not work.

Animation not working

Hi

Thanks for awesome library .
Please have a look on my code given below and tell me if any correction required to do so .Please tell me i am at my office and my boss told me to so and i am in a hurry.


import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { bounce } from 'react-animations';
import Radium from 'radium';

class App extends Component {
  render() {
    const styles = {
      bounce: {
        animation: 'x 1s',
        animationName: Radium.keyframes(bounce, 'bounce')
      }
    }
    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>
        <p className="App-intro" style={styles.bounce}>
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
      </div>
    );
  }
}

Thanks in advance !

StyleRoot is necessary if you want to import animation with Radium.

I installed this package for my react project and tried many times, I haven't use animations.css and radium before, so I tried to copy the code sample from README usage. And it doesn't work, although I tried many times.

Finally ,I realize that, it's very important to add </StyleRoot>, if not, the animation won't work.

See this issue #5 .This is the reason why many guys get stuck with it, so I write this to notice other guys and pull a request.

Export all animations as single object in default export

I believe it would be useful to define a default export in the main index file which exports an object containing all of the animations.

export default {
  bounce,
  flash,
  pulse,
  // ...
};

Which can then be imported as

import animations from 'react-animations';

The benefit of this is that you can allow a user/consumer to choose their own animations without having to import them all individually.

For example, I'm currently developing a Notification component that uses react-animations for it's entry and exit animations. I'd like to be able to expose a couple of props that let the consumer pick the animation that the Notification performs on entry and exit.

The simplest way to do this would be as follows.

import animations from 'react-animations';

export const Notification = ({
  enterAnimationName,
  exitAnimationName,
}) => {
  const enterAnimation = animations[enterAnimationName];
  const exitAnimation = animations[exitAnimationName];
  
  // ...
};

Currently, this isn't possible as react-animations has no default export, so the value of animations is just undefined.

Generally speaking, I do think it's rare that someone would want to import all animations, and that it should be advised against if you are just planning on using a single animation. Saying that, I do think that there's utility in this feature.

More than happy to open a PR.

Package name

Why is it react-animations, I don't see any dependency to react? It should be "cssinjs-animations" or similar.

Event Callback When Animation Finished

Is there a way to execute a callback function when the animation is complete? I think such a feature would make adding state triggered animations much easier to implement.

fade in from black

how do you fade in from black?

I tried using backgroundColor but it doesn't work

...
import Radium, { StyleRoot } from 'radium';
import { fadeIn } from 'react-animations'
...
const animations = {
  fadein: {
    animation: 'x 3s',
    animationName: Radium.keyframes(fadeIn, 'bounce'),
    backgroundColor: 'black',
  }
}
...
<StyleRoot>
   <img style={animations.fadein as React.CSSProperties} src={background_img} className={style.calltoaction_image} />
</StyleRoot>

Reset Animation

Is it possible to reset an animation, and make it play again?

component enter/exit control?

Is there a native way to set animations on/before/after component enter/exit?

If not is there a recommended way to use this?

thanks

It seems to be really nice but too few documentation for newbies

Everything looks pretty nice with a lot of potential to simplify animations in React which is not easy for newbies like me.

After a couple of hours trying to use this project, I gave up. There is too few documentation for people not familiar with Radium, keyframes, etc.

JSS example in documentation is buggy

Current example:

const {classes} = jss.createStyleSheet({
  '@keyframes bounce': bounce,
  bounce: {
    animationName: 'bounce',
    animationDuration: '1s',
  },
}).attach()

Corrected example:

const {classes} = jss.createStyleSheet({
  '@keyframes bounce': bounce,
  bounce: {
    animationName: '$bounce',
    animationDuration: '1s',
  },
}).attach()

$ sign in missing in animationName value.

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.