react-ui-animate 2.0.0-rc.1 → 2.0.0-rc.2
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.
- package/.vscode/settings.json +3 -3
- package/LICENSE +21 -21
- package/README.md +115 -115
- package/dist/animation/animationType.d.ts +8 -0
- package/dist/animation/getInitialConfig.d.ts +2 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/package.json +49 -49
- package/rollup.config.js +18 -18
- package/src/animation/animationType.ts +17 -9
- package/src/animation/getInitialConfig.ts +61 -30
- package/src/animation/index.ts +9 -9
- package/src/animation/interpolation.ts +24 -24
- package/src/animation/modules.tsx +105 -105
- package/src/animation/useAnimatedValue.ts +62 -62
- package/src/animation/useMountedValue.ts +66 -66
- package/src/gestures/controllers/DragGesture.ts +177 -177
- package/src/gestures/controllers/Gesture.ts +54 -54
- package/src/gestures/controllers/MouseMoveGesture.ts +111 -111
- package/src/gestures/controllers/ScrollGesture.ts +107 -107
- package/src/gestures/controllers/WheelGesture.ts +123 -123
- package/src/gestures/controllers/index.ts +4 -4
- package/src/gestures/eventAttacher.ts +67 -67
- package/src/gestures/hooks/index.ts +5 -5
- package/src/gestures/hooks/useDrag.ts +14 -14
- package/src/gestures/hooks/useGesture.ts +38 -38
- package/src/gestures/hooks/useMouseMove.ts +11 -11
- package/src/gestures/hooks/useRecognizer.ts +59 -59
- package/src/gestures/hooks/useScroll.ts +11 -11
- package/src/gestures/hooks/useWheel.ts +11 -11
- package/src/gestures/index.ts +2 -2
- package/src/gestures/math.ts +120 -120
- package/src/gestures/types.ts +49 -49
- package/src/gestures/withDefault.ts +3 -3
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useMeasure.ts +133 -133
- package/src/hooks/useOutsideClick.ts +36 -36
- package/src/hooks/useWindowDimension.ts +59 -59
- package/src/index.ts +5 -4
- package/src/utils/delay.ts +9 -9
- package/src/utils/index.ts +2 -2
- package/src/utils/isDefined.ts +4 -4
- package/tsconfig.json +25 -25
package/src/hooks/useMeasure.ts
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
type MeasurementValue = number | Array<number>;
|
|
4
|
-
|
|
5
|
-
type MeasurementType = {
|
|
6
|
-
left: MeasurementValue;
|
|
7
|
-
top: MeasurementValue;
|
|
8
|
-
width: MeasurementValue;
|
|
9
|
-
height: MeasurementValue;
|
|
10
|
-
vLeft: MeasurementValue;
|
|
11
|
-
vTop: MeasurementValue;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function useMeasure(
|
|
15
|
-
callback: (event: MeasurementType) => void,
|
|
16
|
-
deps?: React.DependencyList
|
|
17
|
-
) {
|
|
18
|
-
const ref = React.useRef(null);
|
|
19
|
-
const elementRefs = React.useRef([]);
|
|
20
|
-
const callbackRef = React.useRef<(event: MeasurementType) => void>(callback);
|
|
21
|
-
|
|
22
|
-
// Reinitiate callback when dependency change
|
|
23
|
-
React.useEffect(() => {
|
|
24
|
-
callbackRef.current = callback;
|
|
25
|
-
|
|
26
|
-
return () => {
|
|
27
|
-
callbackRef.current = () => false;
|
|
28
|
-
};
|
|
29
|
-
}, deps);
|
|
30
|
-
|
|
31
|
-
React.useEffect(() => {
|
|
32
|
-
const _refElement = ref.current || document.documentElement;
|
|
33
|
-
const _refElementsMultiple = elementRefs.current;
|
|
34
|
-
|
|
35
|
-
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
36
|
-
const { left, top, width, height } = entry.target.getBoundingClientRect();
|
|
37
|
-
const { pageXOffset, pageYOffset } = window;
|
|
38
|
-
|
|
39
|
-
if (callbackRef) {
|
|
40
|
-
if (_refElement === document.documentElement) {
|
|
41
|
-
return; // no-op for document
|
|
42
|
-
} else {
|
|
43
|
-
callbackRef.current({
|
|
44
|
-
left: left + pageXOffset,
|
|
45
|
-
top: top + pageYOffset,
|
|
46
|
-
width,
|
|
47
|
-
height,
|
|
48
|
-
vLeft: left,
|
|
49
|
-
vTop: top,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const resizeObserverMultiple = new ResizeObserver((entries) => {
|
|
56
|
-
const left: Array<number> = [];
|
|
57
|
-
const top: Array<number> = [];
|
|
58
|
-
const width: Array<number> = [];
|
|
59
|
-
const height: Array<number> = [];
|
|
60
|
-
const vLeft: Array<number> = [];
|
|
61
|
-
const vTop: Array<number> = [];
|
|
62
|
-
|
|
63
|
-
entries.forEach((entry) => {
|
|
64
|
-
const {
|
|
65
|
-
left: _left,
|
|
66
|
-
top: _top,
|
|
67
|
-
width: _width,
|
|
68
|
-
height: _height,
|
|
69
|
-
} = entry.target.getBoundingClientRect();
|
|
70
|
-
const { pageXOffset, pageYOffset } = window;
|
|
71
|
-
const _pageLeft = _left + pageXOffset;
|
|
72
|
-
const _pageTop = _top + pageYOffset;
|
|
73
|
-
|
|
74
|
-
left.push(_pageLeft);
|
|
75
|
-
top.push(_pageTop);
|
|
76
|
-
width.push(_width);
|
|
77
|
-
height.push(_height);
|
|
78
|
-
vLeft.push(_left);
|
|
79
|
-
vTop.push(_top);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
if (callbackRef) {
|
|
83
|
-
callbackRef.current({
|
|
84
|
-
left,
|
|
85
|
-
top,
|
|
86
|
-
width,
|
|
87
|
-
height,
|
|
88
|
-
vLeft,
|
|
89
|
-
vTop,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
if (_refElement) {
|
|
95
|
-
if (
|
|
96
|
-
_refElement === document.documentElement &&
|
|
97
|
-
_refElementsMultiple.length > 0
|
|
98
|
-
) {
|
|
99
|
-
_refElementsMultiple.forEach((element: any) => {
|
|
100
|
-
resizeObserverMultiple.observe(element.current);
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
resizeObserver.observe(_refElement);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return () => {
|
|
108
|
-
if (_refElement) {
|
|
109
|
-
if (
|
|
110
|
-
_refElement === document.documentElement &&
|
|
111
|
-
_refElementsMultiple.length > 0
|
|
112
|
-
) {
|
|
113
|
-
_refElementsMultiple.forEach((element: any) => {
|
|
114
|
-
resizeObserverMultiple.unobserve(element.current);
|
|
115
|
-
});
|
|
116
|
-
} else {
|
|
117
|
-
resizeObserver.unobserve(_refElement);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}, []);
|
|
122
|
-
|
|
123
|
-
return (index?: number) => {
|
|
124
|
-
if (index === null || index === undefined) {
|
|
125
|
-
return { ref };
|
|
126
|
-
} else {
|
|
127
|
-
elementRefs.current[index] =
|
|
128
|
-
elementRefs.current[index] || React.createRef();
|
|
129
|
-
|
|
130
|
-
return { ref: elementRefs.current[index] };
|
|
131
|
-
}
|
|
132
|
-
}; // ...bind() or ...bind(index) for multiple
|
|
133
|
-
}
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
type MeasurementValue = number | Array<number>;
|
|
4
|
+
|
|
5
|
+
type MeasurementType = {
|
|
6
|
+
left: MeasurementValue;
|
|
7
|
+
top: MeasurementValue;
|
|
8
|
+
width: MeasurementValue;
|
|
9
|
+
height: MeasurementValue;
|
|
10
|
+
vLeft: MeasurementValue;
|
|
11
|
+
vTop: MeasurementValue;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function useMeasure(
|
|
15
|
+
callback: (event: MeasurementType) => void,
|
|
16
|
+
deps?: React.DependencyList
|
|
17
|
+
) {
|
|
18
|
+
const ref = React.useRef(null);
|
|
19
|
+
const elementRefs = React.useRef([]);
|
|
20
|
+
const callbackRef = React.useRef<(event: MeasurementType) => void>(callback);
|
|
21
|
+
|
|
22
|
+
// Reinitiate callback when dependency change
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
callbackRef.current = callback;
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
callbackRef.current = () => false;
|
|
28
|
+
};
|
|
29
|
+
}, deps);
|
|
30
|
+
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
const _refElement = ref.current || document.documentElement;
|
|
33
|
+
const _refElementsMultiple = elementRefs.current;
|
|
34
|
+
|
|
35
|
+
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
36
|
+
const { left, top, width, height } = entry.target.getBoundingClientRect();
|
|
37
|
+
const { pageXOffset, pageYOffset } = window;
|
|
38
|
+
|
|
39
|
+
if (callbackRef) {
|
|
40
|
+
if (_refElement === document.documentElement) {
|
|
41
|
+
return; // no-op for document
|
|
42
|
+
} else {
|
|
43
|
+
callbackRef.current({
|
|
44
|
+
left: left + pageXOffset,
|
|
45
|
+
top: top + pageYOffset,
|
|
46
|
+
width,
|
|
47
|
+
height,
|
|
48
|
+
vLeft: left,
|
|
49
|
+
vTop: top,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const resizeObserverMultiple = new ResizeObserver((entries) => {
|
|
56
|
+
const left: Array<number> = [];
|
|
57
|
+
const top: Array<number> = [];
|
|
58
|
+
const width: Array<number> = [];
|
|
59
|
+
const height: Array<number> = [];
|
|
60
|
+
const vLeft: Array<number> = [];
|
|
61
|
+
const vTop: Array<number> = [];
|
|
62
|
+
|
|
63
|
+
entries.forEach((entry) => {
|
|
64
|
+
const {
|
|
65
|
+
left: _left,
|
|
66
|
+
top: _top,
|
|
67
|
+
width: _width,
|
|
68
|
+
height: _height,
|
|
69
|
+
} = entry.target.getBoundingClientRect();
|
|
70
|
+
const { pageXOffset, pageYOffset } = window;
|
|
71
|
+
const _pageLeft = _left + pageXOffset;
|
|
72
|
+
const _pageTop = _top + pageYOffset;
|
|
73
|
+
|
|
74
|
+
left.push(_pageLeft);
|
|
75
|
+
top.push(_pageTop);
|
|
76
|
+
width.push(_width);
|
|
77
|
+
height.push(_height);
|
|
78
|
+
vLeft.push(_left);
|
|
79
|
+
vTop.push(_top);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (callbackRef) {
|
|
83
|
+
callbackRef.current({
|
|
84
|
+
left,
|
|
85
|
+
top,
|
|
86
|
+
width,
|
|
87
|
+
height,
|
|
88
|
+
vLeft,
|
|
89
|
+
vTop,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (_refElement) {
|
|
95
|
+
if (
|
|
96
|
+
_refElement === document.documentElement &&
|
|
97
|
+
_refElementsMultiple.length > 0
|
|
98
|
+
) {
|
|
99
|
+
_refElementsMultiple.forEach((element: any) => {
|
|
100
|
+
resizeObserverMultiple.observe(element.current);
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
resizeObserver.observe(_refElement);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return () => {
|
|
108
|
+
if (_refElement) {
|
|
109
|
+
if (
|
|
110
|
+
_refElement === document.documentElement &&
|
|
111
|
+
_refElementsMultiple.length > 0
|
|
112
|
+
) {
|
|
113
|
+
_refElementsMultiple.forEach((element: any) => {
|
|
114
|
+
resizeObserverMultiple.unobserve(element.current);
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
resizeObserver.unobserve(_refElement);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
return (index?: number) => {
|
|
124
|
+
if (index === null || index === undefined) {
|
|
125
|
+
return { ref };
|
|
126
|
+
} else {
|
|
127
|
+
elementRefs.current[index] =
|
|
128
|
+
elementRefs.current[index] || React.createRef();
|
|
129
|
+
|
|
130
|
+
return { ref: elementRefs.current[index] };
|
|
131
|
+
}
|
|
132
|
+
}; // ...bind() or ...bind(index) for multiple
|
|
133
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { attachEvents } from "../gestures/eventAttacher";
|
|
4
|
-
|
|
5
|
-
export function useOutsideClick(
|
|
6
|
-
elementRef: React.RefObject<HTMLElement>,
|
|
7
|
-
callback: (event: MouseEvent) => void,
|
|
8
|
-
deps?: React.DependencyList
|
|
9
|
-
) {
|
|
10
|
-
const callbackRef = React.useRef<(event: MouseEvent) => void>();
|
|
11
|
-
|
|
12
|
-
if (!callbackRef.current) {
|
|
13
|
-
callbackRef.current = callback;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Reinitiate callback when dependency change
|
|
17
|
-
React.useEffect(() => {
|
|
18
|
-
callbackRef.current = callback;
|
|
19
|
-
|
|
20
|
-
return () => {
|
|
21
|
-
callbackRef.current = () => false;
|
|
22
|
-
};
|
|
23
|
-
}, deps);
|
|
24
|
-
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
const handleOutsideClick = (e: MouseEvent) => {
|
|
27
|
-
if (!elementRef?.current?.contains(e.target as Element)) {
|
|
28
|
-
callbackRef.current && callbackRef.current(e);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const subscribe = attachEvents([document], [["click", handleOutsideClick]]);
|
|
33
|
-
|
|
34
|
-
return () => subscribe && subscribe();
|
|
35
|
-
}, []);
|
|
36
|
-
}
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { attachEvents } from "../gestures/eventAttacher";
|
|
4
|
+
|
|
5
|
+
export function useOutsideClick(
|
|
6
|
+
elementRef: React.RefObject<HTMLElement>,
|
|
7
|
+
callback: (event: MouseEvent) => void,
|
|
8
|
+
deps?: React.DependencyList
|
|
9
|
+
) {
|
|
10
|
+
const callbackRef = React.useRef<(event: MouseEvent) => void>();
|
|
11
|
+
|
|
12
|
+
if (!callbackRef.current) {
|
|
13
|
+
callbackRef.current = callback;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Reinitiate callback when dependency change
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
callbackRef.current = callback;
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
callbackRef.current = () => false;
|
|
22
|
+
};
|
|
23
|
+
}, deps);
|
|
24
|
+
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
const handleOutsideClick = (e: MouseEvent) => {
|
|
27
|
+
if (!elementRef?.current?.contains(e.target as Element)) {
|
|
28
|
+
callbackRef.current && callbackRef.current(e);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const subscribe = attachEvents([document], [["click", handleOutsideClick]]);
|
|
33
|
+
|
|
34
|
+
return () => subscribe && subscribe();
|
|
35
|
+
}, []);
|
|
36
|
+
}
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
type WindowDimensionType = {
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
innerWidth: number;
|
|
7
|
-
innerHeight: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function useWindowDimension(
|
|
11
|
-
callback: (event: WindowDimensionType) => void,
|
|
12
|
-
deps?: React.DependencyList
|
|
13
|
-
) {
|
|
14
|
-
const windowDimensionsRef = React.useRef<WindowDimensionType>({
|
|
15
|
-
width: 0,
|
|
16
|
-
height: 0,
|
|
17
|
-
innerWidth: 0,
|
|
18
|
-
innerHeight: 0,
|
|
19
|
-
});
|
|
20
|
-
const callbackRef =
|
|
21
|
-
React.useRef<(event: WindowDimensionType) => void>(callback);
|
|
22
|
-
|
|
23
|
-
const handleCallback: () => void = () => {
|
|
24
|
-
if (callbackRef) {
|
|
25
|
-
callbackRef.current({
|
|
26
|
-
...windowDimensionsRef.current,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// Reinitiate callback when dependency change
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
callbackRef.current = callback;
|
|
34
|
-
|
|
35
|
-
return () => {
|
|
36
|
-
callbackRef.current = () => false;
|
|
37
|
-
};
|
|
38
|
-
}, deps);
|
|
39
|
-
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
42
|
-
const { clientWidth, clientHeight } = entry.target;
|
|
43
|
-
const { innerWidth, innerHeight } = window;
|
|
44
|
-
|
|
45
|
-
windowDimensionsRef.current = {
|
|
46
|
-
width: clientWidth,
|
|
47
|
-
height: clientHeight,
|
|
48
|
-
innerWidth,
|
|
49
|
-
innerHeight,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
handleCallback();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
resizeObserver.observe(document.documentElement);
|
|
56
|
-
|
|
57
|
-
return () => resizeObserver.unobserve(document.documentElement);
|
|
58
|
-
}, []);
|
|
59
|
-
}
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
type WindowDimensionType = {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
innerWidth: number;
|
|
7
|
+
innerHeight: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function useWindowDimension(
|
|
11
|
+
callback: (event: WindowDimensionType) => void,
|
|
12
|
+
deps?: React.DependencyList
|
|
13
|
+
) {
|
|
14
|
+
const windowDimensionsRef = React.useRef<WindowDimensionType>({
|
|
15
|
+
width: 0,
|
|
16
|
+
height: 0,
|
|
17
|
+
innerWidth: 0,
|
|
18
|
+
innerHeight: 0,
|
|
19
|
+
});
|
|
20
|
+
const callbackRef =
|
|
21
|
+
React.useRef<(event: WindowDimensionType) => void>(callback);
|
|
22
|
+
|
|
23
|
+
const handleCallback: () => void = () => {
|
|
24
|
+
if (callbackRef) {
|
|
25
|
+
callbackRef.current({
|
|
26
|
+
...windowDimensionsRef.current,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Reinitiate callback when dependency change
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
callbackRef.current = callback;
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
callbackRef.current = () => false;
|
|
37
|
+
};
|
|
38
|
+
}, deps);
|
|
39
|
+
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
42
|
+
const { clientWidth, clientHeight } = entry.target;
|
|
43
|
+
const { innerWidth, innerHeight } = window;
|
|
44
|
+
|
|
45
|
+
windowDimensionsRef.current = {
|
|
46
|
+
width: clientWidth,
|
|
47
|
+
height: clientHeight,
|
|
48
|
+
innerWidth,
|
|
49
|
+
innerHeight,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
handleCallback();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
resizeObserver.observe(document.documentElement);
|
|
56
|
+
|
|
57
|
+
return () => resizeObserver.unobserve(document.documentElement);
|
|
58
|
+
}, []);
|
|
59
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { Easing } from
|
|
2
|
-
export
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export { Easing } from '@raidipesh78/re-motion';
|
|
2
|
+
export { delay } from './utils';
|
|
3
|
+
export * from './animation';
|
|
4
|
+
export * from './gestures';
|
|
5
|
+
export * from './hooks';
|
package/src/utils/delay.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param { number } ms - number of milliseconds to delay code execution
|
|
3
|
-
* @returns Promise
|
|
4
|
-
*/
|
|
5
|
-
export function delay(ms: number) {
|
|
6
|
-
return new Promise((resolve) => {
|
|
7
|
-
setTimeout(() => resolve(null), ms);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @param { number } ms - number of milliseconds to delay code execution
|
|
3
|
+
* @returns Promise
|
|
4
|
+
*/
|
|
5
|
+
export function delay(ms: number) {
|
|
6
|
+
return new Promise((resolve) => {
|
|
7
|
+
setTimeout(() => resolve(null), ms);
|
|
8
|
+
});
|
|
9
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './isDefined';
|
|
2
|
-
export * from './delay';
|
|
1
|
+
export * from './isDefined';
|
|
2
|
+
export * from './delay';
|
package/src/utils/isDefined.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// check undefined or null
|
|
2
|
-
export const isDefined = <T>(value: T): boolean => {
|
|
3
|
-
return value !== undefined && value !== null;
|
|
4
|
-
};
|
|
1
|
+
// check undefined or null
|
|
2
|
+
export const isDefined = <T>(value: T): boolean => {
|
|
3
|
+
return value !== undefined && value !== null;
|
|
4
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "dist",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"target": "es5",
|
|
6
|
-
"lib": ["es6", "dom", "es2016", "es2017", "es2019"],
|
|
7
|
-
"downlevelIteration": true,
|
|
8
|
-
"sourceMap": true,
|
|
9
|
-
"allowJs": false,
|
|
10
|
-
"jsx": "react",
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"noImplicitReturns": true,
|
|
15
|
-
"noImplicitThis": true,
|
|
16
|
-
"noImplicitAny": true,
|
|
17
|
-
"strictNullChecks": true,
|
|
18
|
-
"suppressImplicitAnyIndexErrors": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"types": ["resize-observer-browser", "node"]
|
|
22
|
-
},
|
|
23
|
-
"include": ["src"],
|
|
24
|
-
"exclude": ["node_modules", "dist", "example", "rollup.config.js"]
|
|
25
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"target": "es5",
|
|
6
|
+
"lib": ["es6", "dom", "es2016", "es2017", "es2019"],
|
|
7
|
+
"downlevelIteration": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"allowJs": false,
|
|
10
|
+
"jsx": "react",
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"noImplicitReturns": true,
|
|
15
|
+
"noImplicitThis": true,
|
|
16
|
+
"noImplicitAny": true,
|
|
17
|
+
"strictNullChecks": true,
|
|
18
|
+
"suppressImplicitAnyIndexErrors": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"types": ["resize-observer-browser", "node"]
|
|
22
|
+
},
|
|
23
|
+
"include": ["src"],
|
|
24
|
+
"exclude": ["node_modules", "dist", "example", "rollup.config.js"]
|
|
25
|
+
}
|