From 8cdb6b80a1c3878bd3eb653eb5317828254e01b6 Mon Sep 17 00:00:00 2001 From: Til Date: Fri, 15 May 2026 11:41:33 +0200 Subject: [PATCH] mobile long press to select --- copyparty/web/browser.css | 15 +++++++++++++++ copyparty/web/browser.js | 28 ++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index 9aed748f..cb01a2c0 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -2354,6 +2354,21 @@ html.b .btn { position: relative; top: 0; } +#gridsel.temp { + animation: pulsating 1s alternate infinite; +} + +@keyframes pulsating { + 0% { + border-color: var(--btn-bg); + background: var(--btn-bg); + } + + 100% { + border-color: var(--btn-1-bg); + background: color-mix(in oklab, var(--btn-1-bg) 30%, transparent); + } +} #twig, #gridchop a:first-child, #gridzoom a:first-child { diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 8f470c81..ce5483f4 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -6701,7 +6701,10 @@ window.thegrid = (function () { clmod(ggrid, 'noupscale', !v) }); bcfg_bind(r, 'x3', 'grid3x', dth3x.endsWith('y'), r.set_x3); - bcfg_bind(r, 'sel', 'gridsel', false, r.loadsel); + bcfg_bind(r, 'sel', 'gridsel', false, function () { + clmod(ebi('gridsel'), 'temp', false); + r.loadsel(); + }); bcfg_bind(r, 'en', 'griden', dgrid, function (v) { v ? loadgrid() : r.setvis(true); pbar.onresize(); @@ -9699,6 +9702,8 @@ var msel = (function () { }; r.loadsel = function (vp, sel) { + clmod(ebi('gridsel'), 'temp', false); + if (!sel || !r.so || !ebi(r.so)) r.so = r.pr = null; @@ -9785,6 +9790,11 @@ var msel = (function () { r.origin_tr(tr); } r.selui(); + + if (MOBILE && thegrid.sel && msel.getsel().length == 0 && clgot(ebi('gridsel'), 'on') == false){ + thegrid.sel = false; + clmod(ebi('gridsel'), 'temp', false); + } }; r.origin_tr = function (tr) { r.so = tr2id(tr); @@ -10796,8 +10806,13 @@ var rcm = (function () { clmod(shr, 'hide', !can_shr || !get_evpath().indexOf(have_shr)); shr.innerHTML = has_sel ? L.rc_shs : L.rc_shf; - if(MOBILE){ + if (MOBILE) { clmod(menu, 'large', true); + if (target && !forceopen){ + thegrid.sel = true; + clmod(ebi('gridsel'), 'temp', true); + return; + } } var vh = document.documentElement.clientHeight; var vw = document.documentElement.clientWidth; @@ -10838,19 +10853,24 @@ var rcm = (function () { menu.style.display = ''; } + var forceopen; r.show = function (e) { if (!r.enabled || e.shiftKey || (r.double && menu.style.display) || /doc=/.exec(location.search)) { r.hide(true); return true; } + var gfile = thegrid.en && e.target && e.target.closest('#ggrid > a'); + var target = gfile || e.target; + r.hide(true); + if (MOBILE) + forceopen = !gfile || clgot(gfile, 'sel'); if (selFile.elem && !selFile.no_dsel) { clmod(selFile.elem, "sel", false); msel.selui(); } ev(e); - var gfile = thegrid.en && e.target && e.target.closest('#ggrid > a'); - show(e.clientX, e.clientY, gfile || e.target, gfile); + show(e.clientX, e.clientY, target, gfile); return false; }