make it possible to load/unload slides via the api
This commit is contained in:
		
							
								
								
									
										31
									
								
								js/reveal.js
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								js/reveal.js
									
									
									
									
									
								
							| @@ -2748,10 +2748,10 @@ | |||||||
|  |  | ||||||
| 				// Show the horizontal slide if it's within the view distance | 				// Show the horizontal slide if it's within the view distance | ||||||
| 				if( distanceX < viewDistance ) { | 				if( distanceX < viewDistance ) { | ||||||
| 					showSlide( horizontalSlide ); | 					loadSlide( horizontalSlide ); | ||||||
| 				} | 				} | ||||||
| 				else { | 				else { | ||||||
| 					hideSlide( horizontalSlide ); | 					unloadSlide( horizontalSlide ); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				if( verticalSlidesLength ) { | 				if( verticalSlidesLength ) { | ||||||
| @@ -2764,10 +2764,10 @@ | |||||||
| 						distanceY = x === ( indexh || 0 ) ? Math.abs( ( indexv || 0 ) - y ) : Math.abs( y - oy ); | 						distanceY = x === ( indexh || 0 ) ? Math.abs( ( indexv || 0 ) - y ) : Math.abs( y - oy ); | ||||||
|  |  | ||||||
| 						if( distanceX + distanceY < viewDistance ) { | 						if( distanceX + distanceY < viewDistance ) { | ||||||
| 							showSlide( verticalSlide ); | 							loadSlide( verticalSlide ); | ||||||
| 						} | 						} | ||||||
| 						else { | 						else { | ||||||
| 							hideSlide( verticalSlide ); | 							unloadSlide( verticalSlide ); | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
|  |  | ||||||
| @@ -3166,14 +3166,9 @@ | |||||||
| 	 * | 	 * | ||||||
| 	 * @param {HTMLElement} slide Slide to show | 	 * @param {HTMLElement} slide Slide to show | ||||||
| 	 */ | 	 */ | ||||||
| 	/** | 	function loadSlide( slide, options ) { | ||||||
| 	 * Called when the given slide is within the configured view |  | ||||||
| 	 * distance. Shows the slide element and loads any content | 		options = options || {}; | ||||||
| 	 * that is set to load lazily (data-src). |  | ||||||
| 	 * |  | ||||||
| 	 * @param {HTMLElement} slide Slide to show |  | ||||||
| 	 */ |  | ||||||
| 	function showSlide( slide ) { |  | ||||||
|  |  | ||||||
| 		// Show the slide element | 		// Show the slide element | ||||||
| 		slide.style.display = config.display; | 		slide.style.display = config.display; | ||||||
| @@ -3253,7 +3248,7 @@ | |||||||
| 					background.appendChild( video ); | 					background.appendChild( video ); | ||||||
| 				} | 				} | ||||||
| 				// Iframes | 				// Iframes | ||||||
| 				else if( backgroundIframe ) { | 				else if( backgroundIframe && options.excludeIframes !== true ) { | ||||||
| 					var iframe = document.createElement( 'iframe' ); | 					var iframe = document.createElement( 'iframe' ); | ||||||
| 					iframe.setAttribute( 'allowfullscreen', '' ); | 					iframe.setAttribute( 'allowfullscreen', '' ); | ||||||
| 					iframe.setAttribute( 'mozallowfullscreen', '' ); | 					iframe.setAttribute( 'mozallowfullscreen', '' ); | ||||||
| @@ -3282,12 +3277,12 @@ | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Called when the given slide is moved outside of the | 	 * Unloads and hides the given slide. This is called when the | ||||||
| 	 * configured view distance. | 	 * slide is moved outside of the configured view distance. | ||||||
| 	 * | 	 * | ||||||
| 	 * @param {HTMLElement} slide | 	 * @param {HTMLElement} slide | ||||||
| 	 */ | 	 */ | ||||||
| 	function hideSlide( slide ) { | 	function unloadSlide( slide ) { | ||||||
|  |  | ||||||
| 		// Hide the slide element | 		// Hide the slide element | ||||||
| 		slide.style.display = 'none'; | 		slide.style.display = 'none'; | ||||||
| @@ -5117,6 +5112,10 @@ | |||||||
| 		isAutoSliding: isAutoSliding, | 		isAutoSliding: isAutoSliding, | ||||||
| 		isSpeakerNotes: isSpeakerNotes, | 		isSpeakerNotes: isSpeakerNotes, | ||||||
|  |  | ||||||
|  | 		// Slide preloading | ||||||
|  | 		loadSlide: loadSlide, | ||||||
|  | 		unloadSlide: unloadSlide, | ||||||
|  |  | ||||||
| 		// Adds or removes all internal event listeners (such as keyboard) | 		// Adds or removes all internal event listeners (such as keyboard) | ||||||
| 		addEventListeners: addEventListeners, | 		addEventListeners: addEventListeners, | ||||||
| 		removeEventListeners: removeEventListeners, | 		removeEventListeners: removeEventListeners, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user