我有两个人物,一个在画布的可见区域,一个在外面(在右侧)。无法建立联系,因为我无法到达另一个数字。是否可以在创建连接时向右自动滚动,以便我可以连接到该图形?
问问题
520 次
2 回答
0
不幸的是,您将不得不自己处理滚动。尝试这样的事情
var canvas = new draw2d.Canvas("canvas_id");
var scrollElement = canvas.getScrollArea();
var viewArea = new draw2d.geo.Rectangle(
scrollElement.scrollLeft(), scrollElement.scrollTop(),
scrollElement.width() * canvas.zoomFactor, scrollElement.height() * canvas.zoomFactor);
var outputLocator = new draw2d.layout.locator.OutputPortLocator();
var port = figure.createPort("output", outputLocator);
port.on('drag', function(){
if (!viewArea.contains(port.getBoundingBox())) {
// -- the port has moved off the visible area of the canvas so scroll the view.
}
})
于 2017-03-08T19:23:52.873 回答
0
帆布政策:
var myScroll = draw2d.policy.canvas.CanvasPolicy.extend ({ NAME: 'myScroll',
init: function() {
this._super();
},
onMouseMove: function(the, mouseX, mouseY, shiftKey, ctrlKey) {
this._super(the, mouseX, mouseY, shiftKey, ctrlKey);
if (mouseX>the.getWidth()-100+the.getScrollLeft()) {
$buffer = $("#canvas").scrollLeft();
$treshold = 10;
$("#canvas").scrollLeft($buffer+$treshold);
}
}
于 2017-06-09T08:10:39.667 回答