简体   繁体   English

JavaScript MouseMove 事件属性

[英]JavaScript MouseMove Event properties

I read the Mozilla documentation page about the MouseMove Event.我阅读了有关MouseMove事件的 Mozilla 文档页面。
And in the properties table there are 2 properties that I do not understand how they work.在属性表中,有 2 个属性我不明白它们是如何工作的。

The details property which by description is: "A count of consecutive clicks that happened in a short amount of time, incremented by one."根据描述,详细信息属性是:“在短时间内发生的连续点击次数,增加一。”

What dose Mozilla consider consecutive, how long is the time between the clicks to insure the count. Mozilla 考虑连续的剂量,点击之间的时间是多长时间以确保计数。 Can I configure it to be shorter or longer time period?我可以将其配置为更短或更长的时间段吗?

The buttons property, which stats the description with: "The buttons depressed when the mouse event was fired".按钮属性,它用以下方式统计描述:“触发鼠标事件时按下的按钮”。

What is a depressed button?什么是按下按钮? Is it the button state at the mouseup event?它是 mouseup 事件中的按钮状态吗?
This is no mention of this phase or state in the mouseup event nor in the mousedown event So what is it?这在mouseup 事件mousedown 事件中都没有提到这个阶段或状态 那么它是什么?

The details property give the click count in a short amount of time. details属性会在短时间内给出点击次数。 The "short amount time" is the duration for a double click to be a valid input. “短时间”是双击成为有效输入的持续时间。 In your particular case when you move your mouse over an element you will get a series of mousemove events fired however the mousemove event disregards the details property.. i guess moving the mouse and clicking doesn't make much sense.在您的特定情况下,当您将鼠标移到一个元素上时,您将触发一系列mousemove事件,但是mousemove事件忽略 details 属性..我想移动鼠标和点击没有多大意义。 If you try it with click event you will notice how it works.如果您尝试使用click事件,您会注意到它是如何工作的。

 md.addEventListener("click", e => console.log(e.detail));
 #md { width: 300px; height: 200px; text-align: center; background-color: thistle; }
 <div id="md">Click</div>

it will count your clicks until the tiny duration for a double click is sensed.它会计算您的点击次数,直到感应到双击的微小持续时间。 I guess you may change this time from your operating system mouse interface.我猜您这次可能会从您的操作系统鼠标界面中更改。

buttons property is very clearly explained in MDN as;按钮属性在 MDN 中非常清楚地解释为;

The buttons depressed when the mouse event was fired: Left button=1, Right button=2, Middle (wheel) button=4, 4th button (typically, "Browser Back" button)=8, 5th button (typically, "Browser Forward" button)=16.鼠标事件触发时按下的按钮:左按钮=1,右按钮=2,中间(滚轮)按钮=4,第 4 个按钮(通常为“浏览器后退”按钮)=8,第 5 个按钮(通常为“浏览器前进”) "按钮)=16。 If two or more buttons are depressed, returns the logical sum of the values.如果按下两个或更多按钮,则返回值的逻辑总和。 Eg, if Left button and Right button are depressed, returns 3.例如,如果左键和右键被按下,则返回 3。

It gives you which button(s) is pressed when you have your particular mouse event fired.当您触发特定的鼠标事件时,它会为您提供按下的按钮。 This time it makes sense with the mousemove event since it gives you the button numbers as said in the MDN above description.这次它对mousemove事件有意义,因为它为您提供了上面 MDN 描述中所述的按钮编号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM