Enhancing file browser with drag-to-select.

This commit is contained in:
Roland 2025-12-26 11:28:10 -07:00
parent 150ad6ee78
commit bdaccdeca1
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
5 changed files with 525 additions and 21 deletions

View file

@ -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;
}