2013-10-23 28 views
0

我有很多Raphael元件,其餘推入數組的:拖動()對raphael.js陣列元素

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); 
} 

但不幸的是,我不能拖動它們。最奇怪的是,startmove因爲他們應該。但爲什麼他們不動。

在此先感謝!

回答

1

首先屬性cx,cy用於圓和省略號,所以更新它們將不會移動使用x和y屬性的矩形。如果你想要達到的目標是同時移動它們(這是我開始閱讀你的問題時的第一印象 - 但我不確定:)),那麼請參考this問題。