How do I create a fixed div with overflow: scroll
in such a way that body
won't scroll when hovering over the div and scrolling? Sort of like the fixed chat boxes at the bottom of the window on facebook.com.
I've tried using javascript to capture and stop the scroll
, wheel
and touchmove
events from bubbeling up with stopPropagation()
, but it doesn't seem to work.
I've simplified the problem as much as I can here: https://jsfiddle.net/m9uamaza/
The goal is to scroll up and down in the fixed "bar" div without the "foo" body moving. If the "bar" div is scrolled all the way to the bottom, and I keep scrolling, I don't want the body to start scrolling. The body should still be scrollable when the mouse is not over the fixed div.