0

I have a lot of Raphael elements which I push into an array:

var start = function () {
                this.ox = this.attr("cx");
                this.oy = this.attr("cy");
            },
            move = function (dx, dy) {
                this.attr({cx: this.ox + dx, cy: this.oy + dy});
            }    

for(var i = 0; i < 149; i++) {
    cubes = paper.rect(Math.floor(Math.random()*2000), Math.floor(Math.random()*2000), 0, 0);
    cubes.animate({ width: 25, height: 25 }, 500, "bounce");
    cubesmixed.push(cubes);
    cubesmixed[i].drag(move, start);
}

but unfortunatly I can't drag them. The most weird thing is, that start and move fire as they should. But why do they don't move.

Thanks in advance!

supersize
  • 13,764
  • 18
  • 74
  • 133

1 Answers1

1

First of all attribute cx, cy are used in circles and elipsis so updating them will not move your rectangle which uses x and y attributes. If what you want to achieve is to move them simultanously (that was my first impression when I started to read your question - but I am not sure about that anymore :)), then please refer to this question.

Community
  • 1
  • 1
Adam Moszczyński
  • 3,477
  • 1
  • 17
  • 18