Revert listen to touchable changes

This commit is contained in:
Vadim
2021-08-16 00:59:00 +03:00
parent 848b5b2ee1
commit efdca46391
4 changed files with 15 additions and 14 deletions

View File

@@ -20,16 +20,17 @@ export function createDispatcher(source) {
export function getIsTouchable() {
return (
// ('ontouchstart' in window) || // not changing value during browser view switching (mobile <-> desktop)
(navigator.maxTouchPoints > 0) ||
(navigator.msMaxTouchPoints > 0)
('ontouchstart' in window)
// || // not changing value during browser view switching (mobile <-> desktop)
// (navigator.maxTouchPoints > 0) ||
// (navigator.msMaxTouchPoints > 0)
)
}
export function addTouchableChangeEventListener(cb) {
let isTouchable = null
function handleResize() {
function handleTouchableChange() {
const isTouchableNext = getIsTouchable();
if (isTouchable !== isTouchableNext) {
cb(isTouchableNext)
@@ -37,8 +38,7 @@ export function addTouchableChangeEventListener(cb) {
}
}
const interval = setIntervalImmediate(handleResize, 500);
const interval = setIntervalImmediate(handleTouchableChange, 500);
return () => {
clearInterval(interval)
}