Skip to content

Commit

Permalink
Build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkfranz committed Oct 24, 2018
1 parent d336a20 commit 6372881
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions cytoscape-cxtmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,17 @@ var cxtmenu = function cxtmenu(params) {
setStyles(wrapper, {
position: 'absolute',
zIndex: options.zIndex,
userSelect: 'none'
userSelect: 'none',
pointerEvents: 'none' // prevent events on menu in modern browsers
});

// prevent events on menu in legacy browsers
['mousedown', 'mousemove', 'mouseup', 'contextmenu'].forEach(function (evt) {
wrapper.addEventListener(evt, function (e) {
e.preventDefault();

return false;
});
});

setStyles(parent, {
Expand Down Expand Up @@ -188,7 +198,7 @@ var cxtmenu = function cxtmenu(params) {
setStyles(content, command.contentStyle || {});

if (command.disabled === true || command.enabled === false) {
content.classList.add('cxtmenu-disabled');
content.setAttribute('class', 'cxtmenu-content cxtmenu-disabled');
}

parent.appendChild(item);
Expand Down Expand Up @@ -317,8 +327,8 @@ var cxtmenu = function cxtmenu(params) {

function updatePixelRatio() {
var pxr = getPixelRatio();
var w = container.clientWidth;
var h = container.clientHeight;
var w = containerSize;
var h = containerSize;

canvas.width = w * pxr;
canvas.height = h * pxr;
Expand All @@ -332,7 +342,11 @@ var cxtmenu = function cxtmenu(params) {

var redrawing = true;
var redrawQueue = {};
var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;

var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function (fn) {
return setTimeout(fn, 16);
};

var redraw = function redraw() {
if (redrawQueue.drawBg) {
drawBg.apply(null, redrawQueue.drawBg);
Expand Down Expand Up @@ -632,7 +646,9 @@ module.exports = Object.assign != null ? Object.assign.bind(Object) : function (
srcs[_key - 1] = arguments[_key];
}

srcs.forEach(function (src) {
srcs.filter(function (src) {
return src != null;
}).forEach(function (src) {
Object.keys(src).forEach(function (k) {
return tgt[k] = src[k];
});
Expand Down Expand Up @@ -691,9 +707,13 @@ module.exports = defaults;
var removeEles = function removeEles(query) {
var ancestor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;

ancestor.querySelectorAll(query).forEach(function (el) {
return el.parentNode.removeChild(el);
});
var els = ancestor.querySelectorAll(query);

for (var i = 0; i < els.length; i++) {
var el = els[i];

el.parentNode.removeChild(el);
}
};

var setStyles = function setStyles(el, style) {
Expand Down

0 comments on commit 6372881

Please sign in to comment.