开发者

jQuery video onpause play animation

开发者 https://www.devze.com 2023-04-11 12:06 出处:网络
I am building a site that has thumbnail based navigation and a large image or video as the background. See it here http://www.sarahnwatson.com.

I am building a site that has thumbnail based navigation and a large image or video as the background. See it here http://www.sarahnwatson.com.

Right now I have it so that if you click on a video the navigation menu animates out of the way so that you can see the video better. I want to make it so that on pause the menu animates back in.

Here is the code

//clicking on a thumb, replaces the large image or video
                $list.find('.st_thumbs img').bind('click',function(){
                var $this = $(this);
                $loader.show();
                var src = $this.attr('alt');
                if (/\.(mp4|ogv)$/i.test(src)) {
                var $currImage = $('#st_main').children('img,video').first();
                $("<video class='st_preview' controls='controls' id='video' preload='auto'>").attr({ src: src }).insertBefore($currImage);

                $('.st_overlay').hide();
                setTimeout('playVid()', 5000);
                $socialLinks.animate({ 'left': -($socialLinks.width()) }, 500);
                hideThumbs();
                    $("video").bind("play", function() {
                       $list.children().each(function(i,el) { // loop through the LI elements within $list
                            $(el).delay(500*i).animate({'left':'-300开发者_Go百科px'},1000);
                        });
                    });

                    $("video").bind("pause", function() {
                       $list.children().each(function(i,el) { // loop through the LI elements within $list
                            $(el).delay(500*i).animate({'left':'300px'},1000);
                        });
                    });

                $download.fadeOut(1000);
                $currImage.fadeOut(2000,function(){
                    $(this).remove();
                });
            }
                else {
                    $('<img class="st_preview"/>').load(function(){
                        var $this = $(this);
                        var $currImage = $('#st_main').children('img,video').first();
                        $this.insertBefore($currImage);
                        $loader.hide();
                        $('.st_overlay').show();
                        $socialLinks.animate({ 'left': '0px' }, 1000);
                        $download.fadeIn(2500);
                        $currImage.fadeOut(2000,function(){
                            $(this).remove();
                        });
                    }).attr('src',src);
                }
                setTimeout('$("a.st_img_download").attr("href", "image_download.php?image="+$(\'#st_main\').children(\'img:first\').attr("src"))', 500);
                });


if (video.paused) { 
     //show menu
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号