web-view 页面mousemove失效
发布于 5 年前 作者 yankong 8728 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

h5 代码

<script src="http://cdn.bootcss.com/jquery/2.2.3/jquery.js"></script>
<div id="mouseMove">
<span id="span" style="color: red"></span>
<button id="movebtn" style="width: 100px;height: 100px;">拖动我</button>

</div>

<script>
var num = 0;
$().ready(function(){
console.log('begin move')


document.getElementById("movebtn").addEventListener("mousedown", function(e){
document.getElementById("span").innerHTML = e.clientX + ',' + e.clientY
drag(document.getElementById("movebtn"))
   });
})

/**
  * elementToDrag mousedown 事件的元素
  * [@param](/user/param) elementToDrag
  * [@param](/user/param) event
  */
 function drag(elementToDrag){
document.addEventListener("mousemove", moveHandler, true);
document.addEventListener("mouseup", upHandler, true);

function moveHandler(e){
num++;
document.getElementById("span").innerHTML = e.clientX + ',' + e.clientY
console.log(e.clientX + ',' + e.clientY)

if(e.stopPropagation)
e.stopPropagation();
else
       e.cancelBubble = true;
}

function upHandler(e){
document.removeEventListener("mousemove", moveHandler, true);
document.removeEventListener("mouseup", upHandler, true);

console.log(3);

if(e.stopPropagation)
e.stopPropagation();
else
       e.cancelBubble = true;
}
}
</script>
回到顶部