The PDF Embedder plugin allows you to easily embed PDFs in your web pages. When the browser window is resized, PDF Embedder resizes PDFs to fit the new space available to them. However, in the Divi Theme, when a PDF is hidden inside a closed accordion module toggle, it isn't resized when the browser window is resized. Thus when the accordion toggle is opened, the PDF displays at the old, incorrect size.
This can be fixed by adding the following jQuery code to your site:
<script>
/* Fix PDF Embedder not resizing in closed accordions */
jQuery(function($){
$('.et_pb_accordion .et_pb_toggle_title').on('click', function() {
var $toggle = $(this).closest('.et_pb_toggle');
if ($toggle.hasClass('et_pb_toggle_close')) {
setTimeout(
function() {
$toggle.find('.pdfemb-viewer').pdfEmbedder();
},
100
);
}
});
});
</script>
Related Post: Adding JavaScript / jQuery to Divi.
0 Comments