deltaX
Summary
Gets the distance that a mouse wheel has rotated around the x-axis (horizontal).
Property of dom/WheelEventdom/WheelEvent
Syntax
Note: This property is read-only.
var deltaX = event.deltaX;
Return Value
Returns an object of type NumberNumber
The X rotation distance in pixels, lines or pages.
Examples
The following example shows how to determine the deltaX property of the WheelEvent. Note: to feature test for deltaX you need to use the ‘deltaX’ in event as deltaX may have a value of 0 (false)… (event.deltaX) can return false negatives.
<script type="text/javascript">
function getDeltaMode(dMode){
switch (dMode){
case WheelEvent.DOM_DELTA_LINE:// 1
return 'DOM_DELTA_LINE (1)';
case WheelEvent.DOM_DELTA_PAGE:// 2
return 'DOM_DELTA_PAGE (2)';
case WheelEvent.DOM_DELTA_PIXEL:// 0
return 'DOM_DELTA_PIXEL (0)';
default:
return 'Unknown DeltaMode:' + dMode;
}
}
function showWheelEvent(evt){
if(!evt)evt=window.event;
theform=document.forms.frmEvent;
if(evt.type=='wheel'){
theform.deltamode.value=('deltaMode' in evt)?getDeltaMode(evt.deltaMode):'N/A';
theform.deltax.value=('deltaX' in evt)?evt.deltaX:'N/A';
theform.deltay.value=('deltaY' in evt)?evt.deltaY:'N/A';
theform.deltaz.value=('deltaZ' in evt)?evt.deltaZ:'N/A';
}
}
</script>
Notes
The measurement of the distance can be determined using the deltaMode property.
Related specifications
- DOM Level 3 Events
- Working Draft
Attributions
Mozilla Developer Network : [WheelEvent Article]
Microsoft Developer Network: [deltaX Property Article]