The React library for number rolling animation.
npm install @fecapark/number-rollingThe React library for number rolling animation.
!화면 기록 2024-05-18 22 56 51
```
npm i @fecapark/number-rolling
``
yarn add @fecapark/number-rolling
`tsx
import { Roller } from "@fecapark/number-rolling";
suffix="",
suffixPosition="back",
align="center",
fontSize={48},
rollDuration={0.6},
shiftDuration={0.45},
staggering={false},
diff={false},
rollWay="down",
showAfterFontNameLoaded="",
/>;
`
| prop | description | type | initial value | required |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | --------------------------- | -------- |
| value | Number(integer, float) value to display. | number | value required | true |string
| suffix | Suffix string to display. | | "" (empty string) | false |front
| suffixPosition | Determines position of the suffix string. | or back | back | false |left
| align | Text align of animation container width change. | or center or right | center | false |number
| fontSize | Font size of value and suffix. | | 48 | false |number
| rollDuration | Duration of value rolling animation. | (seconds) | 0.6 (seconds) | false |number
| shiftDuration | Duration of width changing animation. | (seconds) | 0.45 (seconds) | false |boolean
| staggering | Determines trigger each value's rolling animation as sequence or randomly. | | false (triggers randomly) | false |boolean
| diff | Determines trigger rolling aniamtion for only changed values. | | false | false |up
| rollWay | Rolling animation's roll direction. | or down | down | false |font-family
| showAfterFontNameLoaded | This component will be show after setted font-face loaded. If you setted 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 |
`tsx
import { Roller } from "@fecapark/number-rolling";
`
!화면 기록 2024-05-18 23 28 00
`tsx
import { Roller } from "@fecapark/number-rolling";
`
!화면 기록 2024-05-18 23 30 50
`tsx
import { Roller } from "@fecapark/number-rolling";
`
!화면 기록 2024-05-18 23 31 24
For use align props, Roller component should be wrapped in an element that has enough width.
`tsx
import { Roller } from "@fecapark/number-rolling";
`tsx
import { Roller } from "@fecapark/number-rolling";
;
`!화면 기록 2024-05-18 23 36 57
$3
`tsx
import { Roller } from "@fecapark/number-rolling"; ;
``tsx
import { Roller } from "@fecapark/number-rolling"; ;
`!화면 기록 2024-05-18 23 40 03
$3
`tsx
import { Roller } from "@fecapark/number-rolling"; ;
``tsx
import { Roller } from "@fecapark/number-rolling"; ;
`!무제
$3
`tsx
import { Roller } from "@fecapark/number-rolling"; ;
``tsx
import { Roller } from "@fecapark/number-rolling"; ;
`!화면 기록 2024-05-18 23 54 38
$3
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.`tsx
import { Roller } from "@fecapark/number-rolling"; fontFamily: "Roboto, 'Noto Sans' sans-serif"
}}>
;
| Roboto Loaded | Noto Sans Loaded | Result |
| ------------- | ---------------- | -------- |
|
loaded | loaded | show |
| failed | failed | not show |
| loaded | failed | show |
| failed | loaded` | show |