Created
April 6, 2016 19:11
-
-
Save Ravenna/80380c104b0a240f0b16dc28ce0f60a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // BUILD VIDEO SOURCE | |
| var mp4 = $('#home-video-div').attr("data-mpfour"); | |
| var webm = $('#home-video-div').attr("data-webm"); | |
| $('#bgvid').append('<source src="'+ mp4 +'" type="video/mp4"><source src="'+ webm +'" type="video/webm">'); | |
| // SCALE VIDEO SOURCE | |
| $('#home-video-div').delay(200).velocity({ opacity: 1 }, { display: "block" }); | |
| var scale = 1; | |
| var videoRatio = 16 / 9; | |
| var viewportRatio = $(window).width() / $(window).height(); | |
| if (videoRatio < viewportRatio) { | |
| // viewport more widescreen than video aspect ratio | |
| scale = viewportRatio / videoRatio; | |
| } else if (viewportRatio < videoRatio) { | |
| // viewport more square than video aspect ratio | |
| scale = videoRatio / viewportRatio; | |
| } | |
| $('#bgvid').velocity({ | |
| scaleX: scale, | |
| scaleY: scale | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment