Skip to content
Snippets Groups Projects
Commit 6c1282af authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when clicking close to right border menu doesn't exceed window

parent 9c61ca93
No related branches found
No related tags found
1 merge request!323Resolve "long click is triggered when there is no long click and sometimes is overridden by browser behaviour"
Pipeline #
...@@ -10,6 +10,8 @@ var Functions = require('../Functions'); ...@@ -10,6 +10,8 @@ var Functions = require('../Functions');
var logger = require('../logger'); var logger = require('../logger');
var MARGIN = 5;
function ContextMenu(params) { function ContextMenu(params) {
AbstractGuiElement.call(this, params); AbstractGuiElement.call(this, params);
var self = this; var self = this;
...@@ -79,9 +81,18 @@ ContextMenu.prototype.open = function (x, y, timestamp) { ...@@ -79,9 +81,18 @@ ContextMenu.prototype.open = function (x, y, timestamp) {
var self = this; var self = this;
self._handledTimeStamp = timestamp; self._handledTimeStamp = timestamp;
var left = x;
var right = "";
if ($(self.getElement()).width() + x + MARGIN > $(document).width()) {
left = Math.max(0, $(document).width() - $(self.getElement()).width() - MARGIN);
right = 0;
}
$(self.getElement()).show().css({ $(self.getElement()).show().css({
position: "absolute", position: "absolute",
left: x, left: left,
right: right,
top: y top: y
}).off('click').on('click', 'a', function (e) { }).off('click').on('click', 'a', function (e) {
//close if this is not a submenu //close if this is not a submenu
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment