Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function(){
- $(document).ready(function(){
- controlIntroVideo.init();
- });
- controlIntroVideo = {
- /**
- * Constructor
- */
- init : function(){
- var t = this; // This object
- t.video = $('#intro-video'); // The intro video element
- t.expanded = false; // Whether or not the intro video is currently expanded
- t._create_events();
- }, // init
- /**
- * Create the events necessary for proper interaction with the intro video
- */
- _create_events : function(){
- var t = this; // This object
- t.video.on('play', function(){
- t.play_video();
- });
- t.video.on('pause', function(){
- t.pause_video();
- });
- t.video.on('ended', function(){
- t.video_ended();
- });
- }, // create_events
- /**
- * Play the intro video
- */
- play_video : function(){
- var t = this; // This object
- /** Animate the expansion the video to the full width of the page, adding the border specifed above at the same time */
- if(!t.expanded){
- /** Set the border ready for video expansion */
- t.video.css({
- border: '0 solid #FFFFFF',
- });
- /** Pause the video during expansion */
- t.video[0].pause();
- /** Animate the expansion of the intro video */
- t.video.animate({
- borderRightWidth: '90px',
- borderBottomWidth: '10px',
- borderLeftWidth: '90px',
- height: '405', // 495 477 459 405
- width: '720' // 880 848 816 720
- }, 1000, function(){ // On completion of the animation
- t.expanded = true; // Set 'expanded' to true
- t.video[0].play(); //Play the Video
- });
- }
- }, // play_video
- /**
- * Pause the intro video
- */
- pause_video : function(){
- var t = this; // This object
- /** Only run animate the reduction of the video if it is not already expanded */
- if(t.expanded){
- t.expanded = false; // Set 'expanded' to false
- /** Animate the reduction of the intro video */
- t.video.animate({
- borderWidth: '0',
- height: '200',
- width: '356'
- }, 1000);
- }
- }, // pause_video
- /**
- * Reset the intro video when it has ended
- */
- video_ended : function(){
- var t = this; // This object
- setTimeout(function(){
- t.video[0].load();
- t.pause_video();
- }, 2000);
- } // video_ended
- } // controlIntroVideo
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement