Forked from jimjeffers/html5VideoAspectRatioAdjustment.coffee
Created
June 5, 2012 19:04
-
-
Save basz/2877030 to your computer and use it in GitHub Desktop.
Breaking the HTML5 Video Aspect Ratio
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
# Just an example. | |
# @video is a direct reference to a '<video>' element. | |
# $() is assuming jQuery is being used in this example. | |
@video.addEventListener("loadedmetadata", (event) => | |
actualRatio = @video.videoWidth/@video.videoHeight | |
targetRatio = $(@video).width()/$(@video).height() | |
adjustmentRatio = targetRatio/actualRatio | |
$(@video).css("-webkit-transform","scaleX(#{adjustmentRatio})") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment