【发布时间】:2016-05-18 12:33:09
【问题描述】:
我对拉斐尔有意见。在应用缩放、旋转等任何变换后,我无法正确拖动对象。
var text;
Raphael.el.draggable = function () {
var start = function () {
this.ox = 0;
this.oy = 0;
},
move = function (dx, dy) {
var x = dx - this.ox,
y = dy - this.oy;
this.transform("...t" + x + "," + y);
this.ox = dx;
this.oy = dy;
},
end = function () {
};
this.drag(move, start, end);
return this;
};
var paper = Raphael(document.getElementById('canvas'), 300, 300);
paper.rect(0, 0, 300, 300).attr('fill', '#dedede');
text = paper.text(150, 150, 'ABC');
text.attr('font-size', 48);
text.transform('...r90');
text.draggable();
这是一个例子。
https://jsfiddle.net/rzj4e4x8/1/
如何更正我的移动功能,使其可以正确地将对象移动到光标方向?
【问题讨论】:
标签: javascript rotation raphael drag