0.0.7 • Published 1 year ago

@fecapark/number-rolling v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Number Rolling

The React library for number rolling animation.

화면 기록 2024-05-18 22 56 51

Install

npm i @fecapark/number-rolling
yarn add @fecapark/number-rolling

Usage

All Properties

import { Roller } from "@fecapark/number-rolling";

<Roller
  value={13000}
  suffix="",
  suffixPosition="back",
  align="center",
  fontSize={48},
  rollDuration={0.6},
  shiftDuration={0.45},
  staggering={false},
  diff={false},
  rollWay="down",
  showAfterFontNameLoaded="",
/>;
propdescriptiontypeinitial valuerequired
valueNumber(integer, float) value to display.numbervalue requiredtrue
suffixSuffix string to display.string"" (empty string)false
suffixPositionDetermines position of the suffix string.front or backbackfalse
alignText align of animation container width change.left or center or rightcenterfalse
fontSizeFont size of value and suffix.number48false
rollDurationDuration of value rolling animation.number (seconds)0.6 (seconds)false
shiftDurationDuration of width changing animation.number (seconds)0.45 (seconds)false
staggeringDetermines trigger each value's rolling animation as sequence or randomly.booleanfalse (triggers randomly)false
diffDetermines trigger rolling aniamtion for only changed values.booleanfalsefalse
rollWayRolling animation's roll direction.up or downdownfalse
showAfterFontNameLoadedThis component will be show after setted font-face loaded. If you setted font-family through any styling to this component, you should set this prop values as your font-family values for preventing CLS(Cumulative Layout Shift). See examples.string[][] (empty array)false

Examples

Simple usage

import { Roller } from "@fecapark/number-rolling";

<Roller value={13000} />;

화면 기록 2024-05-18 23 28 00

With suffix

import { Roller } from "@fecapark/number-rolling";

<Roller value={...} suffix="%" />;

화면 기록 2024-05-18 23 30 50

import { Roller } from "@fecapark/number-rolling";

<Roller value={...} suffix="$" suffixPosition="front" />;

화면 기록 2024-05-18 23 31 24

Align

For use align props,
Roller component should be wrapped in an element that has enough width.

import { Roller } from "@fecapark/number-rolling";

<div style={{ width: 600 }}>
  <Roller value={...} align="right" />;
</div>

화면 기록 2024-05-18 23 34 26

import { Roller } from "@fecapark/number-rolling";

<div style={{ width: 600 }}>
  <Roller value={...} align="left" />;
</div>

화면 기록 2024-05-18 23 36 57

Staggering

import { Roller } from "@fecapark/number-rolling";

<Roller value={...} staggering={true} />;

화면 기록 2024-05-18 23 39 34

import { Roller } from "@fecapark/number-rolling";

<Roller value={...} staggering={false} />;

화면 기록 2024-05-18 23 40 03

Diff

import { Roller } from "@fecapark/number-rolling";

<Roller value={...} diff={true} />;

화면 기록 2024-05-18 23 44 10

import { Roller } from "@fecapark/number-rolling";

<Roller value={...} diff={false} />;

무제

Rollway

import { Roller } from "@fecapark/number-rolling";

<Roller value={...} rollWay="up" />;

화면 기록 2024-05-18 23 53 52

import { Roller } from "@fecapark/number-rolling";

<Roller value={...} rollWay="down" />;

화면 기록 2024-05-18 23 54 38

showAfterFontNameLoaded

If you setted font-family, recommended to use this property.

In example below, the font Roboto and Noto Sans are setted. After all setted fonts are loaded, if any one of the fonts is successfully loaded, the components are displayed on the screen.

import { Roller } from "@fecapark/number-rolling";

<div style={{
  fontFamily: "Roboto, 'Noto Sans' sans-serif"
}}>
  <Roller value={...}  showAfterFontNameLoaded={["Roboto", "Noto Sans"]} />;
</div>
Roboto LoadedNoto Sans LoadedResult
loadedloadedshow
failedfailednot show
loadedfailedshow
failedloadedshow
0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago