[英]Why can't removeEventListener
In your fnDown you set the event listener to be on the dragBox but then you try to remove it from the dragArea later on. 在您的fnDown中,将事件侦听器设置为dragBox,但是稍后尝试将其从dragArea中删除。 You need to attach the listener to the dragArea if that's where you plan to remove it from.
如果您打算将侦听器从dragArea中删除,则需要将其附加到该侦听器。 This function works as expected.
此功能按预期方式工作。
Drag.prototype.fnDown = function (e) {
this.diff.x = e.clientX - this.dragBox.offsetLeft
this.diff.y = e.clientY - this.dragBox.offsetTop
this.dragArea.addEventListener('mousemove', this.fnMove,false)
}
Working example: http://jsbin.com/dugoxeziho/1/edit?html,output 工作示例: http : //jsbin.com/dugoxeziho/1/edit?html,输出
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.