Skip to content

Commit 6372881

Browse files
committed
Build for release
1 parent d336a20 commit 6372881

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

cytoscape-cxtmenu.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,17 @@ var cxtmenu = function cxtmenu(params) {
122122
setStyles(wrapper, {
123123
position: 'absolute',
124124
zIndex: options.zIndex,
125-
userSelect: 'none'
125+
userSelect: 'none',
126+
pointerEvents: 'none' // prevent events on menu in modern browsers
127+
});
128+
129+
// prevent events on menu in legacy browsers
130+
['mousedown', 'mousemove', 'mouseup', 'contextmenu'].forEach(function (evt) {
131+
wrapper.addEventListener(evt, function (e) {
132+
e.preventDefault();
133+
134+
return false;
135+
});
126136
});
127137

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

190200
if (command.disabled === true || command.enabled === false) {
191-
content.classList.add('cxtmenu-disabled');
201+
content.setAttribute('class', 'cxtmenu-content cxtmenu-disabled');
192202
}
193203

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

318328
function updatePixelRatio() {
319329
var pxr = getPixelRatio();
320-
var w = container.clientWidth;
321-
var h = container.clientHeight;
330+
var w = containerSize;
331+
var h = containerSize;
322332

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

333343
var redrawing = true;
334344
var redrawQueue = {};
335-
var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
345+
346+
var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function (fn) {
347+
return setTimeout(fn, 16);
348+
};
349+
336350
var redraw = function redraw() {
337351
if (redrawQueue.drawBg) {
338352
drawBg.apply(null, redrawQueue.drawBg);
@@ -632,7 +646,9 @@ module.exports = Object.assign != null ? Object.assign.bind(Object) : function (
632646
srcs[_key - 1] = arguments[_key];
633647
}
634648

635-
srcs.forEach(function (src) {
649+
srcs.filter(function (src) {
650+
return src != null;
651+
}).forEach(function (src) {
636652
Object.keys(src).forEach(function (k) {
637653
return tgt[k] = src[k];
638654
});
@@ -691,9 +707,13 @@ module.exports = defaults;
691707
var removeEles = function removeEles(query) {
692708
var ancestor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
693709

694-
ancestor.querySelectorAll(query).forEach(function (el) {
695-
return el.parentNode.removeChild(el);
696-
});
710+
var els = ancestor.querySelectorAll(query);
711+
712+
for (var i = 0; i < els.length; i++) {
713+
var el = els[i];
714+
715+
el.parentNode.removeChild(el);
716+
}
697717
};
698718

699719
var setStyles = function setStyles(el, style) {

0 commit comments

Comments
 (0)