简体   繁体   English

在raphael.js中的数组元素上拖动()

[英]drag() on array-elements in raphael.js

I have a lot of Raphael elements which I push into an array: 我将很多Raphael元素放入数组:

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. 最奇怪的是, startmove火,因为他们应该。 But why do they don't move. 但是为什么他们不动。

Thanks in advance! 提前致谢!

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. 首先,属性cx,cy用于圆形和椭圆形,因此更新它们不会移动使用x和y属性的矩形。 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. 如果您想同时移动它们(这是我开始阅读您的问题时的第一印象-但现在我不太确定:),那么请参考问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM