mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-07 02:58:11 +00:00
26 lines
546 B
TypeScript
26 lines
546 B
TypeScript
'use client';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
export function useIsTouchDevice() {
|
|
const [isTouchDevice, setIsTouchDevice] = useState(false);
|
|
|
|
useEffect(() => {
|
|
function onResize() {
|
|
setIsTouchDevice(
|
|
'ontouchstart' in window ||
|
|
navigator.maxTouchPoints > 0 ||
|
|
navigator.maxTouchPoints > 0
|
|
);
|
|
}
|
|
|
|
window.addEventListener('resize', onResize);
|
|
onResize();
|
|
|
|
return () => {
|
|
window.removeEventListener('resize', onResize);
|
|
};
|
|
}, []);
|
|
|
|
return isTouchDevice;
|
|
}
|