right click menu mobile enlargement and dynamic position

This commit is contained in:
Til Schmitter 2026-04-11 14:23:12 +02:00
parent 97a8d8e833
commit 49e38ff549
2 changed files with 33 additions and 4 deletions

View file

@ -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;

View file

@ -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)};