$(document).ready(function(){ enterEffects(); }); $(window).resize(function(){ var resizeTimer = null; if (resizeTimer) clearTimeout(resizeTimer); resizeTimer = setTimeout(function(){ enterEffects(); // fixNav(); },50); }); $(window).scroll(function(){ enterEffects(); }); $('.sub_0r2 ul').slick({ slidesToShow: 1, slidesToScroll: 1, dots: false, arrows: true, centerMode: true, centerPadding: 0, focusOnSelect: true, autoplay: true, autoplaySpeed: 4000, responsive: [{ breakpoint: 767, settings:{ slidesToShow: 1 } } ] }); // 鼠标滚动渐渐出现 $('.effect1,.effect2,.effect3,.effect4').each(function() { $(this).find("li").each(function(index){ var len = $(this).parent().find("li").length; $( this ).css({'transition-delay': (index*0.5/len)+'s'}); }) }); function enterEffects(){ var sWSon = document.documentElement.clientWidth; if(sWSon >= 992){ $(".effect").each(function(index, element) { var e = $(this); var c = $(window).height(); if($(window).scrollTop()>=$(e).offset().top - 0.9 * c){ $(e).addClass("isView"); }else{ $(e).removeClass("isView"); } }); } } $('.pages .selectLink').click(function(){ $(this).find('.arrow').toggleClass('on'); $(this).find('.alertBox').toggleClass('on'); $(this).toggleClass('on'); }) // 点击回到页面顶部 $('.gotop').click(function(){ $('body,html').stop().animate({scrollTop:0}); $('.header').removeClass('currents'); $('body').css('padding-top',0); $('.top').slideDown(0); return false; }); // tab切换 $.fn.extend({ tab: function (options){ var defaults = { //默认参数 ev : 'mouseover', //默认事件'mouseover','click' til : 'h2', //默认标签 box : '.tab_list', //默认列表 delay : 100, //延迟时间 auto : true, //是否自动切换 true,false speed : 4000, //自动切换间隔时间(毫秒) more : true //是否有more,false,true }; var options = $.extend(defaults, options); //用户设置参数覆盖默认参数 return this.each(function (){ var o = options; var obj = $(this); var oTil = obj.find(o.til); var oBox = obj.find(o.box); var oMore = null; var iNum = 0; var iLen = oTil.length; // 默认选中第一个 $(this).find(o.til).eq(0).addClass('on').siblings(o.til).addClass('off'); $(this).find(o.box).eq(0).addClass('on').siblings(o.box).addClass('off'); $(this).find('.more').eq(0).addClass('on').siblings('.more').addClass('off'); var first = obj.find(o.til).eq(0).index(); //鼠标事件绑定 oTil.bind(o.ev , function (){ var _this = this; if(o.ev == 'mouseover' && o.delay){ _this.timer = setTimeout(function (){ change(_this); },o.delay); }else{ change(_this); }; }) oTil.bind('mouseout',function (){ var _this = this; clearTimeout(_this.timer); }); //自动切换效果 (function autoPlay(){ var timer2 = null; if(o.auto){ function play(){ iNum++; if(iNum >= iLen){ iNum =0; }; change(oTil.eq(iNum)); }; timer2 = setInterval(play,o.speed); obj.on('mouseover',function (){ clearInterval(timer2); }) obj.on('mouseout',function (){ timer2 = setInterval(play,o.speed); }) }; })(); function change(box){ iNum = $(box).index(); iNum = iNum-first; oTil.removeClass('on').addClass('off'); oBox.removeClass('on').addClass('off'); if(o.more){ oMore = obj.find('.more'); oMore.removeClass('on').addClass('off'); oMore.eq(iNum).addClass('on').removeClass('off'); }; oTil.eq(iNum).addClass('on').removeClass('off'); oBox.eq(iNum).addClass('on').removeClass('off'); } }); } })