0
0
Fork 0

Hide list panel from nav bar in mobile layout (#19337)

This commit is contained in:
Yamagishi Kazutoshi 2022-10-11 04:41:25 +09:00 committed by GitHub
parent 05148e2c77
commit d787343325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 11 deletions

View file

@ -1,10 +1,19 @@
// @ts-check
import { supportsPassiveEvents } from 'detect-passive-events';
import { forceSingleColumn } from 'mastodon/initial_state';
const LAYOUT_BREAKPOINT = 630;
/**
* @param {number} width
* @returns {boolean}
*/
export const isMobile = width => width <= LAYOUT_BREAKPOINT;
/**
* @returns {string}
*/
export const layoutFromWindow = () => {
if (isMobile(window.innerWidth)) {
return 'mobile';
@ -17,11 +26,13 @@ export const layoutFromWindow = () => {
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
const listenerOptions = supportsPassiveEvents ? { passive: true } : false;
let userTouching = false;
let listenerOptions = supportsPassiveEvents ? { passive: true } : false;
const touchListener = () => {
userTouching = true;
window.removeEventListener('touchstart', touchListener, listenerOptions);
};