mirror of
https://github.com/drawdb-io/drawdb.git
synced 2026-02-13 02:12:56 +08:00
fullscreen indicator
This commit is contained in:
16
src/hooks/useFullscreen.js
Normal file
16
src/hooks/useFullscreen.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useState } from "react";
|
||||
import { useEventListener } from "usehooks-ts";
|
||||
|
||||
export default function useFullscreen() {
|
||||
const [value, setValue] = useState(() => {
|
||||
return document.fullscreenElement === document.documentElement;
|
||||
});
|
||||
|
||||
function handleFullscreenChange() {
|
||||
setValue(document.fullscreenElement === document.documentElement);
|
||||
}
|
||||
|
||||
useEventListener("fullscreenchange", handleFullscreenChange, document);
|
||||
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user