Open context menu from bottom-left corner when needed

This commit is contained in:
Ivan Kozik 2015-04-25 11:42:21 +00:00
parent 8b55d0c20c
commit 18ff9a8127

View File

@ -300,6 +300,7 @@ a.ignore {
left: 0;
top: 0;
display: none;
cursor: default;
}
.context-menu-entry {
@ -1299,6 +1300,13 @@ ContextMenuRenderer.prototype.onContextMenu = function(ev) {
entry.classList.add('context-menu-entry');
appendAny(this.element, entry);
}
// If the bottom of the context menu is outside the viewport, move the context
// menu up, so that it appears to have opened from its bottom-left corner.
// + 1 pixel so that the pointer lands inside the element and turns on cursor: default
if(ev.clientY + this.element.offsetHeight > document.documentElement.clientHeight) {
this.element.style.top = (ev.clientY - this.element.offsetHeight + 1) + "px";
}
};
ContextMenuRenderer.prototype.blur = function() {