Fix pop-out player appearing on mobile screens in web UI (#15157)
Fix #15092
This commit is contained in:
parent
04a079e723
commit
18ca4e0e9a
6 changed files with 79 additions and 72 deletions
|
@ -1,9 +1,18 @@
|
|||
import { supportsPassiveEvents } from 'detect-passive-events';
|
||||
import { forceSingleColumn } from 'mastodon/initial_state';
|
||||
|
||||
const LAYOUT_BREAKPOINT = 630;
|
||||
|
||||
export function isMobile(width) {
|
||||
return width <= LAYOUT_BREAKPOINT;
|
||||
export const isMobile = width => width <= LAYOUT_BREAKPOINT;
|
||||
|
||||
export const layoutFromWindow = () => {
|
||||
if (isMobile(window.innerWidth)) {
|
||||
return 'mobile';
|
||||
} else if (forceSingleColumn) {
|
||||
return 'single-column';
|
||||
} else {
|
||||
return 'multi-column';
|
||||
}
|
||||
};
|
||||
|
||||
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||
|
@ -11,17 +20,13 @@ const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|||
let userTouching = false;
|
||||
let listenerOptions = supportsPassiveEvents ? { passive: true } : false;
|
||||
|
||||
function touchListener() {
|
||||
const touchListener = () => {
|
||||
userTouching = true;
|
||||
window.removeEventListener('touchstart', touchListener, listenerOptions);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('touchstart', touchListener, listenerOptions);
|
||||
|
||||
export function isUserTouching() {
|
||||
return userTouching;
|
||||
}
|
||||
export const isUserTouching = () => userTouching;
|
||||
|
||||
export function isIOS() {
|
||||
return iOS;
|
||||
};
|
||||
export const isIOS = () => iOS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue