Last active
June 30, 2022 02:09
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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