@adamjanicki/ui 1.2.1 → 1.2.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/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useScrollLock.d.ts +1 -1
- package/hooks/useScrollLock.js +1 -1
- package/hooks/useWindowResize.d.ts +7 -0
- package/hooks/useWindowResize.js +13 -0
- package/package.json +1 -1
package/hooks/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { default as useMediaQuery } from "./useMediaQuery";
|
|
|
3
3
|
export { default as useWatchScroll } from "./useWatchScroll";
|
|
4
4
|
export { default as useFocusTrap } from "./useFocusTrap";
|
|
5
5
|
export { default as useScrollToHash } from "./useScrollToHash";
|
|
6
|
+
export { default as useWindowResize } from "./useWindowResize";
|
package/hooks/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { default as useMediaQuery } from "./useMediaQuery";
|
|
|
3
3
|
export { default as useWatchScroll } from "./useWatchScroll";
|
|
4
4
|
export { default as useFocusTrap } from "./useFocusTrap";
|
|
5
5
|
export { default as useScrollToHash } from "./useScrollToHash";
|
|
6
|
+
export { default as useWindowResize } from "./useWindowResize";
|
package/hooks/useScrollLock.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type ScrollLock = {
|
|
|
9
9
|
unlock: () => void;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* Hook to lock and unlock the scroll position
|
|
12
|
+
* Hook to lock and unlock the scroll position.
|
|
13
13
|
* @returns Object with lock and unlock functions to lock and unlock the scroll position
|
|
14
14
|
*/
|
|
15
15
|
declare const useScrollLock: () => ScrollLock;
|
package/hooks/useScrollLock.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
/**
|
|
3
|
-
* Hook to lock and unlock the scroll position
|
|
3
|
+
* Hook to lock and unlock the scroll position.
|
|
4
4
|
* @returns Object with lock and unlock functions to lock and unlock the scroll position
|
|
5
5
|
*/
|
|
6
6
|
var useScrollLock = function () {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A hook that listens for window resize events.
|
|
4
|
+
*
|
|
5
|
+
* @param callback the callback function fired when the window is resized.
|
|
6
|
+
*/
|
|
7
|
+
var useWindowResize = function (callback) {
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
window.addEventListener("resize", callback);
|
|
10
|
+
return function () { return window.removeEventListener("resize", callback); };
|
|
11
|
+
}, [callback]);
|
|
12
|
+
};
|
|
13
|
+
export default useWindowResize;
|