(function(){ var swiperobj = null; var heightgap = 500; // 高度差距,执行过渡效果的距离 范围屏幕高度以内 var limit = { // 高度限制 mobile: 400, ipad: 450, pc: 720 }; function showelement(arr){ if (arr[0]) { // 第一部分显示时 } else { } if (arr[1]) { $('.gsjj-tit-b, .gsjj-img').addclass('show'); } else { $('.gsjj-tit-b, .gsjj-img').removeclass('show'); } if (arr[2]) { $('.l-qywh5 ,.l-qywh6').addclass('show'); } else { $('.l-qywh5 ,.l-qywh6').removeclass('show'); } if (arr[3]) { $('.gywm-top2, .jjgl-tit').addclass('show'); } else { $('.gywm-top2, .jjgl-tit').removeclass('show'); } if (arr[4]) { $('.gywm-top3, .tzal-img-b').addclass('show'); } else { $('.gywm-top3, .tzal-img-b').removeclass('show'); } if (arr[5]) { $('.l-qywh-box,.fotter').addclass('show'); } else { $('.l-qywh-box,.fotter').removeclass('show'); } } var isie = iecheck(); if (!isie || isie >= 9) { var obj = new windetail({ limit: limit, changeuifn: function(state){ console.log('uichange'); // 分端显示图片 $('.' + state.uimode).find('img').attr('src', function(){ return $(this).attr('data-img'); }) }, changesizefn: function(state){ console.log('sizechange'); $('.swiper-container').height(state.winheight); $('.swiper-slide').height(state.winheight); }, pcfn: function(state){ console.log('pcfn'); } }); var status = obj.state.isreadly; if (status){ swiperobj = new swiper('.swiper-container', { mode: 'vertical', // 竖直滚动 loop: false, // 循环控制 mousewheelcontrol: true, // 鼠标滚轮触发 slideactiveclass: 'swiper-active', // 激活类名 pagination: '.pagination', // 指示点 paginationclickable: true, // 可点击指示点 slidesperview : 'auto', // 根据每屏大小自适应滚动 createpagination: false, // 自动生成指示点 onslidechangeend: swipercallback // 回调函数 }) $('.mouse').velocity({ translatey: [ 50, 0 ], opacity: [ 0.3, "easeinquint", 1 ] }, { duration: 1500, // 动画执行时间 loop: true // 循环 }) } else { noswiper(); } } else { // < ie7,8 noswiper(); } function noswiper(){ $('.mouse').hide(); $('.pagination').hide(); $('.swiper-slide').height('850px'); $('.swiper-container').height('auto'); $(window).scroll(swipercallback); } function swipercallback() { var flagswiper = arguments[0] instanceof swiper; var arr = []; var elementarr = $('.swiper-slide'); var length = elementarr.length; for (var i = 0; i < length; i++){ var flag; if (flagswiper){ flag = $(elementarr[i]).offset().top - heightgap <= 0; } else { flag = $(elementarr[i]).offset().top + heightgap >= 0; } arr[i] = flag; } showelement(arr); } function iecheck(){ var ua = window.useragent || window.navigator.useragent;     if(/msie/i.test(ua)){         var lv = ua.match(/msie (\d+\.\d+)/i)[1]; return parseint(lv);     } return false; } function onswiperto(index){ if (swiperobj) { swiperobj.swipeto(index, 200, true); } else { var itemtop = $(".swiper-slide" + ++index).offset().top; $("html,body").animate({scrolltop: itemtop + "px"}, 200); } } })()