npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-animated-number-tnbt

v1.0.4

Published

>**Note**: I am a newbie in React Native. Here is my frist package which I publish to npm. If it make you waste your time, please dont blame me. I hope to disscuss about any the problem with you. Thank you !!!

Downloads

14

Readme

Getting Started

Note: I am a newbie in React Native. Here is my frist package which I publish to npm. If it make you waste your time, please dont blame me. I hope to disscuss about any the problem with you. Thank you !!!

This package is for Android

Test

You can clone this repo to test package.

https://github.com/tiennguyen12g/react-native-animated-number-tnbt.git
npx react-native start

In the App.tsx, I have some data for test, you can use it if need.

Installation using npm

npm i react-native-animated-number-tnbt

How to use "react-native-animated-number-tnbt"

Import to your component

import {AnimatedNumber} from "react-native-animated-number-tnbt"

if typescript gives the error, you can try to create file name react-native-animated-number-tnbt.d.ts

// file react-native-animated-number-tnbt.d.ts
declare module "react-native-animated-number-tnbt"

Demo

https://github.com/tiennguyen12g/my-media-storage/assets/40747229/71d2b183-eb12-412a-a289-b41cd4332b7e

Available props

   interface Props {
     numberForAnimated: number;
     decimalAmount: number;
     includeComma?: boolean;
     gap?: number;
     colorValue?:string;
     fontSizeValue?:number;
     hookName:"withTiming" | "withSpring",
     withTimingProps?: {
       durationValue?: number;
       easingValue:string
     };
     withSpringProps?: {
       mass?: number;
       damping?: number;
       stiffness?: number;
       restDisplacementThreshold?: number;
       overshootClamping?: boolean;
       restSpeedThreshold?: number;
     };
   }

Table list props

| Name | Type | Default | Description | |-------------------|---------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| | decimalAmount | number | 1 | How many decimal places after the comma. | | includeComma | boolean | true | Whether to include a comma for numbers greater than or equal to 1000. Example: 1000 => 1,000. | | gap | number | 5 | The space between two numbers. | | colorValue | string | "red" | The color for the number. | | fontSizeValue | number | 50 | The size of the font. | | hookName | string | "withSpring" | The type of animation: "withTiming" or "withSpring". |

If you want to customize your animation, you should provide parameters to either "withTimingProps" or "withSpringProps", not both. By default, "withSpring" is used.

"withTimingProps"

| Name | Type | Default | Description | |---------------|---------|---------|-------------------------------------------------------------------------| | durationValue | number | 500 | Time for running the animation. | | easingValue | string | "linear" | The easing function for the animation. Options: "linear", "ease", "bounce", "poly", "circle", "bezier". |

"withSpringProps"

| Name | Type | Default | Description | |-----------------------------|----------|---------|----------------------------------------------------------------------------------------------------------| | mass | number | 3 | The weight of the spring. Reducing this value makes the animation faster. | | damping | number | 20 | How quickly a spring slows down. Higher damping means the spring will come to rest faster. | | stiffness | number | 250 | How bouncy the spring is. | | overshootClamping | boolean | false | Whether a spring can bounce over the toValue. | | restDisplacementThreshold | number | 0.01 | The displacement below which the spring will snap to toValue without further oscillations. | | restSpeedThreshold | number | 2 | The speed in pixels per second from which the spring will snap to toValue without further oscillations. |

Reference: Reanimated withSpring Documentation

Example

import React from 'react';
import {
SafeAreaView,
StyleSheet,
View,
Button
} from 'react-native';
import {AnimatedNumber} from "react-native-animated-number-tnbt"


function App(): JSX.Element {

const [floatNumber, setFloatNumber] = React.useState(18500.5); 
const decimalAmount = 2
const increaseFloat = () => {
const fractionNumber = decimalAmount;
const result = (floatNumber + 565.4).toFixed(fractionNumber);
setFloatNumber(+result);
}
return (
 <SafeAreaView style={styles.container}>
   <AnimatedNumber              
     numberForAnimated = {floatNumber}
     includeComma = {true} // use for number greater or equal 1000.It looks like 1000 => 1,000.
     decimalAmount={decimalAmount}
     gap={2}
     hookName='withSpring'
     colorValue='orange'
     fontSizeValue={50}
   />
   <Button title="increaseFloat" onPress={increaseFloat} />
 </SafeAreaView>
);
}

const styles = StyleSheet.create({
container:{
 justifyContent:"center",
 flex:1
}

});

export default App;

I hope this library will help you save your time.

Congratulations! :tada:

You've successfully run and modified this package. :partying_face: