Skip to content

Commit

Permalink
chore: update js libraries
Browse files Browse the repository at this point in the history
svg not checked
close #12
  • Loading branch information
jhk0530 committed Sep 26, 2023
1 parent a6e2067 commit 1ab6971
Show file tree
Hide file tree
Showing 21 changed files with 6,061 additions and 9,448 deletions.
23 changes: 0 additions & 23 deletions inst/htmlwidgets/lib/cytoscape-3.12.0/cytoscape.min.js

This file was deleted.

23 changes: 0 additions & 23 deletions inst/htmlwidgets/lib/cytoscape-3.13.0/cytoscape.min.js

This file was deleted.

490 changes: 0 additions & 490 deletions inst/htmlwidgets/lib/cytoscape-cola/cola.js

This file was deleted.

79 changes: 41 additions & 38 deletions inst/htmlwidgets/lib/cytoscape-cola/cytoscape-cola.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ ColaLayout.prototype.run = function () {
var dimensions = node.layoutDimensions(options);

var struct = node.scratch().cola = {
x: options.randomize || pos.x === undefined ? Math.round(Math.random() * bb.w) : pos.x,
y: options.randomize || pos.y === undefined ? Math.round(Math.random() * bb.h) : pos.y,
x: options.randomize && !node.locked() || pos.x === undefined ? Math.round(Math.random() * bb.w) : pos.x,
y: options.randomize && !node.locked() || pos.y === undefined ? Math.round(Math.random() * bb.h) : pos.y,
width: dimensions.w + 2 * padding,
height: dimensions.h + 2 * padding,
index: i,
Expand All @@ -392,46 +392,45 @@ ColaLayout.prototype.run = function () {
if (options.alignment) {
// then set alignment constraints

var offsetsX = [];
var offsetsY = [];

nonparentNodes.forEach(function (node) {
var align = getOptVal(options.alignment, node);
var scrCola = node.scratch().cola;
var index = scrCola.index;

if (!align) {
return;
}

if (align.x != null) {
offsetsX.push({
node: index,
offset: align.x
if (options.alignment.vertical) {
var verticalAlignments = options.alignment.vertical;
verticalAlignments.forEach(function (alignment) {
var offsetsX = [];
alignment.forEach(function (nodeData) {
var node = nodeData.node;
var scrCola = node.scratch().cola;
var index = scrCola.index;
offsetsX.push({
node: index,
offset: nodeData.offset ? nodeData.offset : 0
});
});
}

if (align.y != null) {
offsetsY.push({
node: index,
offset: align.y
constraints.push({
type: 'alignment',
axis: 'x',
offsets: offsetsX
});
}
});

if (offsetsX.length > 0) {
constraints.push({
type: 'alignment',
axis: 'x',
offsets: offsetsX
});
}

if (offsetsY.length > 0) {
constraints.push({
type: 'alignment',
axis: 'y',
offsets: offsetsY
if (options.alignment.horizontal) {
var horizontalAlignments = options.alignment.horizontal;
horizontalAlignments.forEach(function (alignment) {
var offsetsY = [];
alignment.forEach(function (nodeData) {
var node = nodeData.node;
var scrCola = node.scratch().cola;
var index = scrCola.index;
offsetsY.push({
node: index,
offset: nodeData.offset ? nodeData.offset : 0
});
});
constraints.push({
type: 'alignment',
axis: 'y',
offsets: offsetsY
});
});
}
}
Expand Down Expand Up @@ -574,7 +573,9 @@ ColaLayout.prototype.run = function () {

layout.trigger({ type: 'layoutstart', layout: layout });

adaptor.avoidOverlaps(options.avoidOverlap).handleDisconnected(options.handleDisconnected).start(options.unconstrIter, options.userConstIter, options.allConstIter);
adaptor.avoidOverlaps(options.avoidOverlap).handleDisconnected(options.handleDisconnected).start(options.unconstrIter, options.userConstIter, options.allConstIter, undefined, // gridSnapIterations = 0
undefined, // keepRunning = true
options.centerGraph);

if (!options.infinite) {
setTimeout(function () {
Expand Down Expand Up @@ -657,6 +658,8 @@ var defaults = {
flow: undefined, // use DAG/tree flow layout if specified, e.g. { axis: 'y', minSeparation: 30 }
alignment: undefined, // relative alignment constraints on nodes, e.g. function( node ){ return { x: 0, y: 1 } }
gapInequalities: undefined, // list of inequality constraints for the gap between the nodes, e.g. [{"axis":"y", "left":node1, "right":node2, "gap":25}]
centerGraph: true, // adjusts the node positions initially to center the graph (pass false if you want to start the layout from the current position)


// different methods of specifying edge length
// each can be a constant numerical value or a function like `function( edge ){ return 2; }`
Expand Down
Loading

0 comments on commit 1ab6971

Please sign in to comment.