cytoscape-cxtmenu
Advanced tools
Comparing version 3.0.2 to 3.1.0
@@ -461,61 +461,73 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
if (typeof options.commands === 'function') { | ||
commands = options.commands(target); | ||
var res = options.commands(target); | ||
if (res.then) { | ||
res.then(function (_commands) { | ||
commands = _commands; | ||
openMenu(); | ||
}); | ||
} else { | ||
commands = res; | ||
openMenu(); | ||
} | ||
} else { | ||
commands = options.commands; | ||
openMenu(); | ||
} | ||
if (!commands || commands.length === 0) { | ||
return; | ||
} | ||
function openMenu() { | ||
if (!commands || commands.length === 0) { | ||
return; | ||
} | ||
zoomEnabled = cy.userZoomingEnabled(); | ||
cy.userZoomingEnabled(false); | ||
zoomEnabled = cy.userZoomingEnabled(); | ||
cy.userZoomingEnabled(false); | ||
panEnabled = cy.userPanningEnabled(); | ||
cy.userPanningEnabled(false); | ||
panEnabled = cy.userPanningEnabled(); | ||
cy.userPanningEnabled(false); | ||
boxEnabled = cy.boxSelectionEnabled(); | ||
cy.boxSelectionEnabled(false); | ||
boxEnabled = cy.boxSelectionEnabled(); | ||
cy.boxSelectionEnabled(false); | ||
grabbable = target.grabbable && target.grabbable(); | ||
if (grabbable) { | ||
target.ungrabify(); | ||
} | ||
grabbable = target.grabbable && target.grabbable(); | ||
if (grabbable) { | ||
target.ungrabify(); | ||
} | ||
var rp = void 0, | ||
rw = void 0, | ||
rh = void 0; | ||
if (!isCy && ele.isNode() && !ele.isParent() && !options.atMouse) { | ||
rp = ele.renderedPosition(); | ||
rw = ele.renderedWidth(); | ||
rh = ele.renderedHeight(); | ||
} else { | ||
rp = e.renderedPosition || e.cyRenderedPosition; | ||
rw = 1; | ||
rh = 1; | ||
} | ||
var rp = void 0, | ||
rw = void 0, | ||
rh = void 0; | ||
if (!isCy && ele.isNode() && !ele.isParent() && !options.atMouse) { | ||
rp = ele.renderedPosition(); | ||
rw = ele.renderedWidth(); | ||
rh = ele.renderedHeight(); | ||
} else { | ||
rp = e.renderedPosition || e.cyRenderedPosition; | ||
rw = 1; | ||
rh = 1; | ||
} | ||
offset = getOffset(container); | ||
offset = getOffset(container); | ||
ctrx = rp.x; | ||
ctry = rp.y; | ||
ctrx = rp.x; | ||
ctry = rp.y; | ||
createMenuItems(); | ||
createMenuItems(); | ||
setStyles(parent, { | ||
display: 'block', | ||
left: rp.x - r + 'px', | ||
top: rp.y - r + 'px' | ||
}); | ||
setStyles(parent, { | ||
display: 'block', | ||
left: rp.x - r + 'px', | ||
top: rp.y - r + 'px' | ||
}); | ||
rs = Math.max(rw, rh) / 2; | ||
rs = Math.max(rs, options.minSpotlightRadius); | ||
rs = Math.min(rs, options.maxSpotlightRadius); | ||
rs = Math.max(rw, rh) / 2; | ||
rs = Math.max(rs, options.minSpotlightRadius); | ||
rs = Math.min(rs, options.maxSpotlightRadius); | ||
queueDrawBg(); | ||
queueDrawBg(); | ||
activeCommandI = undefined; | ||
activeCommandI = undefined; | ||
inGesture = true; | ||
gestureStartEvent = e; | ||
inGesture = true; | ||
gestureStartEvent = e; | ||
} | ||
}).on('cxtdrag tapdrag', options.selector, dragHandler = function dragHandler(e) { | ||
@@ -522,0 +534,0 @@ |
{ | ||
"name": "cytoscape-cxtmenu", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"description": "A circular, swipeable context menu extension for Cytoscape.js", | ||
@@ -11,6 +11,4 @@ "main": "cytoscape-cxtmenu.js", | ||
"scripts": { | ||
"postpublish": "run-s gh-pages:demo gh-pages:deploy gh-pages:clean", | ||
"gh-pages:demo": "cpy demo.html . --rename=index.html", | ||
"gh-pages:deploy": "gh-pages -d . -v node_modules/**", | ||
"gh-pages:clean": "rimraf index.html", | ||
"postpublish": "run-s gh-pages", | ||
"gh-pages": "gh-pages -d pages", | ||
"copyright": "update license", | ||
@@ -17,0 +15,0 @@ "lint": "eslint src", |
@@ -89,3 +89,3 @@ cytoscape-cxtmenu | ||
*/ | ||
], // function( ele ){ return [ /*...*/ ] }, // example function for commands | ||
], // function( ele ){ return [ /*...*/ ] }, // a function that returns commands or a promise of commands | ||
fillColor: 'rgba(0, 0, 0, 0.75)', // the background colour of the menu | ||
@@ -92,0 +92,0 @@ activeFillColor: 'rgba(1, 105, 217, 0.75)', // the colour used to indicate the selected command |
@@ -375,57 +375,69 @@ const defaults = require('./defaults'); | ||
if( typeof options.commands === 'function' ){ | ||
commands = options.commands(target); | ||
const res = options.commands(target); | ||
if( res.then ){ | ||
res.then(_commands => { | ||
commands = _commands; | ||
openMenu(); | ||
}) | ||
} else { | ||
commands = res; | ||
openMenu(); | ||
} | ||
} else { | ||
commands = options.commands; | ||
openMenu(); | ||
} | ||
if( !commands || commands.length === 0 ){ return; } | ||
function openMenu(){ | ||
if( !commands || commands.length === 0 ){ return; } | ||
zoomEnabled = cy.userZoomingEnabled(); | ||
cy.userZoomingEnabled( false ); | ||
zoomEnabled = cy.userZoomingEnabled(); | ||
cy.userZoomingEnabled( false ); | ||
panEnabled = cy.userPanningEnabled(); | ||
cy.userPanningEnabled( false ); | ||
panEnabled = cy.userPanningEnabled(); | ||
cy.userPanningEnabled( false ); | ||
boxEnabled = cy.boxSelectionEnabled(); | ||
cy.boxSelectionEnabled( false ); | ||
boxEnabled = cy.boxSelectionEnabled(); | ||
cy.boxSelectionEnabled( false ); | ||
grabbable = target.grabbable && target.grabbable(); | ||
if( grabbable ){ | ||
target.ungrabify(); | ||
} | ||
grabbable = target.grabbable && target.grabbable(); | ||
if( grabbable ){ | ||
target.ungrabify(); | ||
} | ||
let rp, rw, rh; | ||
if( !isCy && ele.isNode() && !ele.isParent() && !options.atMouse ){ | ||
rp = ele.renderedPosition(); | ||
rw = ele.renderedWidth(); | ||
rh = ele.renderedHeight(); | ||
} else { | ||
rp = e.renderedPosition || e.cyRenderedPosition; | ||
rw = 1; | ||
rh = 1; | ||
} | ||
let rp, rw, rh; | ||
if( !isCy && ele.isNode() && !ele.isParent() && !options.atMouse ){ | ||
rp = ele.renderedPosition(); | ||
rw = ele.renderedWidth(); | ||
rh = ele.renderedHeight(); | ||
} else { | ||
rp = e.renderedPosition || e.cyRenderedPosition; | ||
rw = 1; | ||
rh = 1; | ||
} | ||
offset = getOffset(container); | ||
offset = getOffset(container); | ||
ctrx = rp.x; | ||
ctry = rp.y; | ||
ctrx = rp.x; | ||
ctry = rp.y; | ||
createMenuItems(); | ||
createMenuItems(); | ||
setStyles(parent, { | ||
display: 'block', | ||
left: (rp.x - r) + 'px', | ||
top: (rp.y - r) + 'px' | ||
}); | ||
setStyles(parent, { | ||
display: 'block', | ||
left: (rp.x - r) + 'px', | ||
top: (rp.y - r) + 'px' | ||
}); | ||
rs = Math.max(rw, rh)/2; | ||
rs = Math.max(rs, options.minSpotlightRadius); | ||
rs = Math.min(rs, options.maxSpotlightRadius); | ||
rs = Math.max(rw, rh)/2; | ||
rs = Math.max(rs, options.minSpotlightRadius); | ||
rs = Math.min(rs, options.maxSpotlightRadius); | ||
queueDrawBg(); | ||
queueDrawBg(); | ||
activeCommandI = undefined; | ||
activeCommandI = undefined; | ||
inGesture = true; | ||
gestureStartEvent = e; | ||
inGesture = true; | ||
gestureStartEvent = e; | ||
} | ||
}) | ||
@@ -432,0 +444,0 @@ |
Sorry, the diff of this file is not supported yet
82949
1206
16