【发布时间】:2013-03-16 03:37:25
【问题描述】:
所以我尝试对元素/集合使用 getBBox() 方法,并使用 x、y、width 和 height 属性来定义一个矩形。但是该元素附加了一个拖动事件,每次触发拖动事件时,它都会绘制一个新的边界框。
我尝试在我的拖动功能之后使用 element.remove 来删除该元素,但我似乎遇到了一个元素未定义错误。
foo.click(function(){
console.log(foo.getBBox());
var herpaderp = drawBBox(foo.getBBox());
console.log(herpaderp);
dragsymbolsoncanvas(foo,herpaderp);
});
function dragsymbolsoncavas(foo,herpaderp){
function dragger(){
this.dx = this.dy = 0;
};
function mover(s){
return function(dx, dy){
if(this.data("candrag")=="true"){
(s||this).translate(dx-this.dx,dy-this.dy);
this.dx = dx;
this.dy = dy;
}
}
};
foo.drag(mover(foo), dragger);
herpaderp.remove();
};
【问题讨论】: