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.10.0 to 1.10.1

46

cytoscape-automove.js

@@ -259,24 +259,38 @@ (function webpackUniversalModuleDefinition(root, factory) {

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);
var x = pos.x,
y = pos.y;
var x1 = bb.x1,
y1 = bb.y1,
x2 = bb.x2,
y2 = bb.y2;
if (x != pos.x && y != pos.y) {
if (Math.abs(pos.x - x) < Math.abs(pos.y - y)) {
pos.x = x;
var inX = x1 <= x && x <= x2;
var inY = y1 <= y && y <= y2;
var abs = Math.abs;
if (inX && inY) {
// inside
var dx1 = abs(x1 - x);
var dx2 = abs(x2 - x);
var dy1 = abs(y1 - y);
var dy2 = abs(y2 - y);
var min = Math.min(dx1, dx2, dy1, dy2); // which side of box is closest?
// get position outside, by closest side of box
if (min === dx1) {
return { x: x1, y: y };
} else if (min === dx2) {
return { x: x2, y: y };
} else if (min === dy1) {
return { x: x, y: y1 };
} else {
pos.y = y;
// min === dy2
return { x: x, y: y2 };
}
} else {
// outside already
return { x: x, y: y };
}
return pos;
};

@@ -283,0 +297,0 @@

{
"name": "cytoscape-automove",
"version": "1.10.0",
"version": "1.10.1",
"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 . -v node_modules/**",
"gh-pages:deploy": "gh-pages -d . -v node_modules",
"gh-pages:clean": "rimraf index.html",

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

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

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

@@ -158,24 +158,30 @@ }

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 );
let { x, y } = pos;
let { x1, y1, x2, y2 } = bb;
let inX = x1 <= x && x <= x2;
let inY = y1 <= y && y <= y2;
let abs = Math.abs;
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;
if( inX && inY ){ // inside
let dx1 = abs(x1 - x);
let dx2 = abs(x2 - x);
let dy1 = abs(y1 - y);
let dy2 = abs(y2 - y);
let min = Math.min(dx1, dx2, dy1, dy2); // which side of box is closest?
// get position outside, by closest side of box
if( min === dx1 ){
return { x: x1, y };
} else if( min === dx2 ){
return { x: x2, y };
} else if( min === dy1 ){
return { x, y: y1 };
} else { // min === dy2
return { x, y: y2 };
}
} else { // outside already
return { x, y };
}
return pos;
};

@@ -182,0 +188,0 @@

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