成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

網(wǎng)站制作之使用swiper插件做多組合輪播

2023-03-14    分類(lèi): 網(wǎng)站建設(shè)

近期在網(wǎng)站開(kāi)發(fā)過(guò)程中遇到了一個(gè)需要組合輪播圖片的頁(yè)面,頁(yè)面布局如下:

先來(lái)講一下具體功能是:點(diǎn)擊左側(cè)“公司資質(zhì)”或者“產(chǎn)品證書(shū)”,右邊切換到相應(yīng)的輪播模塊。中間的圖片可以左右拖動(dòng)切換,同時(shí)帶動(dòng)右邊名稱(chēng)的選中狀態(tài)切換,右邊的名稱(chēng)點(diǎn)擊能切換中間的圖片,使對(duì)應(yīng)的圖片能居中放大顯示,也是就是中間的當(dāng)前圖片與右邊的名稱(chēng)是一一對(duì)應(yīng)的。
下面再來(lái)講一下頁(yè)面布局結(jié)構(gòu)如下:

honor
榮譽(yù)資質(zhì)
5
公司資質(zhì)
16
產(chǎn)品證書(shū)

高新技術(shù)企業(yè)證書(shū)

高新技術(shù)企業(yè)
data-delay=".2" data-effect="fadeInUpSmall">

醫(yī)療器械注冊(cè)證(NGS10基因)
data-delay=".2" data-effect="fadeInRight">

醫(yī)療器械注冊(cè)證(NGS10基因)

除了以上的html代碼外,實(shí)現(xiàn)上述的功能還需要下面的js代碼,這些代碼看起來(lái)雖然比較復(fù)雜,但使用方法卻是比較傻瓜式,直接粘貼到頁(yè)面上就可以用,所以看不懂以下的JS代碼也沒(méi)關(guān)系,但對(duì)于一些關(guān)鍵的類(lèi)名,例如上面的html代碼寫(xiě)的hon_con_box1,hon_name_box1,swip_tab2等類(lèi)名還是要跟JS代碼對(duì)應(yīng)起來(lái),不然就實(shí)現(xiàn)不了多組合輪播功能,JS代碼如下:
if($("body").hasClass("swip_box")){
//資質(zhì)榮譽(yù)
if ($(".imgbox2").hasClass("swip_tab2")){
var sib,sib2,sib3;
if (wind_w > 780){
sib = "vertical";
sib2 = 4;
sib3 = false;
} else {
sib = "horizontal";
sib2 = "auto";
sib3 = true;
}
var serSwiper1 = new Swiper('.hon_con_box1 .swiper-container', {
slideActiveClass: 'active',
speed: 1000,
spaceBetween: 10,
autoplayDisableOnInteraction : false,
autoplay: {
delay: 5000,
stopOnLastSlide: false,
disableOnInteraction: false,
},
on: {
progress: function(progress) {
var i;
var modify;
var translate;
var scale;
var zIndex;
for (i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i);
var slideProgress = this.slides[i].progress;
modify = 1;
if (Math.abs(slideProgress) > 1) {
modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
}
translate = slideProgress * modify * sib + 'px';
scale = 1 - Math.abs(slideProgress) / 5;
zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
slide.transform('translateX(' + translate + ') scale(' + scale + ')');
slide.css('zIndex', zIndex);
slide.css('opacity', 1);
if (Math.abs(slideProgress) > 3) {
slide.css('opacity', 0);
}
}
},
slideChangeTransitionStart: function() {
updateNavPosition0();
}
},
navigation: {
nextEl: '.hon_name_box1 .swiper-button-next',
prevEl: '.hon_name_box1 .swiper-button-prev',
},
observer:true,
observeParents:true,
});
var serPageSwiper1 = new Swiper('.hon_name_box1 .swiper-container', {
direction : sib,
slidesPerView: sib2,
allowTouchMove: false,
observer:true,
observeParents:true,
});
$('.hon_name_box1 .swiper-slide').on( 'click', function() {
var index = $(this).index();
//同步運(yùn)行其它swiper
serSwiper1.slideTo(index);
});
function updateNavPosition0() {
$('.hon_name_box1 .active-nav').removeClass('active-nav');
var activeNav = $('.hon_name_box1 .swiper-slide').eq(serSwiper1.activeIndex).addClass('active-nav');
if (!activeNav.hasClass('swiper-slide-visible')) {
if (activeNav.index() > serPageSwiper1.activeIndex ) {
var thumbsPerNav = Math.floor(serPageSwiper1.width / activeNav.width()) ;
serPageSwiper1.slideTo(activeNav.index() - thumbsPerNav);
} else {
serPageSwiper1.slideTo(activeNav.index());
}
}
}
var serSwiper2 = new Swiper('.hon_con_box2 .swiper-container', {
slideActiveClass: 'active',
speed: 1000,
spaceBetween: 10,
autoplayDisableOnInteraction : false,
navigation: {
nextEl: '.hon_name_box2 .swiper-button-next',
prevEl: '.hon_name_box2 .swiper-button-prev',
},
observer:true,
observeParents:true,
});
var serPageSwiper2 = new Swiper('.hon_name_box2 .swiper-container', {
direction : sib,
slidesPerView: sib2,
allowTouchMove: false,
observer:true,
observeParents:true,
preventClicks : false,//默認(rèn)true
});
$('.hon_name_box2 .swiper-slide').on( 'click', function() {
var index = $(this).index();
//同步運(yùn)行其它swiper
serSwiper2.slideTo(index);
});
serSwiper2.on( 'slideChangeTransitionStart', function() {
updateNavPosition1();
// Do stuff here
});
serSwiper2.on( 'progress', function() {
var i;
var modify;
var translate;
var scale;
var zIndex;
for (i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i);
var slideProgress = this.slides[i].progress;
modify = 1;
if (Math.abs(slideProgress) > 1) {
modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
}
translate = slideProgress * modify * sib + 'px';
scale = 1 - Math.abs(slideProgress) / 5;
zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
slide.transform('translateX(' + translate + ') scale(' + scale + ')');
slide.css('zIndex', zIndex);
slide.css('opacity', 1);
if (Math.abs(slideProgress) > 3) {
slide.css('opacity', 0);
}
}
});
function updateNavPosition1() {
$('.hon_name_box2 .active-nav').removeClass('active-nav');
var activeNav = $('.hon_name_box2 .swiper-slide').eq(serSwiper2.activeIndex).addClass('active-nav');
if (!activeNav.hasClass('swiper-slide-visible')) {
if (activeNav.index() > serPageSwiper2.activeIndex ) {
var thumbsPerNav = Math.floor(serPageSwiper2.width / activeNav.width()) ;
serPageSwiper2.slideTo(activeNav.index() - thumbsPerNav);
} else {
serPageSwiper2.slideTo(activeNav.index());
}
}
}
serSwiper2.autoplay.stop();
$('.hon_tab_nav_box > div').on('click', function () {
serSwiper1.autoplay.stop();
serSwiper2.autoplay.stop();
$(this).addClass('on').siblings("div").removeClass('on');
var thisIndex = $(this).index();
$(".hon_con_case > div").eq(thisIndex).show().siblings("div").hide();
switch (thisIndex)
{
case 0:
serSwiper1.autoplay.start();
break;
case 1:
serSwiper2.autoplay.start();
break;
}
});
}
}

網(wǎng)站題目:網(wǎng)站制作之使用swiper插件做多組合輪播
標(biāo)題URL:http://jinyejixie.com/news4/244204.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版網(wǎng)站策劃、網(wǎng)站導(dǎo)航網(wǎng)站設(shè)計(jì)、標(biāo)簽優(yōu)化、外貿(mào)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

營(yíng)銷(xiāo)型網(wǎng)站建設(shè)
保定市| 广平县| 筠连县| 双鸭山市| 军事| 林周县| 山东| 西昌市| 西乌珠穆沁旗| 鄱阳县| 莱西市| 永春县| 凯里市| 宜兰市| 苏尼特左旗| 工布江达县| 武汉市| 岳池县| 连平县| 临朐县| 广灵县| 呼图壁县| 滕州市| 离岛区| 元谋县| 闽清县| 永宁县| 灵川县| 乌拉特中旗| 托里县| 柘荣县| 元朗区| 沧州市| 蕲春县| 凯里市| 海淀区| 连城县| 普兰县| 辽中县| 温州市| 修武县|