You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
776 B
35 lines
776 B
7 years ago
|
import detectPassiveEvents from 'detect-passive-events';
|
||
|
|
||
7 years ago
|
const LAYOUT_BREAKPOINT = 630;
|
||
8 years ago
|
|
||
8 years ago
|
export function isMobile(width, columns) {
|
||
|
switch (columns) {
|
||
8 years ago
|
case 'multiple':
|
||
8 years ago
|
return false;
|
||
8 years ago
|
case 'single':
|
||
8 years ago
|
return true;
|
||
|
default:
|
||
|
return width <= LAYOUT_BREAKPOINT;
|
||
|
}
|
||
8 years ago
|
};
|
||
8 years ago
|
|
||
|
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||
7 years ago
|
|
||
8 years ago
|
let userTouching = false;
|
||
7 years ago
|
let listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
|
||
8 years ago
|
|
||
7 years ago
|
function touchListener() {
|
||
8 years ago
|
userTouching = true;
|
||
7 years ago
|
window.removeEventListener('touchstart', touchListener, listenerOptions);
|
||
|
}
|
||
|
|
||
|
window.addEventListener('touchstart', touchListener, listenerOptions);
|
||
8 years ago
|
|
||
|
export function isUserTouching() {
|
||
|
return userTouching;
|
||
|
}
|
||
8 years ago
|
|
||
|
export function isIOS() {
|
||
|
return iOS;
|
||
|
};
|