handling context submenus on mobile devices

This commit is contained in:
vineethvk11 2024-03-22 01:34:17 +05:30
parent 198507fce4
commit da8351dc82

View File

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