@daeryun/dr_components 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export * from './useBrowser';
2
+ export * from './useCountNum';
@@ -0,0 +1,2 @@
1
+ export * from './useBrowser';
2
+ export * from './useCountNum';
@@ -0,0 +1,2 @@
1
+ export * from './useBrowser';
2
+ export * from './useCountNum';
@@ -0,0 +1,4 @@
1
+ declare const useCountNum: (end: number, start?: number, startFlag?: boolean, customDelay?: number) => {
2
+ count: number;
3
+ };
4
+ export default useCountNum;
@@ -0,0 +1,23 @@
1
+ import { useEffect, useState } from 'react';
2
+ function easeOutExpo(t, y) {
3
+ return t === 1 ? 1 : 1 - Math.pow(2, (y ? y : -5) * t);
4
+ }
5
+ const useCountNum = (end, start = 0, startFlag, customDelay) => {
6
+ const [count, setCount] = useState(start);
7
+ const frameRate = 1000 / 60;
8
+ const totalFrame = Math.round(2000 / frameRate);
9
+ useEffect(() => {
10
+ if (startFlag) {
11
+ let currentNumber = start;
12
+ const counter = setInterval(() => {
13
+ const progress = easeOutExpo(++currentNumber / totalFrame, customDelay);
14
+ setCount(Math.round(end * progress));
15
+ if (progress === 1) {
16
+ clearInterval(counter);
17
+ }
18
+ }, frameRate);
19
+ }
20
+ }, [end, frameRate, start, totalFrame, startFlag]);
21
+ return { count };
22
+ };
23
+ export default useCountNum;
@@ -0,0 +1,28 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ function easeOutExpo(t: number, y?: number): number {
4
+ return t === 1 ? 1 : 1 - Math.pow(2, (y ? y : -5) * t);
5
+ }
6
+
7
+ const useCountNum = (end: number, start = 0, startFlag?: boolean, customDelay?: number) => {
8
+ const [count, setCount] = useState<number>(start);
9
+ const frameRate = 1000 / 60;
10
+ const totalFrame = Math.round(2000 / frameRate);
11
+
12
+ useEffect(() => {
13
+ if (startFlag) {
14
+ let currentNumber = start;
15
+ const counter = setInterval(() => {
16
+ const progress = easeOutExpo(++currentNumber / totalFrame, customDelay);
17
+ setCount(Math.round(end * progress));
18
+
19
+ if (progress === 1) {
20
+ clearInterval(counter);
21
+ }
22
+ }, frameRate);
23
+ }
24
+ }, [end, frameRate, start, totalFrame, startFlag]);
25
+
26
+ return { count };
27
+ };
28
+ export default useCountNum;
@@ -1,25 +1,3 @@
1
- export interface IMapArea {
2
- [region: string]: Array<{
3
- name: string;
4
- desc: string;
5
- url: string;
6
- src: string;
7
- }>;
8
- }
9
- export declare const newNapAreaMobile: IMapArea;
10
- export declare const centerListExample: ({
11
- code: string;
12
- code_name: string;
13
- code_desc: string;
14
- isSelect: boolean;
15
- } | {
16
- code: string;
17
- code_name: string;
18
- code_desc: string;
19
- isSelect?: undefined;
20
- })[];
21
- export declare const categoryListExample: {
22
- idx: number;
23
- center_code: string;
24
- title: string;
25
- }[];
1
+ export * from './hook';
2
+ export * from './types';
3
+ export * from './data';