From 49e38ff549506f4cd8a4a67dae0984dc91e8a709 Mon Sep 17 00:00:00 2001 From: Til Schmitter Date: Sat, 11 Apr 2026 14:23:12 +0200 Subject: [PATCH] right click menu mobile enlargement and dynamic position --- copyparty/web/browser.css | 6 +++++- copyparty/web/browser.js | 31 ++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index 7f5db354..918a91e6 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -4351,7 +4351,8 @@ html.e #detree { } #rcm { - position: absolute; + position: fixed; + overflow-y: auto; display: none; background: #fff; background: var(--bg); @@ -4361,6 +4362,9 @@ html.e #detree { box-shadow: 0 0 .3rem var(--bg-d3); z-index: 3; } +#rcm.large a { + padding: 1em; +} #rcm > * { display: block; diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 3915e463..e49fbe8f 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -10017,8 +10017,33 @@ var rcm = (function () { clmod(shr, 'hide', !can_shr || !get_evpath().indexOf(have_shr)); shr.innerHTML = has_sel ? L.rc_shs : L.rc_shf; - menu.style.left = x + 5 + 'px'; - menu.style.top = y + 5 + 'px'; + if(MOBILE){ + clmod(menu, 'large', true); + } + var vh = document.documentElement.clientHeight; + var vw = document.documentElement.clientWidth; + + var maxh = Math.min(y, vh / 2); + menu.style.maxHeight = `calc(100vh - ${maxh}px - 2em)`; + + if(y > vh / 2){ + // low click => menu upwards + menu.style.top = ''; + menu.style.bottom = `${vh - y}px`; + } + else{ + menu.style.top = `${y}px`; + menu.style.bottom = ''; + } + if(x > vw / 2){ + // far right click => menu leftwards + menu.style.left = ''; + menu.style.right = `${vw - x}px`; + } + else{ + menu.style.left = `${x}px`; + menu.style.right = ''; + } menu.style.display = 'block'; menu.focus(); } @@ -10046,7 +10071,7 @@ var rcm = (function () { } ev(e); var gfile = thegrid.en && e.target && e.target.closest('#ggrid > a'); - show(xscroll() + e.clientX, yscroll() + e.clientY, gfile || e.target, gfile); + show(e.clientX, e.clientY, gfile || e.target, gfile); return false; }; menu.onblur = function() {setTimeout(r.hide)};