0
我正在使用拖動功能,因爲我在小提琴中使用拖曳功能,但我想移動rect和文本togehter,因爲我不僅將拖拽應用到了該矩形。我怎樣才能改變我的拖動功能來移動整個集合?拉斐爾拖整個集
start = function() {
this.ox = this.type == "rect" ? this.attr("x") : this.attr("cx");
this.oy = this.type == "rect" ? this.attr("y") : this.attr("cy");
this.attr({
opacity: 1
});
// Save the dragged object in global namespace.
window.someVar = this;
},
move = function(dx, dy) {
var att = this.type == "rect" ? {
x: this.ox + dx,
y: this.oy + dy
} : {
cx: this.ox + dx,
cy: this.oy + dy
};
this.attr(att);
},
up = function() {
this.attr({
opacity: .5
});
delete window.someVar;
};
上一套refrance
http://jsfiddle.net/Margo/Q3EBw/3/