0
我正在構建一個網站,其中包含基於縮略圖的導航和大圖像或視頻作爲背景。在這裏看到它http://www.sarahnwatson.com。jQuery視頻onpause播放動畫
現在我擁有它,因此,如果您點擊某個視頻,導航菜單就會動起來,這樣您就可以更好地看到視頻。我希望讓這個在暫停菜單中的動畫方式返回。
下面是代碼
//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':'-300px'},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);
});
想通了。請參閱修訂的代碼 – watzon