问题
This is my code. i have tried but cant find any answer. so anyone help me
move = function (dx, dy) {
paper.clear();
this.attr({x: this.ox + dx, y: this.oy + dy});
var arrow = paper.arrow(this.ox,this.oy,this.attrs.x,this.attrs.y,8);
}
rect2.drag(move, start);
回答1:
I don't think you need to be clearing (unless you have a specific reason for doing so...). Raphael isn't like drawing on the html5 canvas; you don't need to clear and redraw everything when you want to animate. Each element within Raphael (and SVG) is an object in and of itself. Changing the centre of a circle will automatically update where that circle is in your drawing.
As long as you have a handle to the object you can manipulate it to your hearts content without having to request it be redrawn.
来源:https://stackoverflow.com/questions/11114416/how-to-redraw-raphael-object-after-paper-clear