JSFiddle - React, Tailwind, and code Playground

by vitorbarbosa

HTML

<div id="canvas"></div>

JavaScript

var paper = new Raphael("canvas", 400, 400);
var r1 = paper.rect(25, 25, 50, 50).attr({fill: "red"}).rotate(45);

var drag_move = function(dx, dy){
    r1.attr({
        transform: "...T" + (dx - this.dox) + "," + (dy - this.doy)
    });
    //
    // store the previous versions of dx,dy for use in the next move call.
    //
    this.dox = dx;
    this.doy = dy;
};

var drag_start = function(){
    this.dox = 0;
    this.doy = 0;
}

var drag_end = function(){
    this.dox = 0;
    this.doy = 0;
}
    
    
r1.drag(drag_move, drag_start, drag_end);