【问题标题】:Visibility of parent node affects opacity of children nodes父节点的可见性影响子节点的不透明度
【发布时间】:2018-09-25 01:28:46
【问题描述】:

我想实现一个复选框来启用/禁用我的复合布局的层次结构。似乎父节点的可见性会影响其子节点。我也尝试过不透明度,但看起来是一样的。有没有办法解决这个问题?您可以在下面找到我的代码。

  //Turn on/off the hierarchy 

  $("#hierarchy-check").on("change",function(){
    if(this.checked) {
      not_childless.css({visibility:'visible'});
      childless.css({visibility:'visible'});
    } 
    else {
      not_childless.css({visibility:'hidden'});
      childless.css({visibility:'visible'});

    }  
  });

【问题讨论】:

    标签: cytoscape.js


    【解决方案1】:

    我现在基于eles.move() 函数的使用找到了一个解决方案。当再次启用层次结构时,我在连接无子节点时遇到了一些问题,所以我只是删除了整个图形并再次添加它。可能,这不是理想的解决方案,但现在可以正常工作。下面是我的代码。在我的代码中,变量not_childlesschildless 在此事件之前计算。

         $("#hierarchy-check").on("change",function(){
        if(this.checked) {
         cy.elements().remove();
         childless.removeClass('hierarchyDisabled');
         cy.add(all_elements);
        } 
        else {
          for(let i=0; i < childless.length; i++) {
           childless[i].move({parent:null}); //I remove the current parent of the node but I keep the position
           childless.addClass('hierarchyDisabled'); //This is just some styling that I add
          }
          not_childless.remove();
        }  
      });
    

    【讨论】:

      猜你喜欢
      • 2019-03-08
      • 1970-01-01
      • 2019-04-19
      • 2011-07-06
      • 1970-01-01
      • 2021-10-17
      • 2015-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多