Created
April 22, 2014 15:55
-
-
Save tommymarshall/11184530 to your computer and use it in GitHub Desktop.
Set Video Dimensions
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
setVideoDimensions: function() { | |
var $wrapper = $('.video-wrapper'); | |
var $video = $('.video'); | |
var height = $wrapper.height(); | |
var width = $wrapper.width(); | |
// Maintain 16 / 9 aspect ratio | |
if (width / height > 16 / 9) { | |
newWidth = height / 9 * 16; | |
newHeight = height; | |
} else { | |
newWidth = width; | |
newHeight = width * 9 / 16; | |
} | |
$video.css({ | |
height: newHeight, | |
width: newWidth | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment