Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cytoscape-automove

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cytoscape-automove - npm Package Compare versions

Comparing version 1.9.0 to 1.10.0

38

cytoscape-automove.js

@@ -185,3 +185,7 @@ (function webpackUniversalModuleDefinition(root, factory) {

} else if (isObject(r)) {
return boxPosition(r);
if (r.type == undefined || r.type == "inside") {
return boxPosition(r);
} else if (r.type == "outside") {
return outsideBoxPosition(r);
}
} else {

@@ -256,2 +260,32 @@ return r;

var constrainOut = function constrainOut(val, min, max) {
var mid = (min + max) / 2;
if (val > min && val < max) {
return val > mid ? max : min;
}
return val;
};
var constrainOutsideBox = function constrainOutsideBox(node, bb) {
var pos = node.position();
var x = constrainOut(pos.x, bb.x1, bb.x2);
var y = constrainOut(pos.y, bb.y1, bb.y2);
if (x != pos.x && y != pos.y) {
if (Math.abs(pos.x - x) < Math.abs(pos.y - y)) {
pos.x = x;
} else {
pos.y = y;
}
}
return pos;
};
var outsideBoxPosition = function outsideBoxPosition(bb) {
return function (node) {
return constrainOutsideBox(node, bb);
};
};
var viewportPosition = function viewportPosition(cy) {

@@ -583,2 +617,4 @@ return function (node) {

// - { x1, y1, x2, y2 } => constrain the node position within the bounding box (in model co-ordinates)
// - { x1, y1, x2, y2, type: 'inside' } => constrain the node position within the bounding box (in model co-ordinates)
// - { x1, y1, x2, y2, type: 'outside' } => constrain the node position outside the bounding box (in model co-ordinates)
// - 'mean' => put the node in the average position of its neighbourhood

@@ -585,0 +621,0 @@ // - 'viewport' => keeps the node body within the viewport

4

package.json
{
"name": "cytoscape-automove",
"version": "1.9.0",
"version": "1.10.0",
"description": "An extension for Cytoscape.js that automatically updates node positions based on specified rules",

@@ -13,3 +13,3 @@ "main": "cytoscape-automove.js",

"gh-pages:demo": "cpy demo.html . --rename=index.html",
"gh-pages:deploy": "gh-pages -d .",
"gh-pages:deploy": "gh-pages -d . -v node_modules/**",
"gh-pages:clean": "rimraf index.html",

@@ -16,0 +16,0 @@ "copyright": "update license",

@@ -74,2 +74,4 @@ cytoscape-automove

// - { x1, y1, x2, y2 } => constrain the node position within the bounding box (in model co-ordinates)
// - { x1, y1, x2, y2, type: 'inside' } => constrain the node position within the bounding box (in model co-ordinates)
// - { x1, y1, x2, y2, type: 'outside' } => constrain the node position outside the bounding box (in model co-ordinates)
// - 'mean' => put the node in the average position of its neighbourhood

@@ -76,0 +78,0 @@ // - 'viewport' => keeps the node body within the viewport

@@ -82,3 +82,8 @@ let defaults = require('./defaults');

} else if( isObject( r ) ){
return boxPosition( r );
if( r.type == undefined || r.type == "inside" ){
return boxPosition( r );
}
else if( r.type == "outside" ){
return outsideBoxPosition( r );
}
} else {

@@ -153,2 +158,32 @@ return r;

let constrainOut = function( val, min, max ){
let mid = ( min + max ) / 2;
if( val > min && val < max ){
return val > mid ? max : min;
}
return val;
};
let constrainOutsideBox = function( node, bb ){
let pos = node.position();
let x = constrainOut( pos.x, bb.x1, bb.x2 );
let y = constrainOut( pos.y, bb.y1, bb.y2 );
if(x != pos.x && y != pos.y){
if(Math.abs(pos.x - x) < Math.abs(pos.y - y)){
pos.x = x;
} else {
pos.y = y;
}
}
return pos;
};
let outsideBoxPosition = function( bb ){
return function( node ){
return constrainOutsideBox( node, bb );
};
};
let viewportPosition = function( cy ){

@@ -155,0 +190,0 @@ return function( node ){

@@ -13,2 +13,4 @@

// - { x1, y1, x2, y2 } => constrain the node position within the bounding box (in model co-ordinates)
// - { x1, y1, x2, y2, type: 'inside' } => constrain the node position within the bounding box (in model co-ordinates)
// - { x1, y1, x2, y2, type: 'outside' } => constrain the node position outside the bounding box (in model co-ordinates)
// - 'mean' => put the node in the average position of its neighbourhood

@@ -15,0 +17,0 @@ // - 'viewport' => keeps the node body within the viewport

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc