我拿不到钥匙
pointerup
A
标记为
href
属性集)
event.pointerType == 'mouse'
如果鼠标在
pointerdown
和
指针
.
我有以下场景:
var lastEvent = false;
var handler = function (e) {
if (lastEvent != e.type) {
e.target.innerHTML += e.type + ' with ' + e.pointerType + '<br/>';
e.target.scrollTo(0, e.target.scrollHeight);
}
lastEvent = e.type;
}
document.querySelector('a').addEventListener('pointerdown', handler);
document.querySelector('a').addEventListener('pointermove', handler);
document.querySelector('a').addEventListener('pointerup', handler);
div {
height: 100vh;
display: flex;
}
a {
height: 60vh;
width: 75vw;
margin: auto;
background-color: red;
display: inline-block;
user-select: none;
touch-action: none;
overflow-y: scroll;
}
<div>
<a href="#"></a>
</div>
如果我按下一个鼠标按钮,按住它一段时间,然后松开它,我得到以下序列:
-
鼠标指针向下
-
鼠标指针
但是,如果我按下鼠标按钮,保持按下并移动鼠标指针,然后释放它,我会得到以下序列:
-
鼠标指针向下
-
鼠标指针移动
问题:pointerup从不开火。
指针
事件,因为如果在
span
或删除
href公司
-
-
-
鼠标指针
此外,它的工作完美无瑕的触摸驱动
PointerEvents
:
-
触摸指针向下
-
指针触摸移动
-
我想有一个聪明的css属性可以设置在元素上禁用它
指针
a { pointer-actions: click; }