Last active
August 29, 2015 13:57
-
-
Save noopkat/9442722 to your computer and use it in GitHub Desktop.
fullscreen aspect ratio respecting video in reveal.js [hack]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
function startEmbeddedContent( slide ) { | |
[...] | |
if( el.hasAttribute( 'data-autoplay' ) ) { | |
// paste this above el.play() | |
var nw = el.videoWidth, | |
nh = el.videoHeight, | |
es = Math.min(nh / nw), | |
elheight = Math.floor(document.documentElement.clientWidth * es), | |
videoPosX = 0 - el.parentNode.parentNode.offsetLeft, | |
videoPosY = (0 - el.parentNode.parentNode.offsetTop) + Math.floor((document.documentElement.clientHeight - elheight) / 2); | |
el.parentNode.setAttribute('style', 'top:0px; left:0px;'); | |
el.setAttribute('style', 'max-height:5000px; max-width:5000px; position:absolute; top:' + videoPosY + 'px; left:' + videoPosX + 'px; width:' + document.documentElement.clientWidth + 'px; height:' + elheight + 'px;'); | |
// end paste | |
el.play(); | |
} | |
[...] | |
function stopEmbeddedContent( slide ) { | |
[...] | |
if( !el.hasAttribute( 'data-ignore' ) ) { | |
// paste line below above el.pause | |
el.style.display = 'none'; | |
// end paste | |
el.pause(); | |
} | |
[...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment