Simple modal no scroll background <body>

I use simple modal . Is there a way to keep the background (overlay) from scrolling when you roll the mouse wheel while outside the borders of the modal?

Thanks!

+4
source share
2 answers

When creating an overflow:hidden modal set for the body. Then you will not be able to scroll the background and hide the modal, set overflow:auto to body .

+4
source

I think you can do this:

 $(document).on('mousewheel', '.simplemodal-overlay, .simplemodal-data', function(event) { event.preventDefault(); }); 

I'm not sure mousewheel has full cross-browser support.

Edit: I checked this, but you need the mousewheel plugin: https://github.com/brandonaaron/jquery-mousewheel/downloads p>

Example: http://jsfiddle.net/jtbowden/AhpLc/

(I inserted jquery.mousewheel.min.js into the script scope ... Don't do this)

+1
source

Source: https://habr.com/ru/post/1400640/


All Articles