Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 66x 8x 8x 2x 2x 2x 8x 8x | import { useEffect, useState } from "react"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import fscreen from 'fscreen'; const useFullScreen = (): { fullScreen: boolean; toggleFullScreen: () => void; } => { const [fullScreen, setFullScreen] = useState<boolean>(false); useEffect(() => { fscreen.addEventListener('fullscreenchange', () => setFullScreen(!(fscreen.fullscreenElement == null))); return () => { fscreen.removeEventListener('fullscreenchange', () => setFullScreen(!(fscreen.fullscreenElement == null))); }; }, []); const toggleFullScreen = (): void => { if (fullScreen === false) { fscreen.requestFullscreen(document.documentElement); } else { fscreen.exitFullscreen(); } setFullScreen(!fullScreen); }; return { fullScreen, toggleFullScreen }; }; export default useFullScreen; |