I have been searching google for a solution to this, but I am having trouble finding something that works.
I simply want to be able to scroll the contents of a div (with no scrollbar) using the mouse wheel. The div should only scroll if the cursor is over the div when the wheel is moved.
Does anyone know where to find a good working solution to this?
Since moving the wheel scrolls the whole web page your div will not be under the mouse cursor for long.
Where the browser interprets input for its own use (as it does with shortcut keys and the mouse wheel) those commands never reach the web page for JavaScript to see them.
Generally if you click on a scrollable div, you can use the mouse wheel to scroll through its contents, without scrolling the entire page.
Perhaps there is a way to set the focus on a div by clicking it, or better yet, by simply hovering over it?
I have seen working examples of divs using custom scrollbars based on javascript. The mouse wheel on these divs works just as it would normally.
Here is one example:
Update:
I tried using this site as a reference:
I couldn’t get it to work right, but it does succeed at NOT scrolling the entire page while the cursor is over the div.