0

When you drag an object and mouse is out of rendering area, dragging stops (firing an event) and user loses a grip.

It's extremelly inconvenient, taking into account that all other technologies (Flash, raw HTML5 Canvas, etc) allows to save the grip even if mouse is out.

Is there a way to solve the problem?

UPDATE: Up to the moment solved the problem by changing library file and binding listeners to the document, not to the container. I know that it's bad to hack into library files, but after inspecting the library's source code I haven't found out way around.

4

2 に答える 2

2

要素が見えないかどうかを確認し、見えない場合は元に戻すことができます:

shape.on('dragend', function() {
 var pos = shape.getPosition();
 var layer = pos.getLayer();
 if (pos.y < 0) {
  pos.y = 0;
 }
 var maxY = layer.getHeight() - shape.getHeight();
 if (pos.y > maxY) {
  pos.y = maxY
 }
 shape.setPosition(pos);
}
于 2012-11-30T16:19:22.250 に答える
1

を見てくださいelement.setCapture()。マウスイベントのイベントハンドラー内から呼び出すことができます。mousedown:

function mouseDown(e) {
    e.target.setCapture();
    e.target.addEventListener("mousemove", mouseMoved, false);
}

ブラウザーのサポートは少しむらがありますが (IE と Firefox はサポートしていますが、他のブラウザーについては不明です)、クロスブラウザーで使用するには、既に見つけたドキュメント アプローチのバインディングにフォールバックする必要があります。

于 2012-10-26T11:11:01.007 に答える