【发布时间】:2016-03-04 21:35:19
【问题描述】:
我正在使用 jsPlumb 在 div 之间画线。棘手的部分是我正在使用引导选项卡窗格,因此在打开页面时可能不会呈现窗格。第二个困难,一些 div 是可折叠的,迫使我重新绘制连接器。
重绘操作在 Firefox 上效果很好,但在任何其他浏览器上,连接器位置错了(Chrome 实际上是根据当前页面偏移量的大小进行偏移量,edge 只是在天空某处重绘所有连接器) .
有什么想法吗?我将尝试尽快发布 MWE(我的代码实际上很大,但这是我所做的):
jsPlumb.ready(function () {
jsPlumb.setContainer($('body')); // needed because connected divs are not at the same dom-tree level
$('a[data-toggle="tab"]').on('shown.bs.tab', function (event)
if (event.target.id == 'carto-pill') {
drawConnections();
} else {
jsPlumb.detachEveryConnection(); // needed otherwise they are still visible when switching tabs
}
});
});
function drawConnections() {
var red = '#ff1d25', orange = '#f7931e' , green = '#39b54a';
var width = 2;
var lineWidth = 2;
var outlineWidth = 2;
jsPlumb.connect({
source:'carto-is_supported',
target:'focused-arg',
endpoint: [ "Rectangle", {width: width, height: 10 }],
anchors: ["Right", [0, 0.25, -1, 0] ],
paintStyle:{lineWidth: lineWidth, strokeStyle: green},
endpointStyle:{fillStyle: green, outlineWidth: outlineWidth}
});
// many other connections are also drawn
jsPlumb.repaintEverything();
}
【问题讨论】:
标签: javascript jquery twitter-bootstrap jsplumb