mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 12:26:19 -05:00
Enhancing file browser with drag-to-select.
This commit is contained in:
parent
150ad6ee78
commit
bdaccdeca1
5 changed files with 525 additions and 21 deletions
|
|
@ -49,6 +49,24 @@ import _ from "lodash";
|
|||
import {TagsSelector} from "../Tags";
|
||||
import {useForm} from "./useForm";
|
||||
|
||||
export const useIsTouchDevice = () => {
|
||||
// Detects if the device has a coarse pointer (touch screen).
|
||||
// Used to disable drag selection on mobile devices.
|
||||
const [isTouchDevice, setIsTouchDevice] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const touchQuery = window.matchMedia('(pointer: coarse)');
|
||||
setIsTouchDevice(touchQuery.matches);
|
||||
|
||||
const handleChange = (e) => setIsTouchDevice(e.matches);
|
||||
touchQuery.addEventListener('change', handleChange);
|
||||
|
||||
return () => touchQuery.removeEventListener('change', handleChange);
|
||||
}, []);
|
||||
|
||||
return isTouchDevice;
|
||||
};
|
||||
|
||||
const calculatePage = (offset, limit) => {
|
||||
return offset && limit ? Math.round((offset / limit) + 1) : 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue