srikat

Untitled

Mar 16th, 2016
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. //jQuery is required to run this code
  2. // $( document ).ready(function() {
  3. // jQuery(document).ready(function($) {
  4. jQuery(function( $ ){
  5.  
  6. scaleVideoContainer();
  7.  
  8. initBannerVideoSize('.video-container .poster img');
  9. initBannerVideoSize('.video-container .filter');
  10. initBannerVideoSize('.video-container video');
  11.  
  12. $(window).on('resize', function() {
  13. scaleVideoContainer();
  14. scaleBannerVideoSize('.video-container .poster img');
  15. scaleBannerVideoSize('.video-container .filter');
  16. scaleBannerVideoSize('.video-container video');
  17. });
  18.  
  19. });
  20.  
  21. function scaleVideoContainer() {
  22.  
  23. var height = $(window).height() + 5;
  24. var unitHeight = parseInt(height) + 'px';
  25. $('.homepage-hero-module').css('height',unitHeight);
  26.  
  27. }
  28.  
  29. function initBannerVideoSize(element){
  30.  
  31. $(element).each(function(){
  32. $(this).data('height', $(this).height());
  33. $(this).data('width', $(this).width());
  34. });
  35.  
  36. scaleBannerVideoSize(element);
  37.  
  38. }
  39.  
  40. function scaleBannerVideoSize(element){
  41.  
  42. var windowWidth = $(window).width(),
  43. windowHeight = $(window).height() + 5,
  44. videoWidth,
  45. videoHeight;
  46.  
  47. console.log(windowHeight);
  48.  
  49. $(element).each(function(){
  50. var videoAspectRatio = $(this).data('height')/$(this).data('width');
  51.  
  52. $(this).width(windowWidth);
  53.  
  54. if(windowWidth < 1000){
  55. videoHeight = windowHeight;
  56. videoWidth = videoHeight / videoAspectRatio;
  57. $(this).css({'margin-top' : 0, 'margin-left' : -(videoWidth - windowWidth) / 2 + 'px'});
  58.  
  59. $(this).width(videoWidth).height(videoHeight);
  60. }
  61.  
  62. $('.homepage-hero-module .video-container video').addClass('fadeIn animated');
  63.  
  64. });
  65. }
Advertisement
Add Comment
Please, Sign In to add comment