swisnl / jQuery-contextMenu

jQuery contextMenu plugin & polyfill
https://swisnl.github.io/jQuery-contextMenu/
MIT License
2.25k stars 744 forks source link

When position.top set manually, menu repositions to top of page when too low for window #704

Closed gjohncock closed 4 years ago

gjohncock commented 4 years ago

Having the position of the menu default to mouse position is not adequate for me. I want the menu's top, left corner to be set to the top, right of the element that launches the menu. I have used the position option to manually calculate the top left corner of the menu and this works as I expect it to. The issue arises when the part of the menu will extend past the bottom of the view. When this occurs, the menu appears right at the top of the window. I understand why and would like to be able to trap this condition and change the position of the menu so that the bottom, left corner is set to the bottom, right corner of the element that launches the menu.

bbrala commented 4 years ago

Either overwrite the determinePosition or the position function on initialisation. The code to fix that is in there.

https://github.com/swisnl/jQuery-contextMenu/blob/master/dist/jquery.contextMenu.js#L146