HTML | DOM WheelEvent deltaY Property

The WheelEvent.deltaY property in HTML is used to return a positive double value when the web page is scrolled down, and a negative double value when the page is scrolled up, else it returns zero. It is a read-only property

Syntax:

event.deltaY

Return Value: It returns a double value which indicates the scrolling direction of the mouse wheel.



  • A positive double value represents mouse is scrolled down.
  • A negative double value represents mouse is scrolled up.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>DOM WheelEvent deltaY Property</title>
    </head>
      
    <body onwheel="Geeks(event)" 
          style="text-align:center; height: 5000px;">
      
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
      
    <h2>
        DOM WheelEvent deltaY Property
    </h2>
      
    <p>Scroll to see effect:</p>
      
    <p id="p"></p>
      
    <script>
        function Geeks(event) {
            var doc = event.deltaY;
            document.getElementById("p").innerHTML = doc;
        }
    </script>
      
    </body>
</html>                    

chevron_right


Output:
deltaY

Supported Browsers: The browser supported by deltaY property are listed below:

  • Apple Safari Not supported
  • Google Chrome 31.0
  • Firefox 17.0
  • Opera 18.0
  • Internet Explorer


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.