This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

deltaMode

Summary

Gets a value that indicates the unit of measurement for delta values.

Property of dom/WheelEventdom/WheelEvent

Syntax

Note: This property is read-only.

var deltaMode = event.deltaMode;

Return Value

Returns an object of type NumberNumber

One of the following values -

  • WheelEvent.DOM_DELTA_PIXEL, or 0x00 (hex), or 0. The delta coordinates are pixel based (most common).
  • WheelEvent.DOM_DELTA_LINE, or 0x01 (hex), or 1. The delta coordinates are line based (in form controls, for example).
  • WheelEvent.DOM_DELTA_PAGE, or 0x02 (hex), or 2. The delta coordinates are page based.

Examples

The following example shows how to determine the deltaMode property of the WheelEvent. Note: to feature test for deltaMode you need to use the ‘deltaMode’ in event as 0 (false) is a valid WheelEvent constant.

<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>

Related specifications

DOM Level 3 Events
Working Draft

Attributions