0
我使用jsPlumb在div之間繪製線條。棘手的部分是我使用引導選項卡窗格,因此打開頁面時可能無法呈現窗格。第二個難點是,一些div可摺疊,迫使我重新繪製連接器。jsPlumb repaint除了火狐瀏覽器之外的所有瀏覽器都不工作
重繪動作在Firefox上作用很大,但在任何其他瀏覽器,連接器放錯了地方(Chrome的實際進行偏移正是當前頁面的偏移,邊緣剛剛重新粉刷所有連接器的地方在天空中的大小)。
有什麼想法?我會盡快發佈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();
}