【发布时间】:2011-10-20 16:51:50
【问题描述】:
我有许多圆圈用作可拖动按钮,我可以为这些圆圈分配拖动事件并且它可以正常工作,但我想克隆并拖动它们,所以我最终得到了多个按钮(多达需要)。如何克隆然后拖动克隆的对象?
这就是我所拥有的
var a = r.circle(20, 50, 15)
// drag handler
var start = function(x,y,event) {
this.ox = this.attr("cx");
this.oy = this.attr("cy");
this.animate({r: 20, opacity: .25}, 500, ">");
},
move = function(dx, dy) {
this.attr({cx: this.ox + dx, cy: this.oy + dy});
},
up = function () {
this.animate({r: 15, opacity: .5}, 500, ">");
};
a.drag(move, start, up);
我尝试了各种方法,一开始就克隆“a”,克隆“this”,但我的 js 知识有限,因此不胜感激。
谢谢!
【问题讨论】:
标签: javascript raphael