From f22120dc38775d5ee2fec6a104a350395ccdf7e9 Mon Sep 17 00:00:00 2001 From: Hagay Goshen Date: Wed, 30 Oct 2024 22:34:39 +0200 Subject: [PATCH] feature: cloudcmd: prevent unselect being fired on panel click when in mobile view (#422) * Prevent unselect being fired on panel click when in mobile view * Prevent unselect being fired on panel click when in mobile view after review --------- Co-authored-by: hagaygo --- client/client.js | 1 + client/listeners/index.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/client.js b/client/client.js index 139dd002..c9f268fe 100644 --- a/client/client.js +++ b/client/client.js @@ -60,6 +60,7 @@ function CloudCmdProto(DOM) { this.prefixURL = ''; this.MIN_ONE_PANEL_WIDTH = 1155; + this.MOBILE_ONE_PANEL_WIDTH = 600; this.HOST = location.origin || location.protocol + '//' + location.host; this.TITLE = 'Cloud Commander'; diff --git a/client/listeners/index.js b/client/listeners/index.js index db927833..cc475794 100644 --- a/client/listeners/index.js +++ b/client/listeners/index.js @@ -55,7 +55,7 @@ const {Events} = DOM; const EventsFiles = { mousedown: exec.with(execIfNotUL, setCurrentFileByEvent), - click: execAll([onClick, unselect]), + click: execAll([onClick, exec.with(execIfNotMobile, unselect)]), dragstart: exec.with(execIfNotUL, onDragStart), dblclick: exec.with(execIfNotUL, onDblClick), touchstart: exec.with(execIfNotUL, onTouch), @@ -221,6 +221,12 @@ function copyPath(el) { .catch(CloudCmd.log); } +function execIfNotMobile(callback , event) +{ + if (window.innerWidth > CloudCmd.MOBILE_ONE_PANEL_WIDTH) + callback(event); +} + function execIfNotUL(callback, event) { const {target} = event; const {tagName} = target;