kitzo 2.3.20 → 2.3.21
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/dist/index.d.ts +1 -5
- package/dist/react/hooks/useWindowSize.js +11 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -113,13 +113,9 @@ export declare function useDebounce<T>(value: T, delay?: number): T;
|
|
|
113
113
|
|
|
114
114
|
export declare function useThrottle<T>(value: T, delay?: number): T;
|
|
115
115
|
|
|
116
|
-
export declare function useWindowSize(
|
|
116
|
+
export declare function useWindowSize(updateDelay?: number): {
|
|
117
117
|
screenWidth: number;
|
|
118
118
|
screenHeight: number;
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
declare type UseWindowSizeOptions = {
|
|
122
|
-
updateDelay?: number;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
121
|
export { }
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
1
|
+
import { useState as o, useRef as u, useEffect as c } from "react";
|
|
2
|
+
function d(n = 30) {
|
|
3
|
+
const [t, r] = o({
|
|
4
4
|
screenWidth: window.innerWidth,
|
|
5
5
|
screenHeight: window.innerHeight
|
|
6
|
-
}), e =
|
|
7
|
-
return
|
|
8
|
-
function
|
|
6
|
+
}), e = u(null);
|
|
7
|
+
return c(() => {
|
|
8
|
+
function i() {
|
|
9
9
|
e.current && clearTimeout(e.current), e.current = setTimeout(
|
|
10
10
|
() => {
|
|
11
|
-
|
|
11
|
+
r({
|
|
12
12
|
screenWidth: window.innerWidth,
|
|
13
13
|
screenHeight: window.innerHeight
|
|
14
14
|
});
|
|
@@ -16,11 +16,11 @@ function w(i = {}) {
|
|
|
16
16
|
Math.max(0, +n)
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
return typeof window < "u" && window.addEventListener("resize",
|
|
20
|
-
e.current && clearTimeout(e.current), window.removeEventListener("resize",
|
|
19
|
+
return typeof window < "u" && window.addEventListener("resize", i), () => {
|
|
20
|
+
e.current && clearTimeout(e.current), window.removeEventListener("resize", i);
|
|
21
21
|
};
|
|
22
|
-
}, [n]),
|
|
22
|
+
}, [n]), t;
|
|
23
23
|
}
|
|
24
24
|
export {
|
|
25
|
-
|
|
25
|
+
d as default
|
|
26
26
|
};
|