I'm using simple modal. Is there any way to keep the background (behind the overlay) from scrolling when you roll the mouse wheel while outside the boundaries of the modal?
Thanks!
I'm using simple modal. Is there any way to keep the background (behind the overlay) from scrolling when you roll the mouse wheel while outside the boundaries of the modal?
Thanks!
While creating the modal, set overflow:hidden
for body. Then you will not be able to scroll the background and when hiding the modal, set overflow:auto
for body
.
I think you can do this:
$(document).on('mousewheel', '.simplemodal-overlay, .simplemodal-data', function(event) {
event.preventDefault();
});
I'm not sure if mousewheel
has full cross-browser support, though.
Edit: I verified this works, but you need the mousewheel
plugin: https://github.com/brandonaaron/jquery-mousewheel/downloads
Example: http://jsfiddle.net/jtbowden/AhpLc/
(I pasted jquery.mousewheel.min.js
into the script area... Don't do that)