Skip to content

Instantly share code, notes, and snippets.

View MikeBiggerstaff's full-sized avatar

Mike Biggerstaff MikeBiggerstaff

View GitHub Profile
@jimjeffers
jimjeffers / html5VideoAspectRatioAdjustment.coffee
Created September 15, 2011 13:24
Breaking the HTML5 Video Aspect Ratio
# 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})")
)