1.0.6 โ€ข Published 4 years ago

react-easy-animate v1.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

react-easy-animate

A micro react component that lets you manage entry and exit animation of your react components using css classes with ease

npm version npm downloads license npm bundle size

Check the interactive example: https://devsrv.github.io/react-easy-animate-example/

๐Ÿ“‹ Features

  • Control entry & exit animation - css animation class to use when component appearing & disappearing
  • Animation delay & duration - manage animation delay and duration for both entry & exit animations
  • Hook into animationEnd events โ€“ access to all animation end events that you can act to

๐Ÿ“ฅ Installation

Using npm:

$ npm i react-easy-animate --save

๐Ÿงช Usage

Basic Example

import React, { Component } from 'react';
import Animatable from 'react-easy-animate';

class Main extends Component {
    state = {
        show: true,
    }

    render() {
        return (
            <div className="col">
                <Animatable show={this.state.show}>
                    <p>Lorem ipsum dolor sit amet</p>
                </Animatable>
                
                <button type="button" 
                    onClick={() => this.setState((state) => ({show: !state.show}))}>
                    click
                </button>
            </div>
        )
    }
}

render(<Main />, document.getElementById('root'));

Example with animate.css

import React, { Component } from 'react';
import { render } from 'react-dom';
import Animatable from 'react-easy-animate';
require("animate.css");

export default class Main extends Component {
    state = {
        show: true,
        disabled: false
    }

    render() {
        return (
                <div className="col">
                    <Animatable 
                        show={this.state.show}
                        entryAnimation={["zoomIn"]}
                        exitAnimation={["zoomOutDown", "faster"]}
                        onExitAnimationEnd={() => this.setState({disabled: false})}
                        onEntryAnimationEnd={() => this.setState({disabled: false})}
                    >
                        <div className="card">
                            <div className="card-body">
                                <h5 className="card-title">Lorem ipsum dolor sit amet</h5>
                                <Animatable 
                                    entryAnimDelay="1s" 
                                    show={this.state.show}
                                >
                                    <p>Lorem ipsum dolor sit amet</p>
                                </Animatable>
                            </div>
                        </div>
                    </Animatable>

                    <button type="button" 
                        disabled={this.state.disabled} 
                        onClick={() => this.setState((state) => ({show: !state.show, disabled: true}))}>
                            {this.state.show? "HIDE" : "SHOW"}
                    </button>
                </div>
        )
    }
}

render(<Main />, document.getElementById('root'));

๐Ÿ“š API

Props

PropertyTypeDefaultRequiredDescription
showboolundefinedโœ“whether to show or hide the component.
entryAnimationarrayzoomIncss classes responsible for animating the component when the component is appearing from a disappeared state
exitAnimationarrayzoomOutcss classes responsible for animating the component when the component is disappearing from a visible state
onExitAnimationEndfuncundefinedfunction to call when the disappearing animation ends
onEntryAnimationEndfuncundefinedfunction to call when the appearing animation ends
entryAnimDelaystringundefinedcss animation-delay value for the appearing animation
entryAnimDurationstringundefinedcss animation-duration value for the appearing animation
exitAnimDelaystringundefinedcss animation-delay value for the disappearing animation
exitAnimDurationstringundefinedcss animation-duration value for the disappearing animation

๐Ÿ‘‹๐Ÿผ Say Hi!

Leave a โญ if you find this package useful ๐Ÿ‘๐Ÿผ,

don't forget to let me know in Twitter

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago