Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active June 30, 2022 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/5b9a5d0de2860e7816e19ce54f16945b to your computer and use it in GitHub Desktop.
Save wplit/5b9a5d0de2860e7816e19ce54f16945b to your computer and use it in GitHub Desktop.
Prevent scrollbar removal from moving content when lightbox opens (code for testing across different browsers)
jQuery(document).ready(function($) {
let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
$(document).on('afterLoad.fb', function( e, instance, slide ) {
$('head').append('<style id="extras-style-noscroll" type="text/css">.compensate-for-scrollbar{margin-right:' + scrollbarWidth + 'px!important;}</style>')
});
$(document).on('afterClose.fb', function( e, instance, slide ) {
$('head #extras-style-noscroll').remove();
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment