Javascript DOM WheelEvent deltaY Property

Introduction

Return whether the user scrolls up or down:

View in separate window

<!DOCTYPE html>
<html>
<body onwheel="myFunction(event)">

<p>Scroll this page to see the value of the deltaY property.</p>

<p id="demo"></p>

<script>
function myFunction(event) {//from ww w.  ja  v  a 2 s . c  o  m
  var y = event.deltaY;
  document.getElementById("demo").innerHTML = y;
}
</script>

</body>
</html>

The deltaY property returns a Double indicating the scrolling direction of the mouse wheel.

The deltaY property returns a positive value when scrolling down, and a negative value when scrolling up, otherwise 0.

This property is read-only.




PreviousNext

Related