【问题标题】:Reseting panzoom should set the graph in original state in cytoscape.js重置 panzoom 应该在 cytoscape.js 中将图形设置为原始状态
【发布时间】:2015-02-06 21:47:56
【问题描述】:

如给定https://github.com/cytoscape/cytoscape.js-panzoom 当我将任何节点拖动到任何位置并再次缩放它并使用重置按钮重置(即适合屏幕)缩放时,拖动的节点保持在它被放置的新位置,它只适合图形。 是否可以将图形重置为原始状态?即,如果我将节点移动到任何位置,那么在重置(适合屏幕)之后它应该出现在其原始状态/位置。 我用过布局{ 名称:'可乐' } 来布局图形。 谢谢!

【问题讨论】:

    标签: cytoscape.js


    【解决方案1】:

    这是将图形重置为其原始位置的代码,我将其放在 cytoscape.js-panzoom.js 中。代码如下:

                        $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;
                    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-18
      • 2015-05-20
      相关资源
      最近更新 更多