JSFiddle - React, Tailwind, and code Playground
by pajtai
HTML
<div id="canvas"></div>
JavaScript
window.onload = function() {
var R = Raphael("canvas", 500, 500),
c = R.circle(100, 100, 50).attr({
fill: "hsb(.8, 1, 1)",
stroke: "none",
opacity: .5
}),
d = R.circle(200, 200, 50).attr({
fill: "hsb(1, 1, .8)",
stroke: "none",
opacity: .5
}),
start = function () {
// storing original coordinates
this.ox = this.attr("cx");
this.oy = this.attr("cy");
this.attr({opacity: 1});
},
move = function (dx, dy) {
// move will be called with dx and dy
this.attr({cx: this.ox + dx, cy: this.oy + dy});
},
up = function () {
// restoring state
this.attr({opacity: .5});
this.undrag(); // Try to make it undragable
};
c.drag(move, start, up);
d.drag(move, start, up);
};