Typescript

This commit is contained in:
Mitchell McCaffrey
2021-07-16 16:58:14 +10:00
parent d80bfa2f1e
commit c7b8990a7b
19 changed files with 97 additions and 74 deletions
+19
View File
@@ -0,0 +1,19 @@
function usePreventSelect() {
function clearSelection() {
window?.getSelection()?.removeAllRanges();
// @ts-ignore
document?.selection?.empty();
}
function preventSelect() {
clearSelection();
document.body.classList.add("no-select");
}
function resumeSelect() {
document.body.classList.remove("no-select");
}
return [preventSelect, resumeSelect];
}
export default usePreventSelect;