I'm using Featherlight as a lightbox. One problem I have is that went it opens, the background remains scrollable. A fix that most lightboxes need is adding a class to the body with overflow:hidden; on it.
How can I do that on open of the lightbox, then remove the class on close?
You can use the options on your plugin call by using of the beforeOpen and afterClose options like:
$.featherlight({
beforeOpen: function() {
document.body.style.overflow = 'hidden';
},
afterEnd: function() {
document.body.style.overflow = '';
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With