Collections of custom hooks for ReactJS
npm install @sh4/hooks@sh4/hooksCollection of my custom React hooks.
``shell`
npm i @sh4/hooks
1. useWindowScroll() - get x axis, y axis and window scroll direction (up, down, left, right)
#### Reference
Default value for delay / throttle (milisecond) is 0
`ts`
interface Scroll {
x: number;
y: number;
direction: "up" | "down" | "right" | "left" | undefined;
}
const useWindowScroll = (delay = 0): Scroll => {};
#### Example
`tsx
import React from "react";
import { useWindowScroll } from "@saifudinhasan/hooks";
const Component = () => {
const { x, y, direction } = useWindowScroll(200);
useEffect(
{
// do something
},
[direction]
);
return
;export default Component;
``