Javascript DOM WheelEvent deltaMode Property

Introduction

Return the length unit of the delta values:

View in separate window

<!DOCTYPE html>
<html>
<body onwheel="myFunction(event)">
<p>Scroll this page to see the length unit of the delta values property.</p>
<p id="demo"></p>

<script>
function myFunction(event) {/* w w  w.  j av  a 2 s . c om*/
  var x = event.deltaMode;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The deltaMode property returns a number representing the length unit of the scrolling values:deltaX, deltaY, and deltaZ.

This property is read-only.

The deltaMode property possible values:

  • 0 = pixels
  • 1 = lines
  • 2 = pages



PreviousNext

Related