about summary refs log tree commit diff
path: root/app/javascript/mastodon/is_mobile.js
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2022-10-11 04:41:25 +0900
committerGitHub <noreply@github.com>2022-10-10 21:41:25 +0200
commitd7873433256746c9b453aeca31520d68c6de4975 (patch)
treed6828f609ad8bbeea224a36d6f9aa678df50e505 /app/javascript/mastodon/is_mobile.js
parent05148e2c77ba7a2ac2cbf2569f60a64440e8a55a (diff)
Hide list panel from nav bar in mobile layout (#19337)
Diffstat (limited to 'app/javascript/mastodon/is_mobile.js')
-rw-r--r--app/javascript/mastodon/is_mobile.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/javascript/mastodon/is_mobile.js b/app/javascript/mastodon/is_mobile.js
index 2926eb4b1..3c8ec1545 100644
--- a/app/javascript/mastodon/is_mobile.js
+++ b/app/javascript/mastodon/is_mobile.js
@@ -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);
 };