Преглед изворни кода

revised remaining height layout logic

Hakim El Hattab пре 10 година
родитељ
комит
04c4fa49b8
4 измењених фајлова са 40 додато и 7 уклоњено
  1. 5 0
      css/reveal.css
  2. 0 0
      css/reveal.min.css
  3. 34 6
      js/reveal.js
  4. 1 1
      js/reveal.min.js

+ 5 - 0
css/reveal.css

@@ -355,6 +355,11 @@ body {
 	vertical-align: top;
 }
 
+.reveal .remaining-height {
+	max-width: none;
+	max-height: none;
+}
+
 
 /*********************************************
  * CONTROLS

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
css/reveal.min.css


+ 34 - 6
js/reveal.js

@@ -1014,12 +1014,8 @@ var Reveal = (function(){
 			dom.slides.style.width = slideWidth + 'px';
 			dom.slides.style.height = slideHeight + 'px';
 
-			// Handle sizing of elements with the 'remaining-height' class
-			toArray( dom.slides.querySelectorAll( 'section > .remaining-height' ) ).forEach( function( element ) {
-
-				element.style.height = getRemainingHeight( element, ( slideHeight - ( slidePadding * 2 ) ) ) + 'px';
-
-			} );
+			// Layout the contents of the slides
+			layoutSlideContents( config.width, config.height, slidePadding );
 
 			// Determine scale of content to fit within available space
 			scale = Math.min( availableWidth / slideWidth, availableHeight / slideHeight );
@@ -1071,6 +1067,38 @@ var Reveal = (function(){
 
 	}
 
+	/**
+	 * Applies layout logic to the contents of all slides in
+	 * the presentation.
+	 */
+	function layoutSlideContents( width, height, padding ) {
+
+		// Handle sizing of elements with the 'remaining-height' class
+		toArray( dom.slides.querySelectorAll( 'section > .remaining-height' ) ).forEach( function( element ) {
+
+			// Determine how much vertical space we can use
+			var remainingHeight = getRemainingHeight( element, ( height - ( padding * 2 ) ) );
+
+			// Consider the aspect ratio of media elements
+			if( /(img|video)/gi.test( element.nodeName ) ) {
+				var nw = element.naturalWidth,
+					nh = element.naturalHeight;
+
+				var es = Math.min( width / nw, remainingHeight / nh );
+
+				element.style.width = ( nw * es ) + 'px';
+				element.style.height = ( nh * es ) + 'px';
+
+			}
+			else {
+				element.style.width = width + 'px';
+				element.style.height = remainingHeight + 'px';
+			}
+
+		} );
+
+	}
+
 	/**
 	 * Stores the vertical index of a stack so that the same
 	 * vertical slide can be selected when navigating to and

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
js/reveal.min.js


Неке датотеке нису приказане због велике количине промена