mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-15 16:23:27 +01:00
* chore: expose scrollActiveElementIntoView * feat(utils): editable element * fix: memoize exceptionRefs, use animation frame and check editable element * fix: improve btn on mobile * chore(drps): bump framer motion version * fix(link): big fix * chore: remove comment code * feat: touch device
21 lines
460 B
TypeScript
21 lines
460 B
TypeScript
import { useState, useEffect } from "react"
|
|
|
|
export function useTouchSensor() {
|
|
const [isTouchDevice, setIsTouchDevice] = useState(false)
|
|
|
|
useEffect(() => {
|
|
const detectTouch = () => {
|
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0)
|
|
}
|
|
|
|
detectTouch()
|
|
window.addEventListener("touchstart", detectTouch, false)
|
|
|
|
return () => {
|
|
window.removeEventListener("touchstart", detectTouch)
|
|
}
|
|
}, [])
|
|
|
|
return isTouchDevice
|
|
}
|