Skip to content

Commit

Permalink
Added small offset for context menu at edge of screen
Browse files Browse the repository at this point in the history
  • Loading branch information
EspeuteClement committed Apr 21, 2023
1 parent f7241e5 commit 8889a86
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bin/libs/jquery.contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,7 @@
var outerHeight = $menu.outerHeight();
var outerWidth = $menu.outerWidth();

var minOffset = 8;
if(menuHeight > winHeight){
$menu.css({
'height' : winHeight + 'px',
Expand All @@ -1628,14 +1629,14 @@
$menu.css({
'top': winScrollTop + 'px'
});
} else if($menuOffset.top + outerHeight > winScrollTop + winHeight){
} else if($menuOffset.top + outerHeight + minOffset > winScrollTop + winHeight){
$menu.css({
'top': $menuOffset.top - (($menuOffset.top + outerHeight) - (winScrollTop + winHeight)) + "px"
'top': $menuOffset.top - (($menuOffset.top + outerHeight) - (winScrollTop + winHeight) + minOffset) + "px"
});
}
if($menuOffset.left + outerWidth > winScrollLeft + winWidth){
if($menuOffset.left + outerWidth + minOffset > winScrollLeft + winWidth){
$menu.css({
'left': $menuOffset.left - (($menuOffset.left + outerWidth) - (winScrollLeft + winWidth)) + "px"
'left': $menuOffset.left - (($menuOffset.left + outerWidth) - (winScrollLeft + winWidth) + minOffset) + "px"
});
}
}
Expand Down

0 comments on commit 8889a86

Please sign in to comment.