Skip to content
Snippets Groups Projects
Commit e5c65b30 authored by Nolan Lawson's avatar Nolan Lawson Committed by Eugen Rochko
Browse files

Set touchstart listener to 'passive', remove 'once' (#5011)

parent 7d16bb37
No related branches found
No related tags found
No related merge requests found
import detectPassiveEvents from 'detect-passive-events';
const LAYOUT_BREAKPOINT = 1024;
export function isMobile(width) {
......@@ -5,11 +7,16 @@ export function isMobile(width) {
};
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
let userTouching = false;
let listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
window.addEventListener('touchstart', () => {
function touchListener() {
userTouching = true;
}, { once: true });
window.removeEventListener('touchstart', touchListener, listenerOptions);
}
window.addEventListener('touchstart', touchListener, listenerOptions);
export function isUserTouching() {
return userTouching;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment