Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript toggle mousewheel scrolling

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #168204
    Anonymous
    Inactive

    I want to disable mousewheel scrolling when the cursor is over a div, and re-enable mousewheel scrolling when it leaves the div. How can i achieve this?

    #168233
    Alan C
    Participant

    I don’t believe this is possible. You could potentially look into preventing page scrolling period though.

    #168264
    dgriesel
    Participant

    You can, here you go:
    http://codepen.io/anon/pen/iLyqK/

    Whenever the cursor is above the div, that div receives the mousewheel event before the rest of the page. Just preventDefault() and no scrolling will happen.

    Be aware that my code uses the jQuery mousewheel plugin:
    http://raw.githubusercontent.com/brandonaaron/jquery-mousewheel/master/jquery.mousewheel.js

    It can also be done with native JS, but that would be your job to find the neccessary code .

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.