Chapter 3: Drag Events
JavaScript
var paper = new Raphael(0, 0, 500, 500);
var circle = paper.circle(120, 110, 25).attr("fill", "yellow");
var ox = 0,oy = 0;
circle.drag(dragmove, dragstart, dragend);
function dragmove(dx, dy, x, y, e) {
this.attr({
cx: ox+dx,
cy: oy+dy
});
}
function dragstart(x, y, e) {
ox = this.attr("cx");
oy = this.attr("cy") ;
this.attr("fill", "orange");
}
function dragend(e) {
this.attr("fill", "yellow");
}