【问题标题】:Getting outer elements in jointJS to expand the paper在jointJS中获取外部元素以扩展论文
【发布时间】:2015-10-17 15:30:01
【问题描述】:

如果用户将元素移动到底部或右侧边框,我想扩展纸张:

var paper = new joint.dia.Paper({
    el: $('#canvas'),
    width: 801,
    height: 496,
    model: graph
});

rect.on('change:position', function(evt, pos) {
    if (pos.y > 400) { height = pos.y + 96; }
    else { height = 496; }

    if (pos.x > 680) { width = pos.x + 121; }
    else { width = 801; }

    paper.setDimensions(width, height);
});

这仅适用于单个元素。但是如果已经有另一个元素,这不起作用。

所以我需要找到具有最高 x 或 y 值的元素。这意味着我搜索纸张最右边或最底部的元素。然后我会把它放到另一个 if 子句中。

我想过使用paper.findViewsInArea(rect),但我真的不知道如何获得我需要的结果。

【问题讨论】:

    标签: javascript jointjs


    【解决方案1】:

    您不必使用setDimensions()。只需做类似的事情

    rect.on('change:position', function(evt, pos, y) {
        paper.fitToContent({
            minWidth: 801,
            minHeight: 496
        });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-22
      • 1970-01-01
      • 2017-01-29
      • 1970-01-01
      • 2021-10-24
      • 2017-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多