JSFiddle - React, Tailwind, and code Playground
JavaScript
window.onload = function() {
var paper = Raphael(0, 0, 640, 540);
// our functions are within window.onload, so
// if we define an object here, they can all see it
var sets = {};
// using a raphael set means we can do raphael functions
// on every element at once
sets.mouseover = paper.set();
function aa(h1,h2){
// put the rectangle somewhere we can get at it
sets.mouseover.push(
paper.rect(h1+200,h2,100,100)
);
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
(function(i, j) {
var boxes = paper.rect(0 + (j * 100), 0 + (i * 100), 100, 100).attr({
fill: '#303030',
stroke: 'white'
});
boxes.node.onmouseover = function() {
var h1 = boxes.getBBox().x;
var h2 = boxes.getBBox().y;
aa(h1,h2);
};
boxes.node.onmouseout = function() {
// no display:none attr
// opposite of create is remove, not hide
sets.mouseover.remove();
};
})(i, j);
}
}
}