【问题标题】:Change the interaction attribute of JointJs Paper?更改 JointJs Paper 的交互属性?
【发布时间】:2015-08-18 13:13:23
【问题描述】:

最近需要做一个 JointJs 图的交互模式。众所周知,纸张对象的创建过程如下:

    paper = new joint.dia.Paper({
      el: $(#myDiagram),
      width: this.props.width,
      height: this.props.height,
      model: this.state.graph,
      gridSize: 1,
      interactive: false
    });

您创建了一个包含所需选项的新论文。在这种情况下,交互(“交互”标志)设置为假。不幸的是,纸质对象上没有 get、attrs、set 方法。我想创建一个更改交互式标志的按钮。它的位置在论文内的选项对象中。手动访问会更改值,但这根本不反映纸张。每次更改交互时重新初始化它的唯一解决方案是什么?先谢谢了。

【问题讨论】:

    标签: javascript backbone.js jointjs


    【解决方案1】:

    这已经改变并且变得更好了。我正在使用jointjs 1.0.3,现在这对我有用:

      edit() {
        const self = this
        this.graph.getCells().forEach(function (cell) {
          const c = cell.findView(self.paper)
          c.setInteractivity(true)
        })
      }
    

    【讨论】:

      【解决方案2】:

      您是否已经尝试拨打电话

      paper.render()
      

      更改值后?

      【讨论】:

      • 毕竟它是一个主干模型/视图。所以这可能有效。
      • 我目前处于同样的情况。更改值后调用 paper.render() 对我不起作用。
      • 我找到了解决方案并将其发布为答案。
      【解决方案3】:

      我对这个问题的解决方法如下:

      _.forEach(this.graph.getLinks(), function (link:joint.dia.Link) {
          self.paper.findViewByModel(link).options.interactive = {
              vertexAdd: true,
              vertexMove: true,
              vertexRemove: true,
              arrowheadMove: false
          }
      });
      

      (我在这个问题上使用了 David Durman 的答案:https://groups.google.com/forum/#!searchin/jointjs/interactive/jointjs/h7tVqVUTd2E/VfA1BaQaFFAJ

      这使我可以更改所有链接的交互性(特别是更改顶点),而无需再次进行纸张初始化。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-13
        • 1970-01-01
        • 2019-03-24
        • 2014-01-13
        • 1970-01-01
        相关资源
        最近更新 更多