JSFiddle - React, Tailwind, and code Playground

by cancerbero_sgx

JavaScript

/* this is an error when adding raphael shapes as json object using paper.add(). I build a json shape type=rect, but pass an extra r=0 property and after adding getBBox() is returning x=4000 instead x=400 */
var paper = Raphael(0,0,300,400);
 /* this works OK - x = 400 */
 //var json = "[{\"type\":\"rect\",\"x\":\"400\",\"y\":\"400\",\"width\":\"300\",\"height\":\"300\"}]";
 
/* this is wrong: x=4000 */
 var json = "[{\"type\":\"rect\",\"x\":\"400\",\"y\":\"400\",\"width\":\"300\",\"height\":\"300\", \"r\":\"0\"}]";
paper.add(eval(json));
paper.forEach(function(shape){
    alert(shape.getBBox().x);
});