【发布时间】:2015-04-03 18:02:04
【问题描述】:
目前我通过在dragStart 函数中使用element.clone() 并在dragMove 函数中移动克隆(在dragStop 函数中删除它)来拖动可拖动Raphael 元素的克隆。
这会导致可拖动元素的 onDragOver 函数出现问题,因为大多数情况下,克隆会引发相应的事件而不是目标事件。
一些代码:
dragStart = function() {
var s = this, c = s.clone();
s.data('clone', c);
c.ox = c.attr('cx');
c.oy = c.attr('cy');
};
dragMove = function(dx, dy) {
var s = this, c = s.data('clone');
c.attr({cx:c.ox+dx, cy:c.oy+dy});
};
dragStop = function() {
this.data('clone').remove();
};
onDragOver = function(el) {
console.log(el); // displays most of the time the clone
};
elementToDrag.drag(dragMove, dragStart, dragStop);
elementToDrag.onDragOver(onDragOver);
【问题讨论】: