soapbox/app/soapbox/is_mobile.js

30 wiersze
670 B
JavaScript
Czysty Zwykły widok Historia

2020-03-27 20:59:38 +00:00
'use strict';
import { supportsPassiveEvents } from 'detect-passive-events';
2020-03-27 20:59:38 +00:00
const LAYOUT_BREAKPOINT = 630;
export function isMobile(width) {
return width <= LAYOUT_BREAKPOINT;
2021-08-03 19:22:51 +00:00
}
2020-03-27 20:59:38 +00:00
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
let userTouching = false;
const listenerOptions = supportsPassiveEvents ? { passive: true } : false;
2020-03-27 20:59:38 +00:00
function touchListener() {
userTouching = true;
window.removeEventListener('touchstart', touchListener, listenerOptions);
}
window.addEventListener('touchstart', touchListener, listenerOptions);
export function isUserTouching() {
return userTouching;
}
export function isIOS() {
return iOS;
2021-08-03 19:22:51 +00:00
}