wait for document to load before triggering pdf layout
This commit is contained in:
		
							
								
								
									
										20
									
								
								js/reveal.js
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								js/reveal.js
									
									
									
									
									
								
							| @@ -360,12 +360,6 @@ | |||||||
| 		// Update all backgrounds | 		// Update all backgrounds | ||||||
| 		updateBackground( true ); | 		updateBackground( true ); | ||||||
|  |  | ||||||
| 		// Special setup and config is required when printing to PDF |  | ||||||
| 		if( isPrintingPDF() ) { |  | ||||||
| 			removeEventListeners(); |  | ||||||
| 			setupPDF(); |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		// Notify listeners that the presentation is ready but use a 1ms | 		// Notify listeners that the presentation is ready but use a 1ms | ||||||
| 		// timeout to ensure it's not fired synchronously after #initialize() | 		// timeout to ensure it's not fired synchronously after #initialize() | ||||||
| 		setTimeout( function() { | 		setTimeout( function() { | ||||||
| @@ -381,6 +375,20 @@ | |||||||
| 			} ); | 			} ); | ||||||
| 		}, 1 ); | 		}, 1 ); | ||||||
|  |  | ||||||
|  | 		// Special setup and config is required when printing to PDF | ||||||
|  | 		if( isPrintingPDF() ) { | ||||||
|  | 			removeEventListeners(); | ||||||
|  |  | ||||||
|  | 			// The document needs to have loaded for the PDF layout | ||||||
|  | 			// measurements to be accurate | ||||||
|  | 			if( document.readyState === 'complete' ) { | ||||||
|  | 				setupPDF(); | ||||||
|  | 			} | ||||||
|  | 			else { | ||||||
|  | 				window.addEventListener( 'load', setupPDF ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user