Skip to content

Commit

Permalink
Merge pull request #156 from vineeth-vk11/#154
Browse files Browse the repository at this point in the history
handling context submenus on mobile devices
  • Loading branch information
jelveh authored Mar 26, 2024
2 parents 28acf71 + da8351d commit 907ecbe
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/UI/UIContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,26 @@ 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,
parent_id: menu_id,
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,
}
})
}
Expand Down

0 comments on commit 907ecbe

Please sign in to comment.