![](/img/trans.png)
[英]HTML5 pointermove/touchmove not working in Microsoft Edge
[英]“touchmove” event is not triggered in Microsoft Edge
我需要根據touchmove事件的clientx和clienty位置檢測拖動元素時的情況。 在Chrome中,可以識別touchmove事件並正確返回位置,而在Microsoft Edge中則不能識別touchmove事件。
<div id="ele" style="position:absolute; top:0px; left:0px; width:100px;height:100px;border:1px solid"></div>
$(document).ready(function() {
document.getElementById('ele').addEventListener('touchmove', function(e)
{
console.log('event triggered');
})
});
我在Edge中將事件類型作為mousemove獲取,但我想改為獲取touchmove事件。 有什么辦法嗎?
嘗試將其添加到HTML文件:
canvas { touch-action: none;}
您需要添加“ passive:false”,如下面的一些示例代碼所示。 這是因為默認情況下被動設置為true。 我花了幾天的時間弄清楚這個!
document.addEventListener('touchmove', function(e) {
e.preventDefault();
}, { passive: false });
編輯。 我相信另一篇文章是正確的,這是錯誤的,但是為了防萬一,我將其留在了這里,因為其他瀏覽器需要使用被動式的:false功能來滿足您的要求
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.