【发布时间】:2014-11-19 17:30:21
【问题描述】:
我想将一条线拖到我拖动的元素上。为此,我需要拖动时元素的“真实”位置。
我试过了:
textSign.drag(function (dx, dy, posx, posy) {
var myMatrix = new Snap.Matrix();
myMatrix.translate(dx,dy);
this.transform(myMatrix.toTransformString());
//drag another element
}, function(x,y,event){
//contains only mouse position
}, function(){
this.attr({x: parseFloat(this.attr("x")) + this.matrix.e, y: parseFloat(this.attr("y")) + this.matrix.f});
this.transform('t0,0');
});
我可以在移动时获得(矩阵或某物的)真实位置吗?
【问题讨论】:
-
我不清楚你在拖动时想要做什么,为什么要使用矩阵,你能把你拥有的东西放在小提琴上吗,那么它可能会更明显一点?
-
我想将点(x2,y2) 的末端设置为对象的中心,同时拖动:jsbin.com/koheyekema/1/edit?html,js,output
标签: javascript svg snap.svg