欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)帶滾動(dòng)導(dǎo)航效果的全屏滾動(dòng)相冊(cè)實(shí)例

 更新時(shí)間:2015年06月19日 15:37:58   作者:任意球  
這篇文章主要介紹了jQuery實(shí)現(xiàn)帶滾動(dòng)導(dǎo)航效果的全屏滾動(dòng)相冊(cè),涉及jQuery針對(duì)頁(yè)面圖片元素與鼠標(biāo)事件的相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)帶滾動(dòng)導(dǎo)航效果的全屏滾動(dòng)相冊(cè)。分享給大家供大家參考。具體如下:

運(yùn)行效果圖如下:

主要代碼如下:

$(function() {
//加載時(shí)的圖片
var $loader= $('#st_loading');
//獲取的ul元素
var $list= $('#st_nav');
//當(dāng)前顯示的圖片
var $currImage = $('#st_main').children('img:first');
//加載當(dāng)前的圖片
//同時(shí)顯示導(dǎo)航的項(xiàng)
$('<img>').load(function(){
$loader.hide();
$currImage.fadeIn(3000);
//滑出導(dǎo)航
setTimeout(function(){
$list.animate({'left':'0px'},500);
},
1000);
}).attr('src',$currImage.attr('src'));
//計(jì)算出將被顯示的略縮圖所在的div元素的寬度
buildThumbs();
function buildThumbs(){
$list.children('li.album').each(function(){
var $elem = $(this);
var $thumbs_wrapper = $elem.find('.st_thumbs_wrapper');
var $thumbs = $thumbs_wrapper.children(':first');
//每張略縮圖占有180像素的寬度和3像素的間距(margin)
var finalW = $thumbs.find('img').length * 183;
$thumbs.css('width',finalW + 'px');
//是這元素具有滾動(dòng)性
makeScrollable($thumbs_wrapper,$thumbs);
});
}
//點(diǎn)擊菜單項(xiàng)目的時(shí)候(向上向下箭頭切換)
//使略縮圖的div層顯示和隱藏當(dāng)前的
//打開菜單(如果有的話)
$list.find('.st_arrow_down').live('click',function(){
var $this = $(this);
hideThumbs();
$this.addClass('st_arrow_up').removeClass('st_arrow_down');
var $elem = $this.closest('li');
$elem.addClass('current').animate({'height':'170px'},200);
var $thumbs_wrapper = $this.parent().next();
$thumbs_wrapper.show(200);
});
$list.find('.st_arrow_up').live('click',function(){
var $this = $(this);
$this.addClass('st_arrow_down').removeClass('st_arrow_up');
hideThumbs();
});
//點(diǎn)擊略縮圖,改變大的圖片
$list.find('.st_thumbs img').bind('click',function(){
var $this = $(this);
$loader.show();
$('<img class="st_preview"/>').load(function(){
var $this = $(this);
var $currImage = $('#st_main').children('img:first');
$this.insertBefore($currImage);
$loader.hide();
$currImage.fadeOut(2000,function(){
$(this).remove();
});
}).attr('src',$this.attr('alt'));
}).bind('mouseenter',function(){
$(this).stop().animate({'opacity':'1'});
}).bind('mouseleave',function(){
$(this).stop().animate({'opacity':'0.7'});
});
//隱藏當(dāng)前已經(jīng)打開了的菜單的函數(shù)
function hideThumbs(){
$list.find('li.current')
 .animate({'height':'50px'},400,function(){
$(this).removeClass('current');
 })
 .find('.st_thumbs_wrapper')
 .hide(200)
 .andSelf()
 .find('.st_link span')
 .addClass('st_arrow_down')
 .removeClass('st_arrow_up');
}
//是當(dāng)前的略縮圖div層滾動(dòng)
//當(dāng)鼠標(biāo)移至菜單層的時(shí)候會(huì)自動(dòng)地進(jìn)行滾動(dòng)
function makeScrollable($outer, $inner){
var extra = 800;
//獲取菜單的寬度
var divWidth = $outer.width();
//移除滾動(dòng)條
$outer.css({
overflow: 'hidden'
});
//查找容器上的最后一張圖片
var lastElem = $inner.find('img:last');
$outer.scrollLeft(0);
//當(dāng)用戶鼠標(biāo)離開菜單的時(shí)候
$outer.unbind('mousemove').bind('mousemove',function(e){
var containerWidth = lastElem[0].offsetLeft + lastElem.outerWidth() + 2*extra;
var left = (e.pageX - $outer.offset().left) * (containerWidth-divWidth) / divWidth - extra;
$outer.scrollLeft(left);
});
}
});

希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論