Reputation: 235
As given https://github.com/cytoscape/cytoscape.js-panzoom when I drag any node to any position and again zoom it and reset(i.e.fit to screen) that zoom using reset button,the draged node remains at new position where it is droped,it only fits the graph. Is it possible to reset the graph to original state? i.e. if I move node to any position then after reset(fit to screen) it should appear at its original state/position. I have used layout{ name: 'cola' } to layout the graph. Thanks!
Upvotes: 0
Views: 1262
Reputation: 235
Here is the code to reset the graph to its original position, I put this in cytoscape.js-panzoom.js. code as below:
$reset.bind("mousedown", function(e){
if( e.button != 0 ){
return;
}var cy = $container.cytoscape("get");
if( cy.elements().size() === 0 ){
cy.reset();
} else { coseOptions = {
name: 'cola', //set layout
ready : function() {},
stop : function() {},
refresh : 0,
animate : false,
fit : true,
padding : 30,
randomize : false,
debug : false,
nodeRepulsion : 10000,
nodeOverlap : 10,
idealEdgeLength : 10,
edgeElasticity : 100,
nestingFactor : 5,
gravity : 250,
numIter : 100,
initialTemp : 200,
coolingFactor : 0.95,
minTemp : 1
};
cy.layout(coseOptions);
//cy.fit( options.fitPadding );
}
return false;
});
Upvotes: 2