• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ‘Ύ Library showing animation of number changes in react.js
npm version

react-animated-numbers

Library showing animation of number changes in react.js

Test

Homepage

Props

name type default description
animateToNumber number none Number to be animated
fontStyle React.CSSProperties? none Style of number text
includeComma boolean? false Whether the number contains commas
locale string? en-US Formats animated number as per locale. Also it should be used with inculdeComma prop. For list of locales, search for "BCP 47 language tags"
configs(1) SpringConfig[]? config.default This module is using react-spring and you can refer to this config option. If you pass multiple settings, an animation is randomly assigned to each number. _ DO NOT USE duration because of a bug that hasn't been fixed yet_
configs(2) (number, number): SpringConfig none The first parameter gives information about the number to be changed, And the second parameter gives information about the order of the changing numbers. You can use that information to adjust the animation by returning the config

Custom Style

  • you can use className animated-container to style container (example)
  • if you want to customize font style. Just ues fontStyle prop

Next JS

You have to use dynamic imports to ensure that this library is imported on the client side only.

Import the library like this:

import dynamic from "next/dynamic";
const AnimatedNumbers = dynamic(() => import("react-animated-numbers"), {
  ssr: false,
});

Credit to @jedwardblack for this

Example

import React from "react";
import AnimatedNumbers from "react-animated-numbers";
import "./App.css";

function App() {
  const [num, setNum] = React.useState(331231);
  return (
    <div className="container">
      <AnimatedNumbers
        includeComma
        animateToNumber={num}
        fontStyle={{ fontSize: 40 }}
        locale="en-US"
        configs={[
          { mass: 1, tension: 220, friction: 100 },
          { mass: 1, tension: 180, friction: 130 },
          { mass: 1, tension: 280, friction: 90 },
          { mass: 1, tension: 180, friction: 135 },
          { mass: 1, tension: 260, friction: 100 },
          { mass: 1, tension: 210, friction: 180 },
        ]}
      ></AnimatedNumbers>

      <AnimatedNumbers
        animateToNumber={num}
        fontStyle={{ fontSize: 32 }}
        configs={(number, index) => {
          return { mass: 1, tension: 230 * (index + 1), friction: 140 };
        }}
      ></AnimatedNumbers>
      <div>
        <button onClick={() => setNum((state) => state + 31234)}>+</button>
        <button onClick={() => setNum((state) => state - 31234)}>-</button>
      </div>
    </div>
  );
}

export default App;

Todo

  • test code
  • start animation when dom is visible

More Repositories

1

react-native-responsive-fontSize

πŸ”  Responsive fontSize based on screen-size of the device in React-Native
JavaScript
575
star
2

react-native-animated-numbers

🎰 Library showing animation of number changes in react-native
Java
251
star
3

react-native-awesome-alert

πŸ”” Customizable modal components with βœ”οΈcheck options in React Native
JavaScript
51
star
4

react-native-frame-loading

⛹️‍♀️⛹️‍♂️ Like animation LoadingIndicator with frame by frame view in React-Native
JavaScript
12
star
5

react-native-hide-modal

πŸ™ˆ Modal components that can be hidden
JavaScript
9
star
6

react-kakao-link

πŸ”— λ¦¬μ•‘νŠΈ μ›Ήμ—μ„œ μ‚¬μš©ν•  수 μžˆλŠ” 카카였 λ§ν¬μž…λ‹ˆλ‹€.
TypeScript
8
star
7

react-native-iphone-se-helper

πŸ“‚ utils for developing Iphone SE size
JavaScript
8
star
8

deprocheck-rn

πŸ“‹ λ””ν”„λ§Œ 좜첡 μ•± RN 버전
TypeScript
5
star
9

youngstargram-node-server

처음으둜 λ§Œλ“€μ–΄λ³΄λŠ” λ…Έλ“œμ„œλ²„ μ–΄ν”Œλ¦¬μΌ€μ΄μ…˜ (μΈμŠ€νƒ€κ·Έλž¨ 클둠)
JavaScript
5
star
10

fc-react-native

πŸ– 패슀트캠퍼슀 React-Native Camp μ—μ„œ μž‘μ„±ν•œ μ½”λ“œλ₯Ό κ³΅μœ ν•©λ‹ˆλ‹€
JavaScript
4
star
11

learning-htmlcss

πŸ“ studying html & css by practice and code reviews
HTML
4
star
12

fastcampus-react-2019

패슀트캠퍼슀 REACTμΊ ν”„ μˆ˜κ°•λ‚΄μš© 정리 (2019εΉ΄)
JavaScript
3
star
13

rntm-starter-kit

RN & TS & MobX starter kit
Objective-C
2
star
14

react-native-bootsplash-example

react-native-bootsplash-example
Java
2
star
15

newblog

gatsby blog
JavaScript
2
star
16

algorithm

assembly for algorithm study that consist of so COOL 😎 iOS developers πŸ’»πŸ“±πŸ“²πŸ–±
Swift
1
star
17

ClassManager_private

πŸ”Œ Web Project with JAVA, JSP, MYSQL, Spring Frame
Java
1
star
18

react-testing-practice

πŸƒβ€β™‚οΈ simple project for react & react-native test code
TypeScript
1
star
19

animated-numbers

HTML
1
star
20

code-splitting

code-spliiting example
JavaScript
1
star
21

Ios_Django_project

πŸš€ First Ios-Django project
Objective-C
1
star
22

ios_swift_study

IOS(Swift) study at Inflearn
Swift
1
star
23

frontend-til

TIL
HTML
1
star
24

ios_hanyoungsoo

Studying Objective-c and Ios at FastCampus
Objective-C
1
star
25

react-18-examples

λ¦¬μ•‘νŠΈ 18 κΈ°λŠ₯을 μ˜ˆμ œμ½”λ“œλ‘œ μ•Œμ•„λ΄…λ‹ˆλ‹€.
JavaScript
1
star
26

admob-project

돈 λˆμ„ λ²Œμ–΄λ²„μž
1
star
27

FC-REACT-8th-assignment

패슀트캠퍼슀 λ¦¬μ•‘νŠΈ μΊ ν”„ 8κΈ° 과제 λͺ¨μŒ
JavaScript
1
star
28

bucket_list

λ²„ν‚·λ¦¬μŠ€νŠΈ μ—λŸ¬ μˆ˜μ •
Objective-C
1
star
29

datastructure_python

DataStructure study with Python
Python
1
star