[英]How to simulate a drag end event in Raphael JS?
我正在使用Raphael JS 2.0,并希望模拟另一个元素上拖动的结束,然后删除当前正在处理的元素。 如果可以使用jquery完成,那也很棒。
像这样的东西:
var child = currentShift.data('endChild');
var newX = child.attr('x');
if (this !== currentShift)
{
newX = child.attr('x')-day;
}
currentShift.attr({y: child.attr('y'), x: newX, height: child.attr('height')});
$(currentShift.node).mouseup();
child.remove();
我得到错误,因为子元素是拖动的“移动”部分中的this
元素。 但它被用于与currentShift
交互。
我知道还有一些其他方法可以获得类似的效果,但我想知道是否有某种方法可以模仿任意元素的拖拽结束。
它看起来像你可以用你的拖动结束函数的引用(在我的情况up
),用call()
只是传递引用(在我的情况currentShift
)到您的拉斐尔JS元素。 我的代码现在看起来像这样:
var child = currentShift.data('endChild');
var newX = child.attr('x');
if (this!==currentShift)
{
newX = child.attr('x')-day;
}
currentShift.attr({y: child.attr('y'), x: newX, height: child.attr('height')});
if (this !== currentShift)
up.call(child);
else
up.call(currentShift);
child.remove();
这仍然没有完全符合我的要求,因为如果用户一直按住鼠标,它会尝试调用我的拖动移动功能,即使在元素被移除后(即它实际上并没有强制拖动事件停止) ,它只是调用up事件然后给出了很多非致命错误,因为在尝试调用move函数时元素不再存在。)
如果有人能在接下来的几天内提供关于如何强制拖动结束的答案(因此不再调用移动功能),即使用户继续按住鼠标,我也会接受这个答案。 否则,我会接受这个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.