mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
handling context submenus on mobile devices
This commit is contained in:
parent
198507fce4
commit
da8351dc82
@ -185,6 +185,17 @@ function UIContextMenu(options){
|
||||
if($(`.context-menu[data-id="${menu_id}-${$(e).attr('data-action')}"]`).length === 0){
|
||||
// close other submenus
|
||||
$(`.context-menu[parent-element-id="${menu_id}"]`).remove();
|
||||
|
||||
// Calculate the position for the submenu
|
||||
let submenu_x_pos, submenu_y_pos;
|
||||
if (isMobile.phone || isMobile.tablet) {
|
||||
submenu_y_pos = y_pos;
|
||||
submenu_x_pos = x_pos;
|
||||
} else {
|
||||
submenu_y_pos = item_rect_box.top - 5;
|
||||
submenu_x_pos = x_pos + item_rect_box.width + 15;
|
||||
}
|
||||
|
||||
// open the new submenu
|
||||
UIContextMenu({
|
||||
items: options.items[parseInt($(e).attr('data-action'))].items,
|
||||
@ -192,8 +203,8 @@ function UIContextMenu(options){
|
||||
is_submenu: true,
|
||||
id: menu_id + '-' + $(e).attr('data-action'),
|
||||
position:{
|
||||
top: item_rect_box.top - 5,
|
||||
left: x_pos + item_rect_box.width + 15,
|
||||
top: submenu_y_pos,
|
||||
left: submenu_x_pos,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user