@sh4/hooks
v1.0.0
Published
Collections of custom hooks for ReactJS
Downloads
6
Maintainers
Readme
@sh4/hooks
Collection of my custom React hooks.
Instalation
npm i @sh4/hooks
Usage
- useWindowScroll() - get x axis, y axis and window scroll direction (up, down, left, right)
Window scroll
Reference
Default value for delay / throttle (milisecond) is 0
interface Scroll {
x: number;
y: number;
direction: "up" | "down" | "right" | "left" | undefined;
}
const useWindowScroll = (delay = 0): Scroll => {};
Example
import React from "react";
import { useWindowScroll } from "@saifudinhasan/hooks";
const Component = () => {
const { x, y, direction } = useWindowScroll(200);
useEffect(
{
// do something
},
[direction]
);
return <div />;
};
export default Component;