Changes
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user