GithubHelp home page GithubHelp logo

kanasite / animated-number-react Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leocardoso94/animated-number-react

0.0 1.0 0.0 118 KB

Super easy way to animate numbers with React

License: MIT License

JavaScript 97.88% HTML 1.81% CSS 0.31%

animated-number-react's Introduction

animated-number-react

npm Build Status

A simple animated number for React, using anime.

Live demo here

Usage

$ npm install animated-number-react
# OR
$ yarn add animated-number-react
import AnimatedNumber from "animated-number-react";

export default class App extends Component {
  state = {
    value: 150
  };
  handleChange = ({ target: { value } }) => {
    this.setState({ value });
  };
  formatValue = value => value.toFixed(2);
  render() {
    return (
      <div>
        <input
          type="number"
          onChange={this.handleChange}
          value={this.state.value}
        />
        <AnimatedNumber
          value={this.state.value}
          formatValue={this.formatValue}
        />
      </div>
    );
  }
}

View demo here Edit animated-number-react

Props

Following props are used while initialization

Note : Only value is a required prop. Others are optional

Prop Name Type Description
value (required) [ Number, String] number that will be animated
duration (optional) Number the duration of animation
delay (optional) Number the delay of animation
easing (optional) String you can found all valid values here

Callbacks props

Execute a function at the beginning, during or when an animation or timeline is completed.

Names Types Arguments Info
formatValue Function value Number A function that will manipulate the animated value
update Function animation Object Called at time = 0
run Function animation Object Called after delay is finished
begin Function animation Object Called after animation delay is over
complete Function animation Object Called only after all the loops are completed

Format Value

formatValue() is used to format the animatedValue.

Update

update() is called on every frame while the instance is playing.

Begin

begin() is called once after the delay is finished.

Check if the animation has begun with myAnimation.began, return true or false.

Run

run() is called every frame after the delay is finished.

Complete

complete() is called once after the animation is finished.

animated-number-react's People

Contributors

josephting avatar leocardoso94 avatar

Watchers

 avatar

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.