var viewswiper = new swiper('.view .swiper-container', { onslidechangestart: function() { updatenavposition() } }) var previewswiper = new swiper('.preview .swiper-container', { visibilityfullfit: true, slidesperview: 'auto', onlyexternal: true, onslideclick: function() { viewswiper.swipeto(previewswiper.clickedslideindex) } }) $(function() { tabactive(".nextboxnav li", 'nextactive', '.nextboxmain .nextboxmainbox'); tabactive(".tabelstop li", 'tableactive', ".tabelsdiv .tabelsdivmain"); $(".peoplename").hover(function() { $(this).find(".introduction").stop(false, true).fadein() }, function() { $(this).find(".introduction").stop(false, true).fadeout() }); $(".activediv li").click(function() { $(".activediv li").find("img").hide(); $(".activediv li").removeclass('activeli'); $(".activediv li").find('em').removeclass('downarrow') $(this).find("em").addclass('downarrow'); $(this).find('img').show(); $(this).addclass('activeli'); }); $(".activediv li").hover(function() { $(this).find("em").addclass('downarrow'); }, function() { $(this).find("em").removeclass('downarrow'); }) var navheight = $("#navheight").offset(); var navfix = $("#nav-wrap"); $(window).scroll(function() { if ($(this).scrolltop() > navheight) { navfix.addclass("navfix"); } else { navfix.removeclass("navfix"); } }); $('.nav').navscroll({ mobiledropdown: true, mobilebreakpoint: 768, scrollspy: true }); $('.view .arrow-left,.preview .arrow-left').on('click', function(e) { e.preventdefault() if (viewswiper.activeindex == 0) { viewswiper.swipeto(viewswiper.slides.length - 1, 1000); return } viewswiper.swipeprev() }) $('.view .arrow-right,.preview .arrow-right').on('click', function(e) { e.preventdefault() if (viewswiper.activeindex == viewswiper.slides.length - 1) { viewswiper.swipeto(0, 1000); return } viewswiper.swipenext() }) }) function updatenavposition() { $('.preview .active-nav').removeclass('active-nav') var activenav = $('.preview .swiper-slide').eq(viewswiper.activeindex).addclass('active-nav') if (!activenav.hasclass('swiper-slide-visible')) { if (activenav.index() > previewswiper.activeindex) { var thumbspernav = math.floor(previewswiper.width / activenav.width()) - 1 previewswiper.swipeto(activenav.index() - thumbspernav) } else { previewswiper.swipeto(activenav.index()) } } } // 选项卡 function tabactive(obj1, obj2, obj3) { $(obj1).click(function() { $(this).addclass(obj2).siblings().removeclass(obj2); var index = $(obj1).index(this); $(obj3).eq(index).show().siblings().hide(); }); }