Forráskód Böngészése

optimize use of getSlideBackground by avoiding index lookup

Hakim El Hattab 7 éve
szülő
commit
a0a9aa7821
1 módosított fájl, 5 hozzáadás és 6 törlés
  1. 5 6
      js/reveal.js

+ 5 - 6
js/reveal.js

@@ -3200,8 +3200,7 @@
 
 
 		// Show the corresponding background element
-		var indices = getIndices( slide );
-		var background = getSlideBackground( indices.h, indices.v );
+		var background = getSlideBackground( slide );
 		if( background ) {
 			background.style.display = 'block';
 
@@ -3288,8 +3287,7 @@
 		slide.style.display = 'none';
 
 		// Hide the corresponding background element
-		var indices = getIndices( slide );
-		var background = getSlideBackground( indices.h, indices.v );
+		var background = getSlideBackground( slide );
 		if( background ) {
 			background.style.display = 'none';
 		}
@@ -3858,13 +3856,14 @@
 	 * defined, have a background element so as long as the
 	 * index is valid an element will be returned.
 	 *
-	 * @param {number} x Horizontal background index
+	 * @param {mixed} x Horizontal background index OR a slide
+	 * HTML element
 	 * @param {number} y Vertical background index
 	 * @return {(HTMLElement[]|*)}
 	 */
 	function getSlideBackground( x, y ) {
 
-		var slide = getSlide( x, y );
+		var slide = typeof x === 'number' ? getSlide( x, y ) : x;
 		if( slide ) {
 			return slide.slideBackgroundElement;
 		}