stone-kit 0.0.1068 → 0.0.1069
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type UseClientWidth = {
|
|
2
2
|
currentClientWidth: number;
|
|
3
3
|
isMobile: boolean;
|
|
4
4
|
isTablet: boolean;
|
|
@@ -6,3 +6,5 @@ export declare const useClientWidth: () => {
|
|
|
6
6
|
isMobileBorder: boolean;
|
|
7
7
|
isFullTablet: boolean;
|
|
8
8
|
};
|
|
9
|
+
export declare const useClientWidth: () => UseClientWidth;
|
|
10
|
+
export {};
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as l, useCallback as w, useEffect as i } from "react";
|
|
2
2
|
const a = () => {
|
|
3
|
-
const [e, n] =
|
|
3
|
+
const [e, n] = l(
|
|
4
|
+
typeof window < "u" ? window.innerWidth : 0
|
|
5
|
+
), t = w(() => {
|
|
4
6
|
n(window.innerWidth);
|
|
5
7
|
}, [n]);
|
|
6
8
|
i(() => (window.addEventListener("resize", t), () => window.removeEventListener("resize", t)), []), i(() => {
|
|
7
9
|
t();
|
|
8
10
|
}, []);
|
|
9
|
-
const
|
|
10
|
-
return {
|
|
11
|
+
const o = e !== 0 && e < 1024, s = typeof window < "u" ? e !== 0 && e < 768 : !1, r = e >= 768 && e < 1440, d = e > 1023 && e < 1440, u = e >= 1440;
|
|
12
|
+
return {
|
|
13
|
+
currentClientWidth: e,
|
|
14
|
+
isMobile: o,
|
|
15
|
+
isTablet: d,
|
|
16
|
+
isDesktop: u,
|
|
17
|
+
isMobileBorder: s,
|
|
18
|
+
isFullTablet: r
|
|
19
|
+
};
|
|
11
20
|
};
|
|
12
21
|
export {
|
|
13
22
|
a as useClientWidth
|