cytoscape-edge-bend-editing
Advanced tools
Comparing version 1.1.4 to 1.2.0
{ | ||
"name": "cytoscape-edge-bend-editing", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "A Cytoscape.js extension enables editing edge bend points", | ||
@@ -5,0 +5,0 @@ "main": "cytoscape-edge-bend-editing.js", |
@@ -23,3 +23,3 @@ cytoscape-edge-bend-editing | ||
* cytoscape-undo-redo.js(optional) ^1.0.1 | ||
* cytoscape-context-menus.js(optional) ^1.0.3 | ||
* cytoscape-context-menus.js(optional) ^2.0.0 | ||
@@ -56,10 +56,23 @@ | ||
`cy.edgeBendEditing(options)` | ||
To initialize with options. | ||
```js | ||
var instance = cy.edgeBendEditing( options ); | ||
``` | ||
`ele.getSegmentPoints()` | ||
get segment points of an edge in an array A, | ||
A[2 * i] is the x coordinate and A[2 * i + 1] is the y coordinate | ||
of the ith bend point. (Returns undefined if the curve style is not segments) | ||
An instance has a number of functions available: | ||
```js | ||
/* | ||
* Get segment points of the given edge in an array A, | ||
* A[2 * i] is the x coordinate and A[2 * i + 1] is the y coordinate | ||
* of the ith bend point. (Returns undefined if the curve style is not segments) | ||
*/ | ||
instance.getSegmentPoints(ele); | ||
``` | ||
You can also get an existing instance: | ||
```js | ||
cy.contextMenus('get'); | ||
``` | ||
## Default Options | ||
@@ -66,0 +79,0 @@ ```js |
@@ -49,39 +49,40 @@ ;(function($$, $){ 'use strict'; | ||
// merge the options with default ones | ||
options = extend(defaults, opts); | ||
if( opts !== 'get' ) { | ||
// merge the options with default ones | ||
options = extend(defaults, opts); | ||
// define edgebendediting-hasbendpoints css class | ||
cy.style().selector('.edgebendediting-hasbendpoints').css({ | ||
'curve-style': 'segments', | ||
'segment-distances': function (ele) { | ||
return bendPointUtilities.getSegmentDistancesString(ele); | ||
}, | ||
'segment-weights': function (ele) { | ||
return bendPointUtilities.getSegmentWeightsString(ele); | ||
}, | ||
'edge-distances': 'node-position' | ||
}); | ||
// init bend positions | ||
bendPointUtilities.initBendPoints(options.bendPositionsFunction, cy.edges()); | ||
if(options.enabled) | ||
$(cy.container()).cytoscapeEdgeBendEditing(options, cy); | ||
else | ||
$(cy.container()).cytoscapeEdgeBendEditing("unbind", cy); | ||
} | ||
// define edgebendediting-hasbendpoints css class | ||
cy.style().selector('.edgebendediting-hasbendpoints').css({ | ||
'curve-style': 'segments', | ||
'segment-distances': function (ele) { | ||
return bendPointUtilities.getSegmentDistancesString(ele); | ||
}, | ||
'segment-weights': function (ele) { | ||
return bendPointUtilities.getSegmentWeightsString(ele); | ||
}, | ||
'edge-distances': 'node-position' | ||
}); | ||
// init bend positions | ||
bendPointUtilities.initBendPoints(options.bendPositionsFunction, cy.edges()); | ||
if(options.enabled) | ||
$(cy.container()).cytoscapeEdgeBendEditing(options, cy); | ||
else | ||
$(cy.container()).cytoscapeEdgeBendEditing("unbind", cy); | ||
var instance = { | ||
/* | ||
* get segment points of the given edge in an array A, | ||
* A[2 * i] is the x coordinate and A[2 * i + 1] is the y coordinate | ||
* of the ith bend point. (Returns undefined if the curve style is not segments) | ||
*/ | ||
getSegmentPoints: function(ele) { | ||
return bendPointUtilities.getSegmentPoints(ele); | ||
} | ||
}; | ||
return this; // chainability | ||
return instance; // chainability | ||
} ); | ||
/* | ||
* get segment points of an edge in an array A, | ||
* A[2 * i] is the x coordinate and A[2 * i + 1] is the y coordinate | ||
* of the ith bend point. (Returns undefined if the curve style is not segments) | ||
*/ | ||
cytoscape( 'collection', 'getSegmentPoints', function(){ | ||
var ele = this; | ||
return bendPointUtilities.getSegmentPoints(ele); | ||
} ); | ||
@@ -88,0 +89,0 @@ }; |
@@ -75,6 +75,7 @@ var debounce = require('./debounce'); | ||
if(cy.contextMenus) { | ||
var menus = cy.contextMenus('get'); | ||
// If context menus is active just append menu items else activate the extension | ||
// with initial menu items | ||
if (cy.isContextMenusActive()) { | ||
cy.appendMenuItems(menuItems); | ||
if (menus.isActive()) { | ||
menus.appendMenuItems(menuItems); | ||
} | ||
@@ -81,0 +82,0 @@ else { |
Sorry, the diff of this file is too big to display
108
186063