Download JoL-player/src/utils/useWindowClient.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 701 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/JoL-player/src/utils/useWindowClient.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/JoL-player/src/utils/useWindowClient.ts
-
curl -L -o useWindowClient.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/JoL-player/src/utils/useWindowClient.ts
701 Bytes
| import { useState, useEffect } from "react"; | |
| export interface useWindowSizeType { | |
| clientX: number; | |
| clientY: number; | |
| [prs: string]: any; | |
| } | |
| const useWindowClient = (): useWindowSizeType => { | |
| const [windowDistance, setWindowDistance] = useState<useWindowSizeType>({ | |
| clientX: 0, | |
| clientY: 0, | |
| }); | |
| useEffect(() => { | |
| function handle(e: MouseEvent) { | |
| setWindowDistance((pre) => { | |
| return { | |
| clientX: e.clientX, | |
| clientY: e.clientY, | |
| }; | |
| }); | |
| } | |
| window.addEventListener("mousemove", handle); | |
| return () => window.removeEventListener("mousemove", handle); | |
| }, []); | |
| return { ...windowDistance }; | |
| }; | |
| export default useWindowClient; | |