Browse Source

revised remaining height layout logic

embed
Hakim El Hattab 11 years ago
parent
commit
04c4fa49b8
  1. 5
      css/reveal.css
  2. 2
      css/reveal.min.css
  3. 40
      js/reveal.js
  4. 4
      js/reveal.min.js

5
css/reveal.css

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

2
css/reveal.min.css

File diff suppressed because one or more lines are too long

40
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

4
js/reveal.min.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save