🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

cytoscape-grid-guide

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cytoscape-grid-guide - npm Package Compare versions

Comparing version

to
2.2.0

{
"name": "cytoscape-grid-guide",
"version": "2.1.2",
"version": "2.2.0",
"description": "A sophisticated and highly customizable Cytoscape.js extension for grid and guideline interactions.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -127,5 +127,6 @@ cytoscape-grid-guide

var cytoscape = require('cytoscape');
var grid-guide = require('cytoscape-grid-guide');
var jquery = require('jquery');
var gridGuide = require('cytoscape-grid-guide');
grid-guide( cytoscape, jquery ); // register extension
gridGuide( cytoscape, jquery ); // register extension
```

@@ -135,4 +136,4 @@

```js
require(['cytoscape', 'cytoscape-grid-guide'], function( cytoscape, grid-guide ){
grid-guide( cytoscape ); // register extension
require(['cytoscape', 'jquery', 'cytoscape-grid-guide'], function( cytoscape, jquery, gridGuide ){
gridGuide( cytoscape, jquery ); // register extension
});

@@ -139,0 +140,0 @@ ```

module.exports = function (cytoscape, cy, $, apiRegistered) {
// Needed because parent nodes cannot be moved!
// Needed because parent nodes cannot be moved in Cytoscape.js < v3.2
function moveTopDown(node, dx, dy) {
var nodes = node.union(node.descendants());
nodes.positions(function (node, i) {
nodes.filter(":childless").positions(function (node, i) {
if(typeof node === "number") {

@@ -9,0 +9,0 @@ node = i;

@@ -40,6 +40,4 @@ module.exports = function (opts, cy, $, debounce) {

var DOMURL = window.URL || window.webkitURL || window;
var img = new Image();
var svg = new Blob([data], {type: 'image/svg+xml'});
var url = DOMURL.createObjectURL(svg);
data = encodeURIComponent(data);

@@ -49,6 +47,5 @@ img.onload = function () {

ctx.drawImage(img, 0, 0);
DOMURL.revokeObjectURL(url);
};
img.src = url;
img.src = "data:image/svg+xml," + data;
};

@@ -55,0 +52,0 @@

@@ -938,3 +938,3 @@ module.exports = function (opts, cy, $, debounce) {

nodesToMove.forEach(function(node, i) {
nodesToMove.filter(":childless").forEach(function(node, i) {
if(typeof node === "number") {

@@ -941,0 +941,0 @@ node = i;

;(function(){ 'use strict';
// registers the extension on a cytoscape lib ref
var register = function( cytoscape ){
var register = function(cytoscape, $){
if( !cytoscape ){ return; } // can't register if cytoscape unspecified
if(!cytoscape || !$){ return; } // can't register if cytoscape unspecified

@@ -129,6 +129,6 @@ // flag that indicates if extension api functions are registed to cytoscape

if( typeof cytoscape !== 'undefined' ){ // expose to global cytoscape (i.e. window.cytoscape)
register( cytoscape );
if( typeof cytoscape !== 'undefined' && $ ){ // expose to global cytoscape (i.e. window.cytoscape)
register( cytoscape, $ );
}
})();

@@ -11,3 +11,2 @@ module.exports = function (cy, snap) {

snapToGridDuringDrag.onTapStartNode = function (e) {

@@ -52,50 +51,2 @@ // If user intends to do box selection, then return. Related issue #28

function getTopMostNodes(nodes) {
var nodesMap = {};
for (var i = 0; i < nodes.length; i++) {
nodesMap[nodes[i].id()] = true;
}
var roots = nodes.filter(function (ele, i) {
if(typeof ele === "number") {
ele = i;
}
var parent = ele.parent()[0];
while (parent != null) {
if (nodesMap[parent.id()]) {
return false;
}
parent = parent.parent()[0];
}
return true;
});
return roots;
}
var moveNodesTopDown = function (nodes, dx, dy) {
/*
console.log(nodes.map(function (e) {
return e.id();
}));
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
var pos = node.position();
if (!node.isParent()) {
node.position({
x: pos.x + dx,
y: pos.y + dy
});
console.log(node.id() + " " + dx + " " + dy);
}
moveNodesTopDown(nodes.children(), dx, dy);
}
*/
};
var onTapDrag = function (e) {

@@ -109,6 +60,5 @@

attachedNode.unlock();
//var topMostNodes = getTopMostNodes(draggedNodes);
var nodes = draggedNodes.union(draggedNodes.descendants());
nodes.positions(function (node, i) {
nodes.filter(":childless").positions(function (node, i) {
if(typeof node === "number") {

@@ -115,0 +65,0 @@ node = i;

@@ -16,28 +16,2 @@ module.exports = function (cy, gridSpacing) {

function getTopMostNodes(nodes) {
var nodesMap = {};
for (var i = 0; i < nodes.length; i++) {
nodesMap[nodes[i].id()] = true;
}
var roots = nodes.filter(function (ele, i) {
if(typeof ele === "number") {
ele = i;
}
var parent = ele.parent()[0];
while(parent != null){
if(nodesMap[parent.id()]){
return false;
}
parent = parent.parent()[0];
}
return true;
});
return roots;
}
snap.snapPos = function (pos) {

@@ -60,26 +34,6 @@ var newPos = {

function snapTopDown(nodes) {
nodes.union(nodes.descendants()).positions(function (node, i) {
if(typeof node === "number") {
node = i;
}
var pos = node.position();
return snap.snapPos(pos);
});
/*
for (var i = 0; i < nodes.length; i++) {
if (!nodes[i].isParent())
snap.snapNode(nodes[i]);
snapTopDown(nodes.children());
}*/
}
snap.snapNodesTopDown = function (nodes) {
// getTOpMostNodes -> nodes
cy.startBatch();
nodes.union(nodes.descendants()).positions(function (node, i) {
nodes.union(nodes.descendants()).filter(":childless").positions(function (node, i) {
if(typeof node === "number") {

@@ -86,0 +40,0 @@ node = i;

Sorry, the diff of this file is too big to display