Fix PDF Embedder not Resized in Closed Accordions

|

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>

This post may contain referral links which may earn a commission for this site

Divi Booster

Hundreds of new features for Divi
in one easy-to-use plugin

0 Comments

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.