--- title: MouseEvent.movementX slug: Web/API/MouseEvent/movementX translation_of: Web/API/MouseEvent/movementX ---

{{APIRef("DOM Events")}}

 MouseEvent.movementX 是只读属性,它提供了当前事件和上一个{{event("mousemove")}}事件之间鼠标在水平方向上的移动值。换句话说,这个值是这样计算的 : currentEvent.movementX = currentEvent.screenX - previousEvent.screenX.

语法

var xShift = instanceOfMouseEvent.movementX

返回值

一个数字

规范

Specification Status Comment
{{SpecName('Pointer Lock','#widl-MouseEvent-movementX','MouseEvent.movementX')}} {{Spec2('Pointer Lock')}} Initial definition

浏览器兼容性

{{ CompatibilityTable() }}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatChrome(22.0)}} {{property_prefix("webkit")}}
{{CompatChrome(37.0)}} unprefixed
{{CompatVersionUnknown}}

{{CompatGeckoDesktop(1.0)}} {{property_prefix("moz")}}
{{CompatGeckoDesktop(41)}}

{{ CompatNo() }} {{ CompatUnknown() }} {{ CompatNo() }}
Feature Android Webview Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatChrome(37)}} {{CompatVersionUnknown}} {{CompatGeckoMobile(1.0)}} {{property_prefix("moz")}}
{{CompatGeckoMobile(41)}}
{{ CompatNo() }} {{ CompatUnknown() }} {{ CompatNo() }} {{CompatVersionUnknown}} {{property_prefix("webkit")}}
{{CompatChrome(37.0)}} unprefixed

相关