cytoscape
Advanced tools
Comparing version 3.3.1 to 3.3.2
{ | ||
"build/cytoscape.umd.js": { | ||
"bundled": 883683, | ||
"minified": 327265, | ||
"gzipped": 101716 | ||
"bundled": 887661, | ||
"minified": 328855, | ||
"gzipped": 102237 | ||
}, | ||
"build/cytoscape.cjs.js": { | ||
"bundled": 813786, | ||
"minified": 344176, | ||
"gzipped": 103735 | ||
"bundled": 817540, | ||
"minified": 345792, | ||
"gzipped": 104228 | ||
}, | ||
"build/cytoscape.esm.js": { | ||
"bundled": 813613, | ||
"minified": 344039, | ||
"gzipped": 103693, | ||
"bundled": 817367, | ||
"minified": 345655, | ||
"gzipped": 104197, | ||
"treeshaked": { | ||
"rollup": { | ||
"code": 322019, | ||
"code": 323609, | ||
"import_statements": 51 | ||
}, | ||
"webpack": { | ||
"code": 324149 | ||
"code": 325752 | ||
} | ||
@@ -24,0 +24,0 @@ } |
{ | ||
"name": "cytoscape", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Graph theory (a.k.a. network) library for analysis and visualisation", |
@@ -12,3 +12,3 @@ <div style="text-align: center;" align="center"><img style="width: 200px; height: 200px;" src="https://raw.githubusercontent.com/cytoscape/cytoscape.js/unstable/documentation/img/cytoscape-logo.png" width="200" height="200"></img></div> | ||
[![Download](https://img.shields.io/npm/v/cytoscape.svg?label=Download)](https://github.com/cytoscape/cytoscape.js/tree/master/dist) | ||
[![Extensions](https://img.shields.io/badge/Extensions-35-blue.svg)](http://js.cytoscape.org/#extensions) | ||
[![Extensions](https://img.shields.io/badge/Extensions-39-blue.svg)](http://js.cytoscape.org/#extensions) | ||
[![npm installs](https://img.shields.io/npm/dm/cytoscape.svg?label=npm%20installs)](https://www.npmjs.com/package/cytoscape) | ||
@@ -139,2 +139,2 @@ [![master branch tests](https://img.shields.io/travis/cytoscape/cytoscape.js/master.svg?label=master%20branch)](https://travis-ci.org/cytoscape/cytoscape.js) | ||
Mocha tests are found in the [test directory](https://github.com/cytoscape/cytoscape.js/tree/master/test). The tests can be run in the browser or they can be run via Node.js (`gulp test` or `mocha`). | ||
Mocha tests are found in the [test directory](https://github.com/cytoscape/cytoscape.js/tree/master/test). The tests can be run in the browser or they can be run via Node.js (`npm test` or `mocha`). |
@@ -365,12 +365,36 @@ import * as is from '../../is'; | ||
let sin = Math.sin( theta ); | ||
let xMid = (lx1 + lx2)/2; | ||
let yMid = (ly1 + ly2)/2; | ||
// rotation point (default value for center-center) | ||
let xo = (lx1 + lx2)/2; | ||
let yo = (ly1 + ly2)/2; | ||
if( !isEdge ){ | ||
switch( halign.value ){ | ||
case 'left': | ||
xo = lx2; | ||
break; | ||
case 'right': | ||
xo = lx1; | ||
break; | ||
} | ||
switch( valign.value ){ | ||
case 'top': | ||
yo = ly2; | ||
break; | ||
case 'bottom': | ||
yo = ly1; | ||
break; | ||
} | ||
} | ||
let rotate = function( x, y ){ | ||
x = x - xMid; | ||
y = y - yMid; | ||
x = x - xo; | ||
y = y - yo; | ||
return { | ||
x: x * cos - y * sin + xMid, | ||
y: x * sin + y * cos + yMid | ||
x: x * cos - y * sin + xo, | ||
y: x * sin + y * cos + yo | ||
}; | ||
@@ -377,0 +401,0 @@ }; |
@@ -120,3 +120,4 @@ import window from '../window'; | ||
// create the renderer | ||
cy.initRenderer( options.renderer ); | ||
let rendererOptions = util.assign({}, options, options.renderer); // allow rendering hints in top level options | ||
cy.initRenderer( rendererOptions ); | ||
@@ -317,2 +318,3 @@ let setElesAndLayout = function( elements, onload, ondone ){ | ||
let eles = cy.mutableElements(); | ||
let getFreshRef = ele => cy.getElementById(ele.id()); | ||
@@ -374,14 +376,20 @@ if( is.plainObject( obj ) ){ // set | ||
// elements not specified in json should be removed | ||
eles.stdFilter( function( ele ){ | ||
return !idInJson[ ele.id() ]; | ||
} ).forEach( function ( ele ){ | ||
if( ele.isParent() ){ | ||
ele.children().move({ parent: null }); // so that children are not removed w/ parent | ||
let parentsToRemove = cy.collection(); | ||
ele.remove(); // remove parent | ||
} else { | ||
ele.remove(); | ||
} | ||
} ); | ||
(eles | ||
.filter(ele => !idInJson[ ele.id() ]) | ||
.forEach(ele => { | ||
if ( ele.isParent() ) { | ||
parentsToRemove.merge(ele); | ||
} else { | ||
ele.remove(); | ||
} | ||
}) | ||
); | ||
// so that children are not removed w/parent | ||
parentsToRemove.forEach(ele => ele.children().move({ parent: null })); | ||
// intermediate parents may be moved by prior line, so make sure we remove by fresh refs | ||
parentsToRemove.forEach(ele => getFreshRef(ele).remove()); | ||
} | ||
@@ -388,0 +396,0 @@ |
@@ -1,4 +0,12 @@ | ||
import * as is from '../is'; | ||
import * as util from '../util'; | ||
let rendererDefaults = util.defaults({ | ||
motionBlur: false, | ||
motionBlurOpacity: 0.05, | ||
pixelRatio: undefined, | ||
desktopTapThreshold: 4, | ||
touchTapThreshold: 8, | ||
wheelSensitivity: 1 | ||
}); | ||
let corefn = ({ | ||
@@ -40,17 +48,10 @@ | ||
let defaults = { | ||
motionBlur: false, | ||
motionBlurOpacity: 0.05, | ||
pixelRatio: undefined, | ||
desktopTapThreshold: 4, | ||
touchTapThreshold: 8, | ||
wheelSensitivity: 1 | ||
}; | ||
if( options.wheelSensitivity !== undefined ){ | ||
util.warn(`You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.`); | ||
} | ||
let rOpts = util.extend( {}, defaults, options, { | ||
cy: cy, | ||
wheelSensitivity: is.number( options.wheelSensitivity ) && options.wheelSensitivity > 0 ? options.wheelSensitivity : defaults.wheelSensitivity, | ||
pixelRatio: is.number( options.pixelRatio ) && options.pixelRatio > 0 ? options.pixelRatio : defaults.pixelRatio | ||
} ); | ||
let rOpts = rendererDefaults(options); | ||
rOpts.cy = cy; | ||
cy._private.renderer = new RendererProto( rOpts ); | ||
@@ -57,0 +58,0 @@ |
@@ -309,3 +309,3 @@ import * as is from '../is'; | ||
_p.minZoom = min; | ||
} else if( is.number( max ) && min === undefined && max <= _p.minZoom ){ | ||
} else if( is.number( max ) && min === undefined && max >= _p.minZoom ){ | ||
_p.maxZoom = max; | ||
@@ -312,0 +312,0 @@ } |
@@ -822,2 +822,4 @@ import * as math from '../../../../math'; | ||
if( type === 'segments' ){ | ||
this.recalculateRenderedStyle( edge ); | ||
return getPts( rs.segpts ); | ||
@@ -832,2 +834,4 @@ } | ||
if( type === 'bezier' || type === 'multibezier' || type === 'self' || type === 'compound' ){ | ||
this.recalculateRenderedStyle( edge ); | ||
return getPts( rs.ctrlpts ); | ||
@@ -840,2 +844,4 @@ } | ||
this.recalculateRenderedStyle( edge ); | ||
return { | ||
@@ -842,0 +848,0 @@ x: rs.midX, |
@@ -278,2 +278,4 @@ import * as math from '../../../../math'; | ||
this.recalculateRenderedStyle( edge ); | ||
switch( rs.edgeType ){ | ||
@@ -296,2 +298,4 @@ case 'haystack': | ||
this.recalculateRenderedStyle( edge ); | ||
switch( rs.edgeType ){ | ||
@@ -298,0 +302,0 @@ case 'haystack': |
@@ -43,7 +43,6 @@ import * as math from '../../../math'; | ||
if( theta !== 0 ){ | ||
let halfW = w/2; | ||
let halfH = h/2; | ||
let rotPt = eleTxrCache.getRotationPoint(ele); | ||
sx = x1 + halfW; | ||
sy = y1 + halfH; | ||
sx = rotPt.x; | ||
sy = rotPt.y; | ||
@@ -57,4 +56,6 @@ context.translate(sx, sy); | ||
x = -halfW; | ||
y = -halfH; | ||
let off = eleTxrCache.getRotationOffset(ele); | ||
x = off.x; | ||
y = off.y; | ||
} else { | ||
@@ -72,3 +73,3 @@ x = x1; | ||
context.drawImage( eleCache.texture.canvas, eleCache.x, 0, eleCache.width, eleCache.height, x, y, bb.w, bb.h ); | ||
context.drawImage( eleCache.texture.canvas, eleCache.x, 0, eleCache.width, eleCache.height, x, y, w, h ); | ||
@@ -102,3 +103,3 @@ if( opacity !== 1 ){ | ||
if( bb.w === 0 || bb.h === 0 ){ return; } | ||
if( bb.w === 0 || bb.h === 0 || !ele.visible() ){ return; } | ||
@@ -105,0 +106,0 @@ if( !extent || math.boundingBoxesIntersect( bb, extent ) ){ |
@@ -37,2 +37,4 @@ import * as math from '../../../math'; | ||
getBoundingBox: null, | ||
getRotationPoint: null, | ||
getRotationOffset: null, | ||
isVisible: trueify, | ||
@@ -39,0 +41,0 @@ allowEdgeTxrCaching: true, |
@@ -100,5 +100,6 @@ /* | ||
let getStyleKey = ele => ele[0]._private.nodeKey; | ||
let drawElement = (context, ele, bb, scaledLabelShown, useEleOpacity) => r.drawElement( context, ele, bb, false, false, useEleOpacity ); | ||
let getElementBox = ele => { ele.boundingBox(); return ele[0]._private.bodyBounds; }; | ||
let getBoxCenter = bb => ({ x: (bb.x1 + bb.x2)/2, y: (bb.y1 + bb.y2)/2 }); | ||
let getCenterOffset = bb => ({ x: -bb.w/2, y: -bb.h/2 }); | ||
let backgroundTimestampHasChanged = ele => { | ||
@@ -111,13 +112,69 @@ let _p = ele[0]._private; | ||
let getStyleKey = ele => ele[0]._private.nodeKey; | ||
let getLabelKey = ele => ele[0]._private.labelStyleKey; | ||
let getSourceLabelKey = ele => ele[0]._private.sourceLabelStyleKey; | ||
let getTargetLabelKey = ele => ele[0]._private.targetLabelStyleKey; | ||
let drawElement = (context, ele, bb, scaledLabelShown, useEleOpacity) => r.drawElement( context, ele, bb, false, false, useEleOpacity ); | ||
let drawLabel = (context, ele, bb, scaledLabelShown, useEleOpacity) => r.drawElementText( context, ele, bb, scaledLabelShown, 'main', useEleOpacity ); | ||
let drawSourceLabel = (context, ele, bb, scaledLabelShown, useEleOpacity) => r.drawElementText( context, ele, bb, scaledLabelShown, 'source', useEleOpacity ); | ||
let drawTargetLabel = (context, ele, bb, scaledLabelShown, useEleOpacity) => r.drawElementText( context, ele, bb, scaledLabelShown, 'target', useEleOpacity ); | ||
let getElementBox = ele => { ele.boundingBox(); return ele[0]._private.bodyBounds; }; | ||
let getLabelBox = ele => { ele.boundingBox(); return ele[0]._private.labelBounds.main || emptyBb; }; | ||
let getSourceLabelBox = ele => { ele.boundingBox(); return ele[0]._private.labelBounds.source || emptyBb; }; | ||
let getTargetLabelBox = ele => { ele.boundingBox(); return ele[0]._private.labelBounds.target || emptyBb; }; | ||
let isLabelVisibleAtScale = (ele, scaledLabelShown) => scaledLabelShown; | ||
let getElementRotationPoint = ele => getBoxCenter( getElementBox(ele) ); | ||
let addTextMargin = (pt, ele) => { | ||
return { | ||
x: pt.x + ele.pstyle('text-margin-x').pfValue, | ||
y: pt.y + ele.pstyle('text-margin-y').pfValue | ||
}; | ||
}; | ||
let getRsPt = (ele, x, y) => { | ||
let rs = ele[0]._private.rscratch; | ||
return { x: rs[x], y: rs[y] }; | ||
}; | ||
let getLabelRotationPoint = ele => addTextMargin(getRsPt(ele, 'labelX', 'labelY'), ele); | ||
let getSourceLabelRotationPoint = ele => addTextMargin(getRsPt(ele, 'sourceLabelX', 'sourceLabelY'), ele); | ||
let getTargetLabelRotationPoint = ele => addTextMargin(getRsPt(ele, 'sourceLabelX', 'sourceLabelY'), ele); | ||
let getElementRotationOffset = ele => getCenterOffset( getElementBox(ele) ); | ||
let getSourceLabelRotationOffset = ele => getCenterOffset( getSourceLabelBox(ele) ); | ||
let getTargetLabelRotationOffset = ele => getCenterOffset( getTargetLabelBox(ele) ); | ||
let getLabelRotationOffset = ele => { | ||
let bb = getLabelBox(ele); | ||
let p = getCenterOffset( getLabelBox(ele) ); | ||
if( ele.isNode() ){ | ||
switch( ele.pstyle('text-halign').value ){ | ||
case 'left': | ||
p.x = -bb.w; | ||
break; | ||
case 'right': | ||
p.x = 0; | ||
break; | ||
} | ||
switch( ele.pstyle('text-valign').value ){ | ||
case 'top': | ||
p.y = -bb.h; | ||
break; | ||
case 'bottom': | ||
p.y = 0; | ||
break; | ||
} | ||
} | ||
return p; | ||
}; | ||
let eleTxrCache = r.data.eleTxrCache = new ElementTextureCache( r, { | ||
@@ -128,2 +185,4 @@ getKey: getStyleKey, | ||
getBoundingBox: getElementBox, | ||
getRotationPoint: getElementRotationPoint, | ||
getRotationOffset: getElementRotationOffset, | ||
allowEdgeTxrCaching: false, | ||
@@ -137,2 +196,4 @@ allowParentTxrCaching: false | ||
getBoundingBox: getLabelBox, | ||
getRotationPoint: getLabelRotationPoint, | ||
getRotationOffset: getLabelRotationOffset, | ||
isVisible: isLabelVisibleAtScale | ||
@@ -145,2 +206,4 @@ } ); | ||
getBoundingBox: getSourceLabelBox, | ||
getRotationPoint: getSourceLabelRotationPoint, | ||
getRotationOffset: getSourceLabelRotationOffset, | ||
isVisible: isLabelVisibleAtScale | ||
@@ -153,2 +216,4 @@ } ); | ||
getBoundingBox: getTargetLabelBox, | ||
getRotationPoint: getTargetLabelRotationPoint, | ||
getRotationOffset: getTargetLabelRotationOffset, | ||
isVisible: isLabelVisibleAtScale | ||
@@ -155,0 +220,0 @@ } ); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3701766
100698