Skip to content

Instantly share code, notes, and snippets.

@noopkat
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noopkat/9442722 to your computer and use it in GitHub Desktop.
Save noopkat/9442722 to your computer and use it in GitHub Desktop.
fullscreen aspect ratio respecting video in reveal.js [hack]
[...]
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