$(function () { history(); }) function history(){ $anchorTop=$('.his_ll').offset().top; // $(window).scroll(function(){ // wint=$(window).scrollTop(); // if (wint>$anchorTop) { // $('.his_ll').addClass('anchor_fixed'); // } // else{ // $('.his_ll').removeClass('anchor_fixed'); // } // }) var his_slide = new Swiper('.history-part .his_ll .swiper-container',{ direction: 'vertical', slidesPerView: 5, slidesPerGroup : 1, spaceBetween: 0, speed:1000, noSwiping : true, prevButton:'.history-part .his_ll .swiper-button-prev', nextButton:'.history-part .his_ll .swiper-button-next', breakpoints:{ 1024: { slidesPerView: 6, direction: 'horizontal', noSwiping : false, }, 767: { slidesPerView: 3, direction: 'horizontal', noSwiping : false, } } }) var _ind=0; var _len = $(".history-part .his_ll .swiper-slide").length; //console.log(_len); btnJudge(); $(".history-part .his_ll .swiper-slide").click(function(){ _ind = $(this).index(); btnJudge(); var url = $(this).data("src"); $(this).addClass("on").siblings().removeClass("on"); caseAjax(".his_box",url); }) $(".history-part .his_ll .swiper-button-prev").click(function(){ _ind--; btnJudge(); $(".history-part .his_ll .swiper-slide").eq(_ind).addClass("on").siblings().removeClass("on"); $(".history-part .his_ll .swiper-slide.on").click(); }) $(".history-part .his_ll .swiper-button-next").click(function(){ _ind++; btnJudge(); $(".history-part .his_ll .swiper-slide").eq(_ind).addClass("on").siblings().removeClass("on"); $(".history-part .his_ll .swiper-slide.on").click(); }) $(".history-part .his_ll .swiper-slide:eq(0)").click(); function btnJudge() { if(_ind >= _len - 1) { $('.history-part .his_ll .swiper-button-next').addClass("disabled") _ind = _len - 1; } else { $('.history-part .his_ll .swiper-button-next').removeClass("disabled") } if(_ind <= 0) { $(".history-part .his_ll .swiper-button-prev").addClass("disabled") _ind = 0; } else { $(".history-part .his_ll .swiper-button-prev").removeClass("disabled") } } } //ajax切换页面 function caseAjax(str,url){ if (url.indexOf('?') == -1) { url += '?tm=' + Math.random(); }else { url += '&tm=' + Math.random(); } $.ajax({ url:url, success:function(msg){ $(str).html(""); $(str).append(msg); hislit(); } }); } function hislit(){ var swiper = new Swiper('.his_box .swiper-container', { direction: 'vertical', pagination: '.his_box .swiper-pagination', slidesPerView: "auto", // centeredSlides: center, // loop:loop, // spaceBetween: 30, // noSwiping : true, mousewheelControl : true, mousewheelReleaseOnEdges : true, mousewheelForceToAxis : true,//固定为竖向 mousewheelInvert : true, mousewheel: true, speed:500, prevButton:'.his_box .swiper-button-prev', nextButton:'.his_box .swiper-button-next', breakpoints:{ //当宽度小于等于1024 1024: { slidesPerView: 3, spaceBetween: 10, centeredSlides: false, direction: 'horizontal', loop:false, mousewheelControl : false }, 767: { slidesPerView: 1, spaceBetween: 0, centeredSlides: false, direction: 'horizontal', loop:false, } } }); }