print() を使用して追加されたテキストをドラッグ可能にしようとしています。SO投稿を見つけましたが、コードが機能しません-フィドルとして再投稿しました-クロムとFFでテキストが画面から飛び出します。getBBox() パラメータを false に設定すると、最初のドラッグは機能しますが、その後のドラッグではマウスがオフセットされます。
var w = document.body.clientWidth,
h = document.body.clientHeight,
paper = Raphael(0, 0, w, h);
var font = paper.getFont("Vegur");
var text = paper.print(20,20,"my dragable text",font,50);
var start = function () {
text.oBB = text.getBBox();
},
move = function (dx, dy) {
var bb = text.getBBox(true); // Setting to false works once
text.transform('...T'+[text.oBB.x - bb.x + dx, text.oBB.y - bb.y + dy]);
},
up = function () {
};
text.drag(move, start, up);