mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-29 10:03:41 +00:00
Set touchstart listener to 'passive', remove 'once' (#5011)
This commit is contained in:
parent
7d16bb379d
commit
e5c65b3067
|
@ -1,3 +1,5 @@
|
||||||
|
import detectPassiveEvents from 'detect-passive-events';
|
||||||
|
|
||||||
const LAYOUT_BREAKPOINT = 1024;
|
const LAYOUT_BREAKPOINT = 1024;
|
||||||
|
|
||||||
export function isMobile(width) {
|
export function isMobile(width) {
|
||||||
|
@ -5,11 +7,16 @@ export function isMobile(width) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||||
let userTouching = false;
|
|
||||||
|
|
||||||
window.addEventListener('touchstart', () => {
|
let userTouching = false;
|
||||||
|
let listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
|
||||||
|
|
||||||
|
function touchListener() {
|
||||||
userTouching = true;
|
userTouching = true;
|
||||||
}, { once: true });
|
window.removeEventListener('touchstart', touchListener, listenerOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('touchstart', touchListener, listenerOptions);
|
||||||
|
|
||||||
export function isUserTouching() {
|
export function isUserTouching() {
|
||||||
return userTouching;
|
return userTouching;
|
||||||
|
|
Loading…
Reference in a new issue