2021-06-09 23:25:28 +10:00
|
|
|
function usePreventSelect() {
|
2021-06-17 11:30:06 +10:00
|
|
|
function clearSelection() {
|
|
|
|
|
if (window.getSelection) {
|
|
|
|
|
window.getSelection().removeAllRanges();
|
|
|
|
|
}
|
|
|
|
|
if (document.selection) {
|
|
|
|
|
document.selection.empty();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-09 23:25:28 +10:00
|
|
|
function preventSelect() {
|
2021-06-17 11:30:06 +10:00
|
|
|
clearSelection();
|
2021-06-09 23:25:28 +10:00
|
|
|
document.body.classList.add("no-select");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resumeSelect() {
|
|
|
|
|
document.body.classList.remove("no-select");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [preventSelect, resumeSelect];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default usePreventSelect;
|