2017-02-28 44 views

回答

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. 
    } 
}) 
+0

托馬斯嗨, 我沒有跟上面的代碼管理,但創造了另一種解決方案。 通過使用不同的連接路由器和自己的畫布策略,我可以從畫布上讀出鼠標位置和滾動條。有了這個代碼,我可以創建一個自動滾動選項。 – Dreqnoid

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); 


     } 
} 
相關問題