$(function(){ //1024分辨率下wow无效 if(window.innerwidth>1024){ new wow().init(); } }); function navscroll(){ var preimg = []; $('img').each(function(index,el){ preimg.push($(el).attr('src')); }) _preloadimg(preimg,function(){ var wins = $(window).scrolltop(); var navtop = $('.nav-detai-pc').offset().top; if(wins>navtop){ $('.nav-detai-pc').addclass('on'); $('.clearfixed').addclass('on'); }else{ $('.nav-detai-pc').removeclass('on'); $('.clearfixed').removeclass('on'); } $(window).on('scroll resize',function(){ wins = $(window).scrolltop(); if(wins>navtop){ $('.pc-nac-detial').addclass('on'); $('.clearfixed').addclass('on'); }else{ $('.pc-nac-detial').removeclass('on'); $('.clearfixed').removeclass('on'); } var _length = $('.position').length; for(var i = 0;i < _length ; i++){ if($(window).scrolltop()>=$('.position').eq(i).offset().top-$('.nav-detai-pc').height()){ $('.nav-detai-pc .detial-nav-pc .swiper-slide a').removeclass('cur'); $('.nav-detai-pc .detial-nav-pc .swiper-slide a').eq(i).addclass('cur') } } if ($(document).scrolltop() >= $(document).height() - $(window).height()) { $('.nav-detai-pc .detial-nav-pc .swiper-slide a').removeclass('cur'); $('.nav-detai-pc .detial-nav-pc .swiper-slide a').last().addclass('cur'); } }); $('.nav-detai-pc .detial-nav-pc .swiper-slide').on('click',function(){ var i = $(this).index(); //console.log($('.position').eq(i).offset().top-$('.nav-detai-pc').outerheight()+2); $('html,body').stop().animate({scrolltop:$('.position').eq(i).offset().top-$('.nav-detai-pc').outerheight()+2},500); }) $('.nav-detai .detial-nav .swiper-slide').on('click',function(){ var i = $(this).index(); $('html,body').stop().animate({scrolltop:$('.position').eq(i).offset().top-$('.nav-detai-pc').outerheight()+2},500); }) }) }