cytoscape
Advanced tools
Comparing version 2.7.17 to 3.0.0
{ | ||
"name": "cytoscape", | ||
"version": "2.7.17", | ||
"version": "3.0.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Graph theory (a.k.a. network) library for analysis and visualisation", |
@@ -157,3 +157,3 @@ 'use strict'; | ||
// New tentative score for node w | ||
var tempScore = gScore[ cMin.id() ] + weightFn.apply( e, [ e ] ); | ||
var tempScore = gScore[ cMin.id() ] + weightFn( e ); | ||
@@ -160,0 +160,0 @@ // Update gScore for node w if: |
@@ -73,3 +73,3 @@ 'use strict'; | ||
var targetIndex = id2position[ edges[ e ].target().id() ]; | ||
var weight = weightFn.apply( edges[ e ], [ edges[ e ] ] ); | ||
var weight = weightFn( edges[ e ] ); | ||
@@ -106,3 +106,3 @@ var temp = cost[ sourceIndex ] + weight; | ||
var targetIndex = id2position[ edges[ e ].target().id() ]; | ||
var weight = weightFn.apply( edges[ e ], [ edges[ e ] ] ); | ||
var weight = weightFn( edges[ e ] ); | ||
@@ -109,0 +109,0 @@ if( cost[ sourceIndex ] + weight < cost[ targetIndex ] ){ |
@@ -96,3 +96,3 @@ 'use strict'; | ||
var edgeWeight = weightFn.apply( edge, [ edge ] ); | ||
var edgeWeight = weightFn( edge ); | ||
@@ -99,0 +99,0 @@ w = w.id(); |
@@ -14,4 +14,2 @@ 'use strict'; | ||
var options; | ||
var std; | ||
var thisArg; | ||
if( is.plainObject( roots ) && !is.elementOrCollection( roots ) ){ | ||
@@ -22,4 +20,2 @@ options = roots; | ||
directed = options.directed; | ||
std = options.std; | ||
thisArg = options.thisArg; | ||
} | ||
@@ -73,7 +69,3 @@ | ||
if( std ){ | ||
ret = fn.call( thisArg, v, prevEdge, prevNode, j++, depth ); | ||
} else { | ||
ret = fn.call( v, j++, depth, v, prevEdge, prevNode ); | ||
} | ||
ret = fn( v, prevEdge, prevNode, j++, depth ); | ||
@@ -89,6 +81,6 @@ if( ret === true ){ | ||
var vwEdges = v.connectedEdges( directed ? function(){ return this.data( 'source' ) === v.id(); } : undefined ).intersect( edges ); | ||
var vwEdges = v.connectedEdges( directed ? function( ele ){ return ele.data( 'source' ) === v.id(); } : undefined ).intersect( edges ); | ||
for( var i = 0; i < vwEdges.length; i++ ){ | ||
var e = vwEdges[ i ]; | ||
var w = e.connectedNodes( function(){ return this.id() !== v.id(); } ).intersect( nodes ); | ||
var w = e.connectedNodes( function( n ){ return n.id() !== v.id(); } ).intersect( nodes ); | ||
@@ -95,0 +87,0 @@ if( w.length !== 0 && !V[ w.id() ] ){ |
@@ -157,3 +157,3 @@ 'use strict'; | ||
var edge = connEdges[ i ]; | ||
s += weightFn.apply( edge, [ edge ] ); | ||
s += weightFn( edge ); | ||
} | ||
@@ -175,3 +175,3 @@ | ||
var edge = incoming[ i ]; | ||
s_in += weightFn.apply( edge, [ edge ] ); | ||
s_in += weightFn( edge ); | ||
} | ||
@@ -182,3 +182,3 @@ | ||
var edge = outgoing[ i ]; | ||
s_out += weightFn.apply( edge, [ edge ] ); | ||
s_out += weightFn( edge ); | ||
} | ||
@@ -185,0 +185,0 @@ |
@@ -25,3 +25,3 @@ 'use strict'; | ||
var edges = this.edges().filter( function(){ return !this.isLoop(); } ); | ||
var edges = this.edges().filter( function( ele ){ return !ele.isLoop(); } ); | ||
var nodes = this.nodes(); | ||
@@ -57,3 +57,3 @@ | ||
var edge = uvs[ i ]; | ||
var weight = weightFn.apply( edge, [ edge ] ); | ||
var weight = weightFn( edge ); | ||
@@ -60,0 +60,0 @@ if( weight < smallestDistance || !smallestEdge ){ |
@@ -74,3 +74,3 @@ 'use strict'; | ||
var targetIndex = id2position[ edges[ i ].target().id() ]; | ||
var weight = weightFn.apply( edges[ i ], [ edges[ i ] ] ); | ||
var weight = weightFn( edges[ i ] ); | ||
@@ -90,3 +90,3 @@ // Check if already process another edge between same 2 nodes | ||
var targetIndex = id2position[ edges[ i ].source().id() ]; | ||
var weight = weightFn.apply( edges[ i ], [ edges[ i ] ] ); | ||
var weight = weightFn( edges[ i ] ); | ||
@@ -93,0 +93,0 @@ // Check if already process another edge between same 2 nodes |
@@ -38,4 +38,4 @@ 'use strict'; | ||
var S = edges.toArray().sort( function( a, b ){ | ||
var weightA = weightFn.call( a, a ); | ||
var weightB = weightFn.call( b, b ); | ||
var weightA = weightFn( a ); | ||
var weightB = weightFn( b ); | ||
@@ -42,0 +42,0 @@ return weightA - weightB; |
@@ -95,3 +95,3 @@ 'use strict'; | ||
var t = id2position[ edge.target().id() ]; | ||
var w = weightFn.apply( edge, [ edge ] ); | ||
var w = weightFn( edge ); | ||
@@ -98,0 +98,0 @@ // Update matrix |
@@ -59,3 +59,3 @@ 'use strict'; | ||
var pos = fn.apply( ele, [ i, ele ] ); | ||
var pos = fn( ele, i ); | ||
@@ -232,3 +232,2 @@ if( pos && !ele.locked() && !ele.isParent() ){ | ||
includeLabels: includeLabels, | ||
includeShadows: false, | ||
includeOverlays: false, | ||
@@ -345,6 +344,2 @@ | ||
var rotation = ele.pstyle( prefixDash + 'text-rotation' ); | ||
var shadowR = ele.pstyle( 'text-shadow-blur' ).pfValue / 2; | ||
var shadowX = ele.pstyle( 'text-shadow-offset-x' ).pfValue; | ||
var shadowY = ele.pstyle( 'text-shadow-offset-y' ).pfValue; | ||
var shadowOpacity = ele.pstyle( 'text-shadow-opacity' ).value; | ||
var outlineWidth = ele.pstyle( 'text-outline-width' ).pfValue; | ||
@@ -436,11 +431,2 @@ var borderWidth = ele.pstyle( 'text-border-width' ).pfValue; | ||
updateBounds( bounds, lx1, ly1, lx2, ly2 ); | ||
if( options.includeShadows && shadowOpacity > 0 ){ | ||
lx1 += - shadowR + shadowX; | ||
lx2 += + shadowR + shadowX; | ||
ly1 += - shadowR + shadowY; | ||
ly2 += + shadowR + shadowY; | ||
updateBounds( bounds, lx1, ly1, lx2, ly2 ); | ||
} | ||
} | ||
@@ -610,4 +596,4 @@ | ||
// shadow and overlay | ||
///////////////////// | ||
// overlay | ||
////////// | ||
@@ -621,10 +607,2 @@ if( styleEnabled ){ | ||
if( options.includeShadows && ele.pstyle('shadow-opacity').value > 0 ){ | ||
var r = ele.pstyle('shadow-blur').pfValue / 2; | ||
var ox = ele.pstyle('shadow-offset-x').pfValue; | ||
var oy = ele.pstyle('shadow-offset-y').pfValue; | ||
updateBounds( bounds, ex1 - r + ox, ey1 - r + oy, ex2 + r + ox, ey2 + r + oy ); | ||
} | ||
updateBounds( bounds, ex1 - overlayPadding, ey1 - overlayPadding, ex2 + overlayPadding, ey2 + overlayPadding ); | ||
@@ -685,3 +663,2 @@ } | ||
key += tf( opts.includeLabels ); | ||
key += tf( opts.includeShadows ); | ||
key += tf( opts.includeOverlays ); | ||
@@ -716,3 +693,2 @@ | ||
includeLabels: true, | ||
includeShadows: true, | ||
includeOverlays: true, | ||
@@ -741,3 +717,2 @@ useCache: true | ||
includeLabels: util.default( options.includeLabels, defBbOpts.includeLabels ), | ||
includeShadows: util.default( options.includeShadows, defBbOpts.includeShadows ), | ||
includeOverlays: util.default( options.includeOverlays, defBbOpts.includeOverlays ), | ||
@@ -744,0 +719,0 @@ useCache: util.default( options.useCache, defBbOpts.useCache ) |
@@ -8,4 +8,4 @@ 'use strict'; | ||
nodes: function( selector ){ | ||
return this.filter( function( i, element ){ | ||
return element.isNode(); | ||
return this.filter( function( ele, i ){ | ||
return ele.isNode(); | ||
} ).filter( selector ); | ||
@@ -15,8 +15,8 @@ }, | ||
edges: function( selector ){ | ||
return this.filter( function( i, element ){ | ||
return element.isEdge(); | ||
return this.filter( function( ele, i ){ | ||
return ele.isEdge(); | ||
} ).filter( selector ); | ||
}, | ||
filter: function( filter ){ | ||
filter: function( filter, thisArg ){ | ||
if( filter === undefined ){ // check this first b/c it's the most common/performant case | ||
@@ -27,13 +27,15 @@ return this; | ||
} else if( is.fn( filter ) ){ | ||
var elements = []; | ||
var filterEles = this.spawn(); | ||
var eles = this; | ||
for( var i = 0; i < this.length; i++ ){ | ||
var ele = this[ i ]; | ||
for( var i = 0; i < eles.length; i++ ){ | ||
var ele = eles[ i ]; | ||
var include = thisArg ? filter.apply( thisArg, [ ele, i, eles ] ) : filter( ele, i, eles ); | ||
if( filter.apply( ele, [ i, ele ] ) ){ | ||
elements.push( ele ); | ||
if( include ){ | ||
filterEles.merge( ele ); | ||
} | ||
} | ||
return this.spawn( elements ); | ||
return filterEles; | ||
} | ||
@@ -307,18 +309,2 @@ | ||
stdFilter: function( fn, thisArg ){ | ||
var filterEles = []; | ||
var eles = this; | ||
for( var i = 0; i < eles.length; i++ ){ | ||
var ele = eles[ i ]; | ||
var include = thisArg ? fn.apply( thisArg, [ ele, i, eles ] ) : fn( ele, i, eles ); | ||
if( include ){ | ||
filterEles.push( ele ); | ||
} | ||
} | ||
return this.spawn( filterEles ); | ||
}, | ||
max: function( valFn, thisArg ){ | ||
@@ -373,5 +359,5 @@ var max = -Infinity; | ||
fn[ '^' ] = fn[ '(+)' ] = fn[ '(-)' ] = fn.symmetricDifference = fn.symdiff = fn.xor; | ||
fn.fnFilter = fn.filterFn = fn.stdFilter; | ||
fn.fnFilter = fn.filterFn = fn.stdFilter = fn.filter; | ||
fn.complement = fn.abscomp = fn.absoluteComplement; | ||
module.exports = elesfn; |
@@ -7,14 +7,2 @@ 'use strict'; | ||
var elesfn = ({ | ||
each: function( fn ){ | ||
if( is.fn( fn ) ){ | ||
for( var i = 0; i < this.length; i++ ){ | ||
var ele = this[ i ]; | ||
var ret = fn.apply( ele, [ i, ele ] ); | ||
if( ret === false ){ break; } // exit each early on return false | ||
} | ||
} | ||
return this; | ||
}, | ||
forEach: function( fn, thisArg ){ | ||
@@ -136,2 +124,4 @@ if( is.fn( fn ) ){ | ||
elesfn.each = elesfn.forEach; | ||
module.exports = elesfn; |
@@ -22,3 +22,3 @@ 'use strict'; | ||
var newPos = fn.call( node, i, node ); | ||
var newPos = fn( node, i ); | ||
var pos = node.position(); | ||
@@ -103,12 +103,2 @@ | ||
cy.layout( util.extend( {}, options, { | ||
eles: this | ||
} ) ); | ||
return this; | ||
}, | ||
makeLayout: function( options ){ | ||
var cy = this.cy(); | ||
return cy.makeLayout( util.extend( {}, options, { | ||
@@ -122,4 +112,4 @@ eles: this | ||
// aliases: | ||
elesfn.createLayout = elesfn.makeLayout; | ||
elesfn.createLayout = elesfn.makeLayout = elesfn.layout; | ||
module.exports = elesfn; |
@@ -193,56 +193,2 @@ 'use strict'; | ||
visible: function(){ | ||
var cy = this.cy(); | ||
if( !cy.styleEnabled() ){ return true; } | ||
var ele = this[0]; | ||
var hasCompoundNodes = cy.hasCompoundNodes(); | ||
if( ele ){ | ||
if( | ||
ele.pstyle( 'visibility' ).value !== 'visible' | ||
|| ele.pstyle( 'display' ).value !== 'element' | ||
|| ele.pstyle('width').pfValue === 0 | ||
){ | ||
return false; | ||
} | ||
if( ele._private.group === 'nodes' ){ | ||
if( ele.pstyle('height').pfValue === 0 ){ return false; } | ||
if( !hasCompoundNodes ){ return true; } | ||
var parents = ele._private.data.parent ? ele.parents() : null; | ||
if( parents ){ | ||
for( var i = 0; i < parents.length; i++ ){ | ||
var parent = parents[ i ]; | ||
var pVis = parent.pstyle( 'visibility' ).value; | ||
var pDis = parent.pstyle( 'display' ).value; | ||
if( pVis !== 'visible' || pDis !== 'element' ){ | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
} else { | ||
var src = ele._private.source; | ||
var tgt = ele._private.target; | ||
return src.visible() && tgt.visible(); | ||
} | ||
} | ||
}, | ||
hidden: function(){ | ||
var ele = this[0]; | ||
if( ele ){ | ||
return !ele.visible(); | ||
} | ||
}, | ||
effectiveOpacity: function(){ | ||
@@ -303,3 +249,103 @@ var cy = this.cy(); | ||
function defineDerivedStateFunction( specs ){ | ||
var ok = specs.ok; | ||
var edgeOkViaNode = specs.edgeOkViaNode || specs.ok; | ||
var parentOk = specs.parentOk || specs.ok; | ||
return function(){ | ||
var cy = this.cy(); | ||
if( !cy.styleEnabled() ){ return true; } | ||
var ele = this[0]; | ||
var hasCompoundNodes = cy.hasCompoundNodes(); | ||
if( ele ){ | ||
var _p = ele._private; | ||
if( !ok( ele ) ){ return false; } | ||
if( ele.isNode() ){ | ||
if( hasCompoundNodes ){ | ||
var parents = _p.data.parent ? ele.parents() : null; | ||
if( parents ){ for( var i = 0; i < parents.length; i++ ){ | ||
var parent = parents[ i ]; | ||
if( !parentOk( parent ) ){ return false; } | ||
} } | ||
} | ||
return true; | ||
} else { | ||
return edgeOkViaNode( _p.source ) && edgeOkViaNode( _p.target ); | ||
} | ||
} | ||
}; | ||
} | ||
var eleTakesUpSpace = function( ele ){ | ||
return ( | ||
ele.pstyle( 'display' ).value === 'element' | ||
&& ele.width() !== 0 | ||
&& ( ele.isNode() ? ele.height() !== 0 : true ) | ||
); | ||
}; | ||
elesfn.takesUpSpace = defineDerivedStateFunction({ | ||
ok: eleTakesUpSpace | ||
}); | ||
var eleInteractive = function( ele ){ | ||
return ( | ||
ele.pstyle('events').value === 'yes' | ||
&& ele.pstyle('visibility').value === 'visible' | ||
&& eleTakesUpSpace( ele ) | ||
); | ||
}; | ||
var parentInteractive = function( parent ){ | ||
return ( | ||
parent.pstyle('visibility').value === 'visible' | ||
&& eleTakesUpSpace( parent ) | ||
); | ||
}; | ||
elesfn.interactive = defineDerivedStateFunction({ | ||
ok: eleInteractive, | ||
parentOk: parentInteractive, | ||
edgeOkViaNode: eleTakesUpSpace | ||
}); | ||
elesfn.noninteractive = function(){ | ||
var ele = this[0]; | ||
if( ele ){ | ||
return !ele.interactive(); | ||
} | ||
}; | ||
var eleVisible = function( ele ){ | ||
return ( | ||
ele.pstyle( 'visibility' ).value === 'visible' | ||
&& ele.pstyle( 'opacity' ).pfValue !== 0 | ||
&& eleTakesUpSpace( ele ) | ||
); | ||
}; | ||
var edgeVisibleViaNode = eleTakesUpSpace; | ||
elesfn.visible = defineDerivedStateFunction({ | ||
ok: eleVisible, | ||
edgeOkViaNode: edgeVisibleViaNode | ||
}); | ||
elesfn.hidden = function(){ | ||
var ele = this[0]; | ||
if( ele ){ | ||
return !ele.visible(); | ||
} | ||
}; | ||
elesfn.bypass = elesfn.css = elesfn.style; | ||
@@ -306,0 +352,0 @@ elesfn.renderedCss = elesfn.renderedStyle; |
@@ -422,3 +422,3 @@ 'use strict'; | ||
roots: root, | ||
visit: function( i, depth, v, e, u ){ | ||
visit: function( v, e, u, i, depth ){ | ||
visitInComponent( v, component ); | ||
@@ -425,0 +425,0 @@ } |
@@ -81,43 +81,2 @@ 'use strict'; | ||
return collection.remove(); | ||
}, | ||
load: function( elements, onload, ondone ){ | ||
var cy = this; | ||
cy.notifications( false ); | ||
// remove old elements | ||
var oldEles = cy.mutableElements(); | ||
if( oldEles.length > 0 ){ | ||
oldEles.remove(); | ||
} | ||
if( elements != null ){ | ||
if( is.plainObject( elements ) || is.array( elements ) ){ | ||
cy.add( elements ); | ||
} | ||
} | ||
cy.one( 'layoutready', function( e ){ | ||
cy.notifications( true ); | ||
cy.trigger( e ); // we missed this event by turning notifications off, so pass it on | ||
cy.notify( { | ||
type: 'load', | ||
eles: cy.mutableElements() | ||
} ); | ||
cy.one( 'load', onload ); | ||
cy.trigger( 'load' ); | ||
} ).one( 'layoutstop', function(){ | ||
cy.one( 'done', ondone ); | ||
cy.trigger( 'done' ); | ||
} ); | ||
var layoutOpts = util.extend( {}, cy._private.options.layout ); | ||
layoutOpts.eles = cy.elements(); | ||
cy.layout( layoutOpts ); | ||
return this; | ||
} | ||
@@ -124,0 +83,0 @@ }; |
@@ -118,6 +118,2 @@ 'use strict'; | ||
if( is.fn( ani_p.step ) ){ | ||
ani_p.step.call( ele, now ); | ||
} | ||
if( ani_p.applying ){ | ||
@@ -124,0 +120,0 @@ ani_p.applying = false; |
@@ -55,3 +55,2 @@ 'use strict'; | ||
ready: false, // whether ready has been triggered | ||
initrender: false, // has initrender has been triggered | ||
options: options, // cached options | ||
@@ -130,2 +129,39 @@ elements: new Collection( this ), // elements in the graph | ||
var setElesAndLayout = function( elements, onload, ondone ){ | ||
cy.notifications( false ); | ||
// remove old elements | ||
var oldEles = cy.mutableElements(); | ||
if( oldEles.length > 0 ){ | ||
oldEles.remove(); | ||
} | ||
if( elements != null ){ | ||
if( is.plainObject( elements ) || is.array( elements ) ){ | ||
cy.add( elements ); | ||
} | ||
} | ||
cy.one( 'layoutready', function( e ){ | ||
cy.notifications( true ); | ||
cy.trigger( e ); // we missed this event by turning notifications off, so pass it on | ||
cy.notify( { | ||
type: 'load', | ||
eles: cy.mutableElements() | ||
} ); | ||
cy.one( 'load', onload ); | ||
cy.trigger( 'load' ); | ||
} ).one( 'layoutstop', function(){ | ||
cy.one( 'done', ondone ); | ||
cy.trigger( 'done' ); | ||
} ); | ||
var layoutOpts = util.extend( {}, cy._private.options.layout ); | ||
layoutOpts.eles = cy.elements(); | ||
cy.layout( layoutOpts ).run(); | ||
}; | ||
loadExtData([ options.style, options.elements ], function( thens ){ | ||
@@ -140,12 +176,4 @@ var initStyle = thens[0]; | ||
// trigger the passed function for the `initrender` event | ||
if( options.initrender ){ | ||
cy.on( 'initrender', options.initrender ); | ||
cy.on( 'initrender', function(){ | ||
_p.initrender = true; | ||
} ); | ||
} | ||
// initial load | ||
cy.load( initEles, function(){ // onready | ||
setElesAndLayout( initEles, function(){ // onready | ||
cy.startAnimationLoop(); | ||
@@ -193,6 +221,2 @@ _p.ready = true; | ||
initrender: function(){ | ||
return this._private.initrender; | ||
}, | ||
destroy: function(){ | ||
@@ -199,0 +223,0 @@ var cy = this; |
@@ -8,11 +8,3 @@ 'use strict'; | ||
layout: function( params ){ | ||
var layout = this._private.prevLayout = ( params == null ? this._private.prevLayout : this.makeLayout( params ) ); | ||
layout.run(); | ||
return this; // chaining | ||
}, | ||
makeLayout: function( options ){ | ||
layout: function( options ){ | ||
var cy = this; | ||
@@ -55,4 +47,4 @@ | ||
corefn.createLayout = corefn.makeLayout; | ||
corefn.createLayout = corefn.makeLayout = corefn.layout; | ||
module.exports = corefn; |
@@ -28,4 +28,4 @@ 'use strict'; | ||
nodes: function( selector ){ | ||
var nodes = this.$( function(){ | ||
return this.isNode(); | ||
var nodes = this.$( function( ele ){ | ||
return ele.isNode(); | ||
} ); | ||
@@ -41,4 +41,4 @@ | ||
edges: function( selector ){ | ||
var edges = this.$( function(){ | ||
return this.isEdge(); | ||
var edges = this.$( function( ele ){ | ||
return ele.isEdge(); | ||
} ); | ||
@@ -45,0 +45,0 @@ |
@@ -207,3 +207,3 @@ 'use strict'; | ||
return function onImpl( events, selector, data, callback ){ | ||
return function onImpl( events, selector, callback ){ | ||
var self = this; | ||
@@ -215,17 +215,7 @@ var selfIsArrayLike = self.length !== undefined; | ||
if( is.plainObject( selector ) ){ // selector is actually data | ||
callback = data; | ||
data = selector; | ||
selector = undefined; | ||
} else if( is.fn( selector ) || selector === false ){ // selector is actually callback | ||
if( is.fn( selector ) ){ // selector is actually callback | ||
callback = selector; | ||
data = undefined; | ||
selector = undefined; | ||
} | ||
if( is.fn( data ) || data === false ){ // data is actually callback | ||
callback = data; | ||
data = undefined; | ||
} | ||
// if there isn't a callback, we can't really do anything | ||
@@ -268,3 +258,2 @@ // (can't speak for mapped events arg version) | ||
callback: callback, // callback to run | ||
data: data, // extra data in eventObj.data | ||
delegated: selector ? true : false, // whether the evt is delegated | ||
@@ -464,3 +453,3 @@ selector: selector, // the selector to match for delegated events | ||
evt.cyTarget = evt.cyTarget || triggerer; | ||
evt.target = evt.target || triggerer; | ||
evt.cy = evt.cy || cy; | ||
@@ -470,3 +459,3 @@ | ||
evt = new Event( evtObj, { | ||
cyTarget: triggerer, | ||
target: triggerer, | ||
cy: cy, | ||
@@ -488,8 +477,8 @@ namespace: evtObj.namespace | ||
// create a rendered position based on the passed position | ||
if( evt.cyPosition ){ | ||
var pos = evt.cyPosition; | ||
if( evt.position ){ | ||
var pos = evt.position; | ||
var zoom = cy.zoom(); | ||
var pan = cy.pan(); | ||
evt.cyRenderedPosition = { | ||
evt.renderedPosition = { | ||
x: pos.x * zoom + pan.x, | ||
@@ -512,3 +501,3 @@ y: pos.y * zoom + pan.y | ||
var typeMatches = lis.type === evt.type; | ||
var targetMatches = lis.delegated ? ( triggerer !== evt.cyTarget && is.element( evt.cyTarget ) && lis.selObj.matches( evt.cyTarget ) ) : (true); // we're not going to validate the hierarchy; that's too expensive | ||
var targetMatches = lis.delegated ? ( triggerer !== evt.target && is.element( evt.target ) && lis.selObj.matches( evt.target ) ) : (true); // we're not going to validate the hierarchy; that's too expensive | ||
var listenerMatches = nsMatches && typeMatches && targetMatches; | ||
@@ -520,8 +509,2 @@ | ||
if( lis.data ){ // add on data plugged into binding | ||
evt.data = lis.data; | ||
} else { // or clear it in case the event obj is reused | ||
evt.data = undefined; | ||
} | ||
if( lis.unbindSelfOnTrigger || lis.unbindAllBindersOnTrigger ){ // then remove listener | ||
@@ -551,3 +534,3 @@ listeners.splice( k, 1 ); | ||
// run the callback | ||
var context = lis.delegated ? evt.cyTarget : triggerer; | ||
var context = lis.delegated ? evt.target : triggerer; | ||
var ret = lis.callback.apply( context, args ); | ||
@@ -554,0 +537,0 @@ |
@@ -38,8 +38,7 @@ 'use strict'; | ||
this.cy = props.cy; | ||
this.cyTarget = props.cyTarget; | ||
this.cyPosition = props.cyPosition; | ||
this.cyRenderedPosition = props.cyRenderedPosition; | ||
this.target = props.target; | ||
this.position = props.position; | ||
this.renderedPosition = props.renderedPosition; | ||
this.namespace = props.namespace; | ||
this.layout = props.layout; | ||
this.data = props.data; | ||
this.message = props.message; | ||
@@ -46,0 +45,0 @@ } |
@@ -69,3 +69,3 @@ 'use strict'; | ||
roots: unhandledNodes[0], | ||
visit: function( i, depth, node, edge, pNode ){ | ||
visit: function( node, edge, pNode, i, depth ){ | ||
currComp = currComp.add( node ); | ||
@@ -84,4 +84,4 @@ }, | ||
var maxDegree = comp.maxDegree( false ); | ||
var compRoots = comp.filter( function(){ | ||
return this.degree( false ) === maxDegree; | ||
var compRoots = comp.filter( function( ele ){ | ||
return ele.degree( false ) === maxDegree; | ||
} ); | ||
@@ -107,4 +107,4 @@ | ||
directed: options.directed, | ||
visit: function( i, depth, node, edge, pNode ){ | ||
var ele = this[0]; | ||
visit: function( node, edge, pNode, i, depth ){ | ||
var ele = node[0]; | ||
var id = ele.id(); | ||
@@ -212,4 +212,4 @@ | ||
var intersectsDepth = function( node ){ // returns true if has edges pointing in from a higher depth | ||
var edges = node.connectedEdges( function(){ | ||
return this.data( 'target' ) === node.id(); | ||
var edges = node.connectedEdges( function( ele ){ | ||
return ele.data( 'target' ) === node.id(); | ||
} ); | ||
@@ -430,4 +430,4 @@ var thisInfo = node._private.scratch.breadthfirst; | ||
nodes.layoutPositions( this, options, function(){ | ||
return pos[ this.id() ]; | ||
nodes.layoutPositions( this, options, function( node ){ | ||
return pos[ node.id() ]; | ||
} ); | ||
@@ -434,0 +434,0 @@ |
@@ -85,3 +85,3 @@ 'use strict'; | ||
var getPos = function( i, ele ){ | ||
var getPos = function( ele, i ){ | ||
var theta = options.startAngle + i * dTheta * ( clockwise ? 1 : -1 ); | ||
@@ -88,0 +88,0 @@ |
@@ -64,3 +64,3 @@ 'use strict'; | ||
// calculate the node value | ||
value = options.concentric.apply( node, [ node ] ); | ||
value = options.concentric( node ); | ||
nodeValues.push( { | ||
@@ -190,4 +190,4 @@ value: value, | ||
// position the nodes | ||
nodes.layoutPositions( this, options, function(){ | ||
var id = this.id(); | ||
nodes.layoutPositions( this, options, function( ele ){ | ||
var id = ele.id(); | ||
@@ -194,0 +194,0 @@ return pos[ id ]; |
@@ -15,4 +15,4 @@ 'use strict'; | ||
var math = require( '../../math' ); | ||
var Thread = require( '../../thread' ); | ||
var is = require( '../../is' ); | ||
var Promise = require('../../promise'); | ||
@@ -87,4 +87,4 @@ var DEBUG; | ||
// Whether to use threading to speed up the layout | ||
useMultitasking: true | ||
// Pass a reference to weaver to use threads for calculations | ||
weaver: false | ||
}; | ||
@@ -103,3 +103,2 @@ | ||
/** | ||
@@ -113,5 +112,48 @@ * @brief : runs the layout | ||
var thread = this.thread; | ||
var Thread = options.weaver ? options.weaver.Thread : null; | ||
var falseThread = { // use false thread as polyfill | ||
listeners: [], | ||
on: function(e, cb){ | ||
this.listeners.push({ event: e, callback: cb }); | ||
return this; | ||
}, | ||
trigger: function(e){ | ||
if( is.string(e) ){ | ||
e = { type: e }; | ||
} | ||
var matchesEvent = function( l ){ return l.event === e.type; }; | ||
var trigger = function( l ){ l.callback(e); }; | ||
this.listeners.filter( matchesEvent ).forEach( trigger ); | ||
return this; | ||
}, | ||
pass: function( data ){ | ||
this.pass = data; | ||
return this; | ||
}, | ||
run: function( cb ){ | ||
var pass = this.pass; | ||
return new Promise(function( resolve ){ | ||
resolve( cb( pass ) ); | ||
}); | ||
}, | ||
stop: function(){ | ||
return this; | ||
} | ||
}; | ||
function broadcast( message ){ // for false thread | ||
var e = { type: 'message', message: message }; | ||
falseThread.trigger( e ); | ||
} | ||
if( !thread || thread.stopped() ){ | ||
thread = this.thread = Thread( { disabled: !options.useMultitasking } ); | ||
thread = this.thread = Thread ? new Thread() : falseThread; | ||
} | ||
@@ -988,3 +1030,3 @@ | ||
// forces | ||
tempNode.nodeRepulsion = is.fn( options.nodeRepulsion ) ? options.nodeRepulsion.call( n, n ) : options.nodeRepulsion; | ||
tempNode.nodeRepulsion = is.fn( options.nodeRepulsion ) ? options.nodeRepulsion(n) : options.nodeRepulsion; | ||
@@ -1058,4 +1100,4 @@ // Add new node | ||
// Compute ideal length | ||
var idealLength = is.fn( options.idealEdgeLength ) ? options.idealEdgeLength.call( e, e ) : options.idealEdgeLength; | ||
var elasticity = is.fn( options.edgeElasticity ) ? options.edgeElasticity.call( e, e ) : options.edgeElasticity; | ||
var idealLength = is.fn( options.idealEdgeLength ) ? options.idealEdgeLength(e) : options.idealEdgeLength; | ||
var elasticity = is.fn( options.edgeElasticity ) ? options.edgeElasticity(e) : options.edgeElasticity; | ||
@@ -1303,3 +1345,3 @@ // Check if it's an inter graph edge | ||
nodes.positions( function( i, ele ){ | ||
nodes.positions( function( ele, i ){ | ||
var lnode = layoutInfo.layoutNodes[ layoutInfo.idToIndex[ ele.data( 'id' ) ] ]; | ||
@@ -1306,0 +1348,0 @@ // s = "Node: " + lnode.id + ". Refreshed position: (" + |
@@ -45,3 +45,3 @@ 'use strict'; | ||
if( bb.h === 0 || bb.w === 0 ){ | ||
nodes.layoutPositions( this, options, function(){ | ||
nodes.layoutPositions( this, options, function( ele ){ | ||
return { x: bb.x1, y: bb.y1 }; | ||
@@ -209,3 +209,3 @@ } ); | ||
var getPos = function( i, element ){ | ||
var getPos = function( element, i ){ | ||
var x, y; | ||
@@ -212,0 +212,0 @@ |
@@ -36,3 +36,3 @@ 'use strict'; | ||
if( posIsFn ){ | ||
return options.positions.apply( node, [ node ] ); | ||
return options.positions( node ); | ||
} | ||
@@ -49,3 +49,3 @@ | ||
nodes.layoutPositions( this, options, function( i, node ){ | ||
nodes.layoutPositions( this, options, function( node, i ){ | ||
var position = getPosition( node ); | ||
@@ -52,0 +52,0 @@ |
@@ -31,3 +31,3 @@ 'use strict'; | ||
var getPos = function( i, node ){ | ||
var getPos = function( node, i ){ | ||
return { | ||
@@ -34,0 +34,0 @@ x: bb.x1 + Math.round( Math.random() * bb.w ), |
@@ -227,3 +227,3 @@ 'use strict'; | ||
defineArrowShape( 'inhibitor', { | ||
defineArrowShape( 'tee', { | ||
points: [ | ||
@@ -245,4 +245,2 @@ -0.15, 0, | ||
defineArrowShape( 'tee', 'inhibitor' ); | ||
defineArrowShape( 'square', { | ||
@@ -249,0 +247,0 @@ points: [ |
@@ -42,3 +42,3 @@ 'use strict'; | ||
.on('position.* style.* free.*', 'node', function onDirtyModNode( e ){ | ||
var node = e.cyTarget; | ||
var node = e.target; | ||
@@ -57,3 +57,3 @@ enqueue( node, e ); | ||
.on('add.* background.*', 'node', function onDirtyAddNode( e ){ | ||
var ele = e.cyTarget; | ||
var ele = e.target; | ||
@@ -66,3 +66,3 @@ enqueue( ele, e ); | ||
.on('add.* style.*', 'edge', function onDirtyEdge( e ){ | ||
var edge = e.cyTarget; | ||
var edge = e.target; | ||
@@ -74,3 +74,3 @@ enqueue( edge, e ); | ||
.on('remove.*', 'edge', function onDirtyRemoveEdge( e ){ | ||
var edge = e.cyTarget; | ||
var edge = e.target; | ||
var pEdges = edge.parallelEdges(); | ||
@@ -136,7 +136,16 @@ | ||
if( _p.group === 'nodes' ){ | ||
var pos = _p.position; | ||
nodes.push( ele ); | ||
rstyle.nodeX = pos.x; | ||
rstyle.nodeY = pos.y; | ||
rstyle.nodeW = ele.pstyle( 'width' ).pfValue; | ||
rstyle.nodeH = ele.pstyle( 'height' ).pfValue; | ||
} else { // edges | ||
edges.push( ele ); | ||
} | ||
} // if edges | ||
rstyle.clean = true; | ||
@@ -146,18 +155,4 @@ // rstyle.dirtyEvents = null; | ||
// update node data from projections | ||
for( var i = 0; i < nodes.length; i++ ){ | ||
var ele = nodes[i]; | ||
var _p = ele._private; | ||
var rstyle = _p.rstyle; | ||
var pos = _p.position; | ||
this.recalculateNodeLabelProjection( ele ); | ||
rstyle.nodeX = pos.x; | ||
rstyle.nodeY = pos.y; | ||
rstyle.nodeW = ele.pstyle( 'width' ).pfValue; | ||
rstyle.nodeH = ele.pstyle( 'height' ).pfValue; | ||
} | ||
this.recalculateEdgeProjections( edges ); | ||
this.recalculateLabelProjections( nodes, edges ); | ||
@@ -171,4 +166,2 @@ // update edge data from projections | ||
this.recalculateEdgeLabelProjections( ele ); | ||
// update rstyle positions | ||
@@ -230,7 +223,7 @@ rstyle.srcX = rs.arrowStartX; | ||
BRp.findNearestElement = function( x, y, visibleElementsOnly, isTouch ){ | ||
return this.findNearestElements( x, y, visibleElementsOnly, isTouch )[0]; | ||
BRp.findNearestElement = function( x, y, interactiveElementsOnly, isTouch ){ | ||
return this.findNearestElements( x, y, interactiveElementsOnly, isTouch )[0]; | ||
}; | ||
BRp.findNearestElements = function( x, y, visibleElementsOnly, isTouch ){ | ||
BRp.findNearestElements = function( x, y, interactiveElementsOnly, isTouch ){ | ||
var self = this; | ||
@@ -249,2 +242,6 @@ var r = this; | ||
if( interactiveElementsOnly ){ | ||
eles = eles.interactive; | ||
} | ||
function addEle( ele, sqDist ){ | ||
@@ -284,4 +281,2 @@ if( ele.isNode() ){ | ||
if( node.pstyle( 'events' ).strValue === 'no' ){ return; } | ||
var width = node.outerWidth() + 2 * nodeThreshold; | ||
@@ -298,9 +293,2 @@ var height = node.outerHeight() + 2 * nodeThreshold; | ||
){ | ||
var visible = !visibleElementsOnly || ( node.visible() && !node.transparent() ); | ||
// exit early if invisible edge and must be visible | ||
if( visibleElementsOnly && !visible ){ | ||
return; | ||
} | ||
var shape = r.nodeShapes[ self.getNodeShape( node ) ]; | ||
@@ -321,4 +309,2 @@ | ||
if( edge.pstyle('events').strValue === 'no' ){ return; } | ||
var rs = _p.rscratch; | ||
@@ -334,24 +320,2 @@ var styleWidth = edge.pstyle( 'width' ).pfValue; | ||
// exit early if invisible edge and must be visible | ||
var passedVisibilityCheck; | ||
var passesVisibilityCheck = function(){ | ||
if( passedVisibilityCheck !== undefined ){ | ||
return passedVisibilityCheck; | ||
} | ||
if( !visibleElementsOnly ){ | ||
passedVisibilityCheck = true; | ||
return true; | ||
} | ||
var visible = edge.visible() && !edge.transparent(); | ||
if( visible ){ | ||
passedVisibilityCheck = true; | ||
return true; | ||
} | ||
passedVisibilityCheck = false; | ||
return false; | ||
}; | ||
if( rs.edgeType === 'segments' || rs.edgeType === 'straight' || rs.edgeType === 'haystack' ){ | ||
@@ -363,3 +327,3 @@ var pts = rs.allpts; | ||
(inEdgeBB = math.inLineVicinity( x, y, pts[ i ], pts[ i + 1], pts[ i + 2], pts[ i + 3], width2 )) | ||
&& passesVisibilityCheck() && | ||
&& | ||
widthSq > ( sqDist = math.sqdistToFiniteLine( x, y, pts[ i ], pts[ i + 1], pts[ i + 2], pts[ i + 3] ) ) | ||
@@ -377,3 +341,3 @@ ){ | ||
(inEdgeBB = math.inBezierVicinity( x, y, pts[ i ], pts[ i + 1], pts[ i + 2], pts[ i + 3], pts[ i + 4], pts[ i + 5], width2 )) | ||
&& passesVisibilityCheck() && | ||
&& | ||
(widthSq > (sqDist = math.sqdistToQuadraticBezier( x, y, pts[ i ], pts[ i + 1], pts[ i + 2], pts[ i + 3], pts[ i + 4], pts[ i + 5] )) ) | ||
@@ -388,27 +352,26 @@ ){ | ||
// if we're close to the edge but didn't hit it, maybe we hit its arrows | ||
if( passesVisibilityCheck() ){ | ||
var src = src || _p.source; | ||
var tgt = tgt || _p.target; | ||
var arSize = self.getArrowWidth( styleWidth ); | ||
var src = src || _p.source; | ||
var tgt = tgt || _p.target; | ||
var arrows = [ | ||
{ name: 'source', x: rs.arrowStartX, y: rs.arrowStartY, angle: rs.srcArrowAngle }, | ||
{ name: 'target', x: rs.arrowEndX, y: rs.arrowEndY, angle: rs.tgtArrowAngle }, | ||
{ name: 'mid-source', x: rs.midX, y: rs.midY, angle: rs.midsrcArrowAngle }, | ||
{ name: 'mid-target', x: rs.midX, y: rs.midY, angle: rs.midtgtArrowAngle } | ||
]; | ||
var arSize = self.getArrowWidth( styleWidth ); | ||
for( var i = 0; i < arrows.length; i++ ){ | ||
var ar = arrows[ i ]; | ||
var shape = r.arrowShapes[ edge.pstyle( ar.name + '-arrow-shape' ).value ]; | ||
var arrows = [ | ||
{ name: 'source', x: rs.arrowStartX, y: rs.arrowStartY, angle: rs.srcArrowAngle }, | ||
{ name: 'target', x: rs.arrowEndX, y: rs.arrowEndY, angle: rs.tgtArrowAngle }, | ||
{ name: 'mid-source', x: rs.midX, y: rs.midY, angle: rs.midsrcArrowAngle }, | ||
{ name: 'mid-target', x: rs.midX, y: rs.midY, angle: rs.midtgtArrowAngle } | ||
]; | ||
if( | ||
shape.roughCollide( x, y, arSize, ar.angle, { x: ar.x, y: ar.y }, edgeThreshold ) | ||
&& | ||
shape.collide( x, y, arSize, ar.angle, { x: ar.x, y: ar.y }, edgeThreshold ) | ||
){ | ||
addEle( edge ); | ||
return true; | ||
} | ||
for( var i = 0; i < arrows.length; i++ ){ | ||
var ar = arrows[ i ]; | ||
var shape = r.arrowShapes[ edge.pstyle( ar.name + '-arrow-shape' ).value ]; | ||
if( | ||
shape.roughCollide( x, y, arSize, ar.angle, { x: ar.x, y: ar.y }, edgeThreshold ) | ||
&& | ||
shape.collide( x, y, arSize, ar.angle, { x: ar.x, y: ar.y }, edgeThreshold ) | ||
){ | ||
addEle( edge ); | ||
return true; | ||
} | ||
@@ -522,5 +485,3 @@ } | ||
BRp.getAllInBox = function( x1, y1, x2, y2 ){ | ||
var eles = this.getCachedZSortedEles(); | ||
var nodes = eles.nodes; | ||
var edges = eles.edges; | ||
var eles = this.getCachedZSortedEles().interactive; | ||
var box = []; | ||
@@ -543,44 +504,44 @@ | ||
for( var i = 0; i < nodes.length; i++ ){ | ||
var node = nodes[ i ]; | ||
var nodeBb = node.boundingBox( { | ||
includeNodes: true, | ||
includeEdges: false, | ||
includeLabels: false, | ||
includeShadows: false | ||
} ); | ||
for( var e = 0; e < eles.length; e++ ){ | ||
var ele = eles[e]; | ||
if( math.boundingBoxesIntersect( boxBb, nodeBb ) ){ | ||
box.push( nodes[ i ] ); | ||
} | ||
} | ||
if( ele.isNode() ){ | ||
var node = ele; | ||
var nodeBb = node.boundingBox( { | ||
includeNodes: true, | ||
includeEdges: false, | ||
includeLabels: false | ||
} ); | ||
for( var e = 0; e < edges.length; e++ ){ | ||
var edge = edges[ e ]; | ||
var _p = edge._private; | ||
var rs = _p.rscratch; | ||
if( math.boundingBoxesIntersect( boxBb, nodeBb ) ){ | ||
box.push( node ); | ||
} | ||
} else { | ||
var edge = ele; | ||
var _p = edge._private; | ||
var rs = _p.rscratch; | ||
if( rs.startX != null && rs.startY != null && !math.inBoundingBox( boxBb, rs.startX, rs.startY ) ){ continue; } | ||
if( rs.endX != null && rs.endY != null && !math.inBoundingBox( boxBb, rs.endX, rs.endY ) ){ continue; } | ||
if( rs.startX != null && rs.startY != null && !math.inBoundingBox( boxBb, rs.startX, rs.startY ) ){ continue; } | ||
if( rs.endX != null && rs.endY != null && !math.inBoundingBox( boxBb, rs.endX, rs.endY ) ){ continue; } | ||
if( rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound' || rs.edgeType === 'segments' || rs.edgeType === 'haystack' ){ | ||
if( rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound' || rs.edgeType === 'segments' || rs.edgeType === 'haystack' ){ | ||
var pts = _p.rstyle.bezierPts || _p.rstyle.linePts || _p.rstyle.haystackPts; | ||
var allInside = true; | ||
var pts = _p.rstyle.bezierPts || _p.rstyle.linePts || _p.rstyle.haystackPts; | ||
var allInside = true; | ||
for( var i = 0; i < pts.length; i++ ){ | ||
if( !math.pointInBoundingBox( boxBb, pts[ i ] ) ){ | ||
allInside = false; | ||
break; | ||
for( var i = 0; i < pts.length; i++ ){ | ||
if( !math.pointInBoundingBox( boxBb, pts[ i ] ) ){ | ||
allInside = false; | ||
break; | ||
} | ||
} | ||
} | ||
if( allInside ){ | ||
if( allInside ){ | ||
box.push( edge ); | ||
} | ||
} else if( rs.edgeType === 'haystack' || rs.edgeType === 'straight' ){ | ||
box.push( edge ); | ||
} | ||
} else if( rs.edgeType === 'haystack' || rs.edgeType === 'straight' ){ | ||
box.push( edge ); | ||
} | ||
} | ||
@@ -657,24 +618,10 @@ | ||
var cyEles = this.cy.mutableElements(); | ||
var eles = []; | ||
var eles = this.cy.mutableElements().toArray(); | ||
eles.nodes = []; | ||
eles.edges = []; | ||
eles.sort( zIndexSort ); | ||
for( var i = 0; i < cyEles.length; i++ ){ | ||
var ele = cyEles[i]; | ||
eles.interactive = eles.filter(function( ele ){ | ||
return ele.interactive(); | ||
}); | ||
if( ele.animated() || (ele.visible() && !ele.transparent()) ){ | ||
eles.push( ele ); | ||
if( ele.isNode() ){ | ||
eles.nodes.push( ele ); | ||
} else { | ||
eles.edges.push( ele ); | ||
} | ||
} | ||
} | ||
eles.sort( zIndexSort ); | ||
this.cachedZSortedEles = eles; | ||
@@ -1181,2 +1128,12 @@ | ||
BRp.recalculateLabelProjections = function( nodes, edges ){ | ||
for( var i = 0; i < nodes.length; i++ ){ | ||
this.recalculateNodeLabelProjection( nodes[ i ] ); | ||
} | ||
for( var i = 0; i < edges.length; i++ ){ | ||
this.recalculateEdgeLabelProjections( edges[ i ] ); | ||
} | ||
}; | ||
BRp.recalculateEdgeProjections = function( edges ){ | ||
@@ -1183,0 +1140,0 @@ this.findEdgeControlPoints( edges ); |
@@ -84,5 +84,3 @@ 'use strict'; | ||
this.nodeIsDraggable( node ) | ||
&& node.pstyle( 'opacity' ).value !== 0 | ||
&& node.pstyle( 'visibility' ).value === 'visible' | ||
&& node.pstyle( 'display' ).value === 'element' | ||
&& node.interactive() | ||
); | ||
@@ -448,3 +446,3 @@ }; | ||
type: 'taphold', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ) ); | ||
@@ -454,3 +452,3 @@ } else { | ||
type: 'taphold', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ) ); | ||
@@ -470,3 +468,3 @@ } | ||
type: 'cxttapstart', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -500,7 +498,13 @@ | ||
var grabEvent = new Event( e, { | ||
type: 'grab', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
} ); | ||
var makeEvent = function( type ){ | ||
return new Event( e, { | ||
type: type, | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
}; | ||
var triggerGrab = function( ele ){ | ||
ele.trigger( makeEvent('grab') ); | ||
}; | ||
setGrabTarget( near ); | ||
@@ -513,12 +517,14 @@ | ||
near.trigger( grabEvent ); | ||
near.trigger( makeEvent('grabon') ).trigger( makeEvent('grab') ); | ||
} else if( near.selected() ){ | ||
} else { | ||
draggedElements = r.dragData.possibleDragElements = [ ]; | ||
var selectedNodes = cy.$( function(){ return this.isNode() && this.selected() && r.nodeIsGrabbable( this ); } ); | ||
var selectedNodes = cy.$( function( ele ){ return ele.isNode() && ele.selected() && r.nodeIsGrabbable( ele ); } ); | ||
addNodesToDrag( selectedNodes, { addToList: draggedElements } ); | ||
near.trigger( grabEvent ); | ||
near.trigger( makeEvent('grabon') ); | ||
selectedNodes.forEach( triggerGrab ); | ||
} | ||
@@ -539,3 +545,3 @@ | ||
triggerEvents( near, [ 'mousedown', 'tapstart', 'vmousedown' ], e, { | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -627,3 +633,3 @@ | ||
triggerEvents( near, [ 'mousemove', 'vmousemove', 'tapdrag' ], e, { | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -637,3 +643,3 @@ | ||
type: 'cxtdrag', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -654,3 +660,3 @@ | ||
type: 'cxtdragout', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ) ); | ||
@@ -664,3 +670,3 @@ } | ||
type: 'cxtdragover', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ) ); | ||
@@ -750,3 +756,3 @@ } | ||
triggerEvents( last, [ 'mouseout', 'tapdragout' ], e, { | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -757,3 +763,3 @@ } | ||
triggerEvents( near, [ 'mouseover', 'tapdragover' ], e, { | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -868,3 +874,3 @@ } | ||
type: 'cxttapend', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -881,3 +887,3 @@ | ||
type: 'cxttap', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -905,5 +911,3 @@ | ||
cy.$( function(){ | ||
return this.selected(); | ||
} ).unselect(); | ||
cy.$( function( ele ){ return ele.selected(); } ).unselect(); | ||
@@ -918,3 +922,3 @@ if( draggedElements.length > 0 ){ | ||
triggerEvents( near, [ 'mouseup', 'tapend', 'vmouseup' ], e, { | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -928,3 +932,3 @@ | ||
triggerEvents( down, ['click', 'tap', 'vclick'], e, { | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ); | ||
@@ -1107,3 +1111,3 @@ } | ||
type: 'mouseout', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ) ); | ||
@@ -1117,3 +1121,3 @@ }, false ); | ||
type: 'mouseover', | ||
cyPosition: { x: pos[0], y: pos[1] } | ||
position: { x: pos[0], y: pos[1] } | ||
} ) ); | ||
@@ -1198,3 +1202,3 @@ }, false ); | ||
type: 'cxttapstart', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ) ); | ||
@@ -1206,3 +1210,3 @@ r.touchData.start = near1; | ||
type: 'cxttapstart', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ) ); | ||
@@ -1214,3 +1218,3 @@ r.touchData.start = near2; | ||
type: 'cxttapstart', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ) ); | ||
@@ -1248,2 +1252,3 @@ } | ||
var draggedEles = r.dragData.touchDragEles = []; | ||
var selectedNodes = null; | ||
@@ -1256,4 +1261,4 @@ r.redrawHint( 'eles', true ); | ||
var selectedNodes = cy.$( function(){ | ||
return this.selected() && r.nodeIsGrabbable( this ); | ||
selectedNodes = cy.$( function( ele ){ | ||
return ele.selected() && r.nodeIsGrabbable( ele ); | ||
} ); | ||
@@ -1268,6 +1273,16 @@ | ||
near.trigger( new Event( e, { | ||
type: 'grab', | ||
cyPosition: { x: now[0], y: now[1] } | ||
} ) ); | ||
var makeEvent = function( type ){ | ||
return new Event( e, { | ||
type: type, | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
}; | ||
near.trigger( makeEvent('grabon') ); | ||
if( selectedNodes ){ | ||
selectedNodes.forEach(function( n ){ n.trigger( makeEvent('grab') ); }); | ||
} else { | ||
near.trigger( makeEvent('grab') ); | ||
} | ||
} | ||
@@ -1277,3 +1292,3 @@ } | ||
triggerEvents( near, [ 'touchstart', 'tapstart', 'vmousedown' ], e, { | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1306,3 +1321,3 @@ | ||
triggerEvents( r.touchData.start, [ 'taphold' ], e, { | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1387,3 +1402,3 @@ | ||
type: 'cxttapend', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1409,3 +1424,3 @@ | ||
type: 'cxtdrag', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1431,3 +1446,3 @@ r.data.bgActivePosistion = undefined; | ||
type: 'cxtdragout', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ) ); | ||
@@ -1441,3 +1456,3 @@ } | ||
type: 'cxtdragover', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ) ); | ||
@@ -1665,8 +1680,8 @@ | ||
triggerEvents( (start || near), [ 'touchmove', 'tapdrag', 'vmousemove' ], e, { | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
if( ( !start || !start.grabbed() ) && near != last ){ | ||
if( last ){ last.trigger( new Event( e, { type: 'tapdragout', cyPosition: { x: now[0], y: now[1] } } ) ); } | ||
if( near ){ near.trigger( new Event( e, { type: 'tapdragover', cyPosition: { x: now[0], y: now[1] } } ) ); } | ||
if( last ){ last.trigger( new Event( e, { type: 'tapdragout', position: { x: now[0], y: now[1] } } ) ); } | ||
if( near ){ near.trigger( new Event( e, { type: 'tapdragover', position: { x: now[0], y: now[1] } } ) ); } | ||
} | ||
@@ -1788,3 +1803,3 @@ | ||
type: 'cxttapend', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1801,3 +1816,3 @@ | ||
type: 'cxttap', | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1887,3 +1902,3 @@ | ||
triggerEvents( start, [ 'touchend', 'tapend', 'vmouseup', 'tapdragout' ], e, { | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1899,3 +1914,3 @@ | ||
triggerEvents( near, [ 'touchend', 'tapend', 'vmouseup', 'tapdragout' ], e, { | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1937,3 +1952,3 @@ | ||
triggerEvents( start, [ 'tap', 'vclick' ], e, { | ||
cyPosition: { x: now[0], y: now[1] } | ||
position: { x: now[0], y: now[1] } | ||
} ); | ||
@@ -1940,0 +1955,0 @@ } |
@@ -55,10 +55,2 @@ 'use strict'; | ||
var shadowBlur = edge.pstyle( 'shadow-blur' ).pfValue; | ||
var shadowOpacity = edge.pstyle( 'shadow-opacity' ).value; | ||
var shadowColor = edge.pstyle( 'shadow-color' ).value; | ||
var shadowOffsetX = edge.pstyle( 'shadow-offset-x' ).pfValue; | ||
var shadowOffsetY = edge.pstyle( 'shadow-offset-y' ).pfValue; | ||
this.shadowStyle( context, shadowColor, drawOverlayInstead ? 0 : shadowOpacity, shadowBlur, shadowOffsetX, shadowOffsetY ); | ||
this.drawEdgePath( | ||
@@ -74,4 +66,2 @@ edge, | ||
this.shadowStyle( context, 'transparent', 0 ); // reset for next guy | ||
if( !drawOverlayInstead ){ | ||
@@ -78,0 +68,0 @@ this.drawEdge( context, edge, false, drawLabel, true ); |
@@ -121,7 +121,2 @@ 'use strict'; | ||
var outlineColor = ele.pstyle( 'text-outline-color' ).value; | ||
var shadowBlur = ele.pstyle( 'text-shadow-blur' ).pfValue; | ||
var shadowOpacity = ele.pstyle( 'text-shadow-opacity' ).value; | ||
var shadowColor = ele.pstyle( 'text-shadow-color' ).value; | ||
var shadowOffsetX = ele.pstyle( 'text-shadow-offset-x' ).pfValue; | ||
var shadowOffsetY = ele.pstyle( 'text-shadow-offset-y' ).pfValue; | ||
@@ -145,4 +140,2 @@ var fontCacheKey = ele._private.fontKey; | ||
this.strokeStyle( context, outlineColor[ 0 ], outlineColor[ 1 ], outlineColor[ 2 ], outlineOpacity ); | ||
this.shadowStyle( context, shadowColor, shadowOpacity, shadowBlur, shadowOffsetX, shadowOffsetY ); | ||
}; | ||
@@ -356,4 +349,2 @@ | ||
} | ||
this.shadowStyle( context, 'transparent', 0 ); // reset for next guy | ||
} | ||
@@ -360,0 +351,0 @@ }; |
@@ -85,10 +85,2 @@ 'use strict'; | ||
var shadowBlur = node.pstyle( 'shadow-blur' ).pfValue; | ||
var shadowOpacity = node.pstyle( 'shadow-opacity' ).value; | ||
var shadowColor = node.pstyle( 'shadow-color' ).value; | ||
var shadowOffsetX = node.pstyle( 'shadow-offset-x' ).pfValue; | ||
var shadowOffsetY = node.pstyle( 'shadow-offset-y' ).pfValue; | ||
this.shadowStyle( context, shadowColor, shadowOpacity, shadowBlur, shadowOffsetX, shadowOffsetY ); | ||
context.lineJoin = 'miter'; // so borders are square with the node shape | ||
@@ -160,4 +152,2 @@ | ||
this.shadowStyle( context, 'transparent', 0 ); // reset for next guy | ||
// | ||
@@ -164,0 +154,0 @@ // bg image |
@@ -80,27 +80,2 @@ 'use strict'; | ||
CRp.shadowStyle = function( context, color, opacity, blur, offsetX, offsetY ){ | ||
var zoom = this.cy.zoom(); | ||
// var cache = this.paintCache( context ); | ||
// | ||
// // don't make expensive changes to the shadow style if it's not used | ||
// if( cache.shadowOpacity === 0 && opacity === 0 ){ | ||
// return; | ||
// } | ||
// | ||
// cache.shadowOpacity = opacity; | ||
if( opacity > 0 ){ | ||
context.shadowBlur = blur * zoom; | ||
context.shadowColor = 'rgba(' + color[0] + ',' + color[1] + ',' + color[2] + ',' + opacity + ')'; | ||
context.shadowOffsetX = offsetX * zoom; | ||
context.shadowOffsetY = offsetY * zoom; | ||
} else { | ||
context.shadowBlur = 0; | ||
context.shadowColor = 'transparent'; | ||
context.shadowOffsetX = 0; | ||
context.shadowOffsetY = 0; | ||
} | ||
}; | ||
// Resize canvas | ||
@@ -597,8 +572,2 @@ CRp.matchCanvasSize = function( container ){ | ||
if( !forcedContext && !r.initrender ){ | ||
r.initrender = true; | ||
cy.trigger( 'initrender' ); | ||
} | ||
if( !forcedContext ){ | ||
@@ -605,0 +574,0 @@ cy.trigger('render'); |
@@ -9,6 +9,3 @@ 'use strict'; | ||
var extension = require( './extension' ); | ||
var registerJquery = require( './jquery-plugin' ); | ||
var Stylesheet = require( './stylesheet' ); | ||
var Thread = require( './thread' ); | ||
var Fabric = require( './fabric' ); | ||
@@ -32,20 +29,17 @@ var cytoscape = function( options ){ // jshint ignore:line | ||
// replaced by build system | ||
cytoscape.version = require('./version'); | ||
// e.g. cytoscape.use( require('cytoscape-foo'), bar ) | ||
cytoscape.use = function( ext ){ | ||
var args = Array.prototype.slice.call( arguments, 1 ); // args to pass to ext | ||
// try to register w/ jquery | ||
if( window && window.jQuery ){ | ||
registerJquery( window.jQuery, cytoscape ); | ||
} | ||
args.unshift( cytoscape ); // cytoscape is first arg to ext | ||
// expose register api | ||
cytoscape.registerJquery = function( jQuery ){ | ||
registerJquery( jQuery, cytoscape ); | ||
ext.apply( null, args ); | ||
}; | ||
// replaced by build system | ||
cytoscape.version = require('./version'); | ||
// expose public apis (mostly for extensions) | ||
cytoscape.stylesheet = cytoscape.Stylesheet = Stylesheet; | ||
cytoscape.thread = cytoscape.Thread = Thread; | ||
cytoscape.fabric = cytoscape.Fabric = Fabric; | ||
module.exports = cytoscape; |
@@ -143,3 +143,3 @@ 'use strict'; | ||
// e.g. :foobar|:foo | ||
regex: '(:selected|:unselected|:locked|:unlocked|:visible|:hidden|:transparent|:grabbed|:free|:removed|:inside|:grabbable|:ungrabbable|:animated|:unanimated|:selectable|:unselectable|:orphan|:nonorphan|:parent|:child|:loop|:simple|:active|:inactive|:touch|:backgrounding|:nonbackgrounding)', | ||
regex: '(:selected|:unselected|:locked|:unlocked|:visible|:hidden|:transparent|:grabbed|:free|:removed|:inside|:grabbable|:ungrabbable|:animated|:unanimated|:selectable|:unselectable|:orphan|:nonorphan|:parent|:child|:loop|:simple|:active|:inactive|:backgrounding|:nonbackgrounding)', | ||
populate: function( state ){ | ||
@@ -508,5 +508,2 @@ this.colonSelectors.push( state ); | ||
break; | ||
case ':touch': | ||
allColonSelectorsMatch = is.touch(); | ||
break; | ||
case ':backgrounding': | ||
@@ -761,3 +758,3 @@ allColonSelectorsMatch = ele.backgrounding(); | ||
var selectorFunction = function( i, element ){ | ||
var selectorFunction = function( element, i ){ | ||
for( var j = 0; j < self.length; j++ ){ | ||
@@ -764,0 +761,0 @@ var query = self[ j ]; |
@@ -332,18 +332,6 @@ 'use strict'; | ||
case types.mapData: | ||
case types.mapLayoutData: | ||
case types.mapScratch: | ||
var isLayout = prop.mapped === types.mapLayoutData; | ||
var isScratch = prop.mapped === types.mapScratch; | ||
// flatten the field (e.g. data.foo.bar) | ||
var fields = prop.field.split( '.' ); | ||
var fieldVal; | ||
var fieldVal = _p.data; | ||
if( isScratch || isLayout ){ | ||
fieldVal = _p.scratch; | ||
} else { | ||
fieldVal = _p.data; | ||
} | ||
for( var i = 0; i < fields.length && fieldVal; i++ ){ | ||
@@ -412,17 +400,6 @@ var field = fields[ i ]; | ||
case types.data: | ||
case types.layoutData: | ||
case types.scratch: | ||
var isLayout = prop.mapped === types.layoutData; | ||
var isScratch = prop.mapped === types.scratch; | ||
// flatten the field (e.g. data.foo.bar) | ||
var fields = prop.field.split( '.' ); | ||
var fieldVal; | ||
var fieldVal = _p.data; | ||
if( isScratch || isLayout ){ | ||
fieldVal = _p.scratch; | ||
} else { | ||
fieldVal = _p.data; | ||
} | ||
if( fieldVal ){ for( var i = 0; i < fields.length; i++ ){ | ||
@@ -429,0 +406,0 @@ var field = fields[ i ]; |
@@ -90,24 +90,11 @@ 'use strict'; | ||
// check if value is mapped | ||
var data, mapData, layoutData, mapLayoutData, scratch, mapScratch; | ||
var data, mapData; | ||
if( !valueIsString || propIsFlat ){ | ||
// then don't bother to do the expensive regex checks | ||
} else if( | ||
( data = new RegExp( types.data.regex ).exec( value ) ) || | ||
( layoutData = new RegExp( types.layoutData.regex ).exec( value ) ) || | ||
( scratch = new RegExp( types.scratch.regex ).exec( value ) ) | ||
){ | ||
} else if( (data = new RegExp( types.data.regex ).exec( value )) ){ | ||
if( propIsBypass ){ return false; } // mappers not allowed in bypass | ||
var mapped; | ||
if( data ){ | ||
mapped = types.data; | ||
} else if( layoutData ){ | ||
mapped = types.layoutData; | ||
} else { | ||
mapped = types.scratch; | ||
} | ||
var mapped = types.data; | ||
data = data || layoutData || scratch; | ||
return { | ||
@@ -122,21 +109,8 @@ name: name, | ||
} else if( | ||
( mapData = new RegExp( types.mapData.regex ).exec( value ) ) || | ||
( mapLayoutData = new RegExp( types.mapLayoutData.regex ).exec( value ) ) || | ||
( mapScratch = new RegExp( types.mapScratch.regex ).exec( value ) ) | ||
){ | ||
} else if( (mapData = new RegExp( types.mapData.regex ).exec( value )) ){ | ||
if( propIsBypass ){ return false; } // mappers not allowed in bypass | ||
if( type.multiple ){ return false; } // impossible to map to num | ||
var mapped; | ||
if( mapData ){ | ||
mapped = types.mapData; | ||
} else if( mapLayoutData ){ | ||
mapped = types.mapLayoutData; | ||
} else { | ||
mapped = types.mapScratch; | ||
} | ||
var mapped = types.mapData; | ||
mapData = mapData || mapLayoutData || mapScratch; | ||
// we can map only if the type is a colour or a number | ||
@@ -143,0 +117,0 @@ if( !(type.color || type.number) ){ return false; } |
@@ -159,16 +159,2 @@ 'use strict'; | ||
// shadows | ||
{ name: 'shadow-blur', type: t.size }, | ||
{ name: 'shadow-color', type: t.color }, | ||
{ name: 'shadow-opacity', type: t.zeroOneNumber }, | ||
{ name: 'shadow-offset-x', type: t.bidirectionalSize }, | ||
{ name: 'shadow-offset-y', type: t.bidirectionalSize }, | ||
// label shadows | ||
{ name: 'text-shadow-blur', type: t.size }, | ||
{ name: 'text-shadow-color', type: t.color }, | ||
{ name: 'text-shadow-opacity', type: t.zeroOneNumber }, | ||
{ name: 'text-shadow-offset-x', type: t.bidirectionalSize }, | ||
{ name: 'text-shadow-offset-y', type: t.bidirectionalSize }, | ||
// transition anis | ||
@@ -353,12 +339,2 @@ { name: 'transition-property', type: t.propList }, | ||
'overlay-padding': 10, | ||
'shadow-opacity': 0, | ||
'shadow-color': '#000', | ||
'shadow-blur': 10, | ||
'shadow-offset-x': 0, | ||
'shadow-offset-y': 0, | ||
'text-shadow-opacity': 0, | ||
'text-shadow-color': '#000', | ||
'text-shadow-blur': 5, | ||
'text-shadow-offset-x': 0, | ||
'text-shadow-offset-y': 0, | ||
'transition-property': 'none', | ||
@@ -365,0 +341,0 @@ 'transition-duration': 0, |
@@ -1,1 +0,1 @@ | ||
module.exports = "2.7.17"; | ||
module.exports = "3.0.0"; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
46376
2
0
2826291
114