aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2014-03-25 21:16:58 +0100
committerHakim El Hattab <hakim.elhattab@gmail.com>2014-03-25 21:16:58 +0100
commiteef1636fd712cb581a4c2280810255e284404e98 (patch)
treeb96440111d1889de0fec08b06462f7002ece8d8c /js
parenta9c2d4d6635462e40d6446d1be465ae0c2fdbd7f (diff)
parent1a7732c235df0076dd77bc396266e7c94c024040 (diff)
downloadfosdem-2018-presentation-eef1636fd712cb581a4c2280810255e284404e98.tar
fosdem-2018-presentation-eef1636fd712cb581a4c2280810255e284404e98.tar.gz
Merge branch 'dev' of https://github.com/xdhmoore/reveal.js into dev
Diffstat (limited to 'js')
-rw-r--r--js/reveal.js36
1 files changed, 11 insertions, 25 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 7e77079..ffcb489 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -838,40 +838,26 @@ var Reveal = (function(){
/**
* Returns the remaining height within the parent of the
- * target element after subtracting the height of all
- * siblings.
+ * target element.
*
- * remaining height = [parent height] - [ siblings height]
+ * remaining height = [ configured parent height ] - [ current parent height ]
*/
function getRemainingHeight( element, height ) {
height = height || 0;
if( element ) {
- var parent = element.parentNode;
- var siblings = parent.childNodes;
+ var newHeight, oldHeight = element.style.height;
- // Subtract the height of each sibling
- toArray( siblings ).forEach( function( sibling ) {
+ // Change the .stretch element height to 0 in order find the height of all
+ // the other elements
+ element.style.height = '0px';
+ newHeight = height - element.parentNode.offsetHeight;
- if( typeof sibling.offsetHeight === 'number' && sibling !== element ) {
-
- var styles = window.getComputedStyle( sibling ),
- marginTop = parseInt( styles.marginTop, 10 ),
- marginBottom = parseInt( styles.marginBottom, 10 );
-
- height -= sibling.offsetHeight + marginTop + marginBottom;
-
- }
-
- } );
-
- var elementStyles = window.getComputedStyle( element );
-
- // Subtract the margins of the target element
- height -= parseInt( elementStyles.marginTop, 10 ) +
- parseInt( elementStyles.marginBottom, 10 );
+ // Restore the old height, just in case
+ element.style.height = oldHeight + 'px';
+ return newHeight;
}
return height;
@@ -1151,7 +1137,7 @@ var Reveal = (function(){
toArray( dom.slides.querySelectorAll( 'section > .stretch' ) ).forEach( function( element ) {
// Determine how much vertical space we can use
- var remainingHeight = getRemainingHeight( element, ( height - ( padding * 2 ) ) );
+ var remainingHeight = getRemainingHeight( element, height );
// Consider the aspect ratio of media elements
if( /(img|video)/gi.test( element.nodeName ) ) {