This commit is contained in:
gpt-engineer-app[bot]
2026-01-22 23:52:02 +00:00
parent ccca90c504
commit 07a2fe0c17
4 changed files with 34 additions and 36 deletions
+4 -9
View File
@@ -7,18 +7,13 @@ const MatrixCursor = () => {
const [isTouchDevice, setIsTouchDevice] = useState(false);
useEffect(() => {
// Detect touch device - check for touch capability and if primary input is touch
// Detect touch device - only consider it a touch device if primary pointer is coarse (touch)
const checkTouchDevice = () => {
const hasTouchScreen = 'ontouchstart' in window ||
navigator.maxTouchPoints > 0 ||
// @ts-ignore - msMaxTouchPoints is IE-specific
navigator.msMaxTouchPoints > 0;
// Also check if the device has a fine pointer (mouse)
// Check if the device has a fine pointer (mouse) as primary input
const hasFinePrimary = window.matchMedia('(pointer: fine)').matches;
// Consider it a touch device if it has touch AND doesn't have fine pointer as primary
setIsTouchDevice(hasTouchScreen && !hasFinePrimary);
// Consider it a touch device only if it doesn't have a fine pointer as primary
setIsTouchDevice(!hasFinePrimary);
};
checkTouchDevice();