[Selection] Position context menus

This commit is contained in:
Victor Woeltjen 2016-09-25 20:30:42 -07:00
parent f926bd9762
commit c9a0a469f6

View File

@ -6,13 +6,25 @@ define(['zepto'], function ($) {
OverlayManager.prototype.show = function (view, x, y) {
var $container = $('<div></div>');
var w = this.$body.width();
var h = this.$body.height();
x = x || 0;
y = y || 0;
$container.css('position', 'absolute');
$container.css('left', x + 'px');
$container.css('top', y + 'px');
if (x < w / 2) {
$container.css('left', x + 'px');
} else {
$container.css('right', (w - x) + 'px');
}
if (x < h / 2) {
$container.css('top', y + 'px');
} else {
$container.css('bottom', (h - y) + 'px');
}
view.show($container[0]);