function scroll(fn) { var beforeScrollTop = document.body.scrollTop || document.documentElement.scrollTop, fn = fn || function() {}; window.addEventListener("scroll", function() { var afterScrollTop = document.body.scrollTop || document.documentElement.scrollTop, delta = afterScrollTop - beforeScrollTop; if(delta == 0) return false; fn(delta > 0 ? "down" : "up"); beforeScrollTop = afterScrollTop; }, false); } //判断字符是否为空的方法 function isEmpty(obj){ if(typeof obj == "undefined" || obj == null || obj == ""){ return true; }else{ return false; } } function getQueryString(name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); var r = window.location.search.substr(1).match(reg); if (r != null) { return unescape(r[2]); } return null; } function open53kf(){ var iWidth=800; //弹出窗口的宽度; var iHeight=600; //弹出窗口的高度; //获得窗口的垂直位置 var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //获得窗口的水平位置 var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; var params = 'scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=800,height=600,left='+iLeft+',top='+iTop; open('https://tb.53kf.com/code/client/10129344/1','53kf',params) } $(function () { $('.kflink').click(function(){ window.open('/list-42-1.html'); //open53kf(); }); /*锚点动效*/ $('a[href*="#"],area[href*="#"]').click(function() { if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']'); if ($target.length) { var targetOffset = $target.offset().top; $('html,body').animate({ scrollTop: targetOffset }, 1000); return false; } } }); var windoww = $(window).width(); $('.sp_nav,#nav-close').click(function () { $('.sp_nav').toggleClass('sp_nav_se'); $('.sjj_nav').toggleClass('nav_show'); }); $('.sjj_nav ul li i').click(function () { $(this).parent().children('ul').slideToggle().parent().siblings().children('ul').slideUp(); $(this).toggleClass('sjj_nav_i_se'); $(this).parent().siblings().find('i').removeClass('sjj_nav_i_se'); }); $('.sp_nav_xjb').html(' '); var e = $('#smenu'); var li = e.find("li"); var len = li.length; if(len * li.width() > e.width()){ var swiper = new Swiper('#smenu', { freeMode: true, slidesPerView: 'auto', freeModeSticky: true, //spaceBetween: 30, //pagination: { //el: '.swiper-pagination', //clickable: true, //}, }) var index = e.find('.active').index(); if(index > 0 && index + 1 != len){ index-- } index && swiper.slideTo(index); }else{ //e.addClass('dbl'); e.parent().addClass('dbl'); } var elems=$(".animated"); elems.each(function(i,a) { if ($(a).offset().top >= $(window).scrollTop() && $(a).offset().top < ($(window).scrollTop() + $(window).height())) { var animated=$(this).attr('data-animated'); $(this).addClass(animated); } }); scroll(function(direction) { if(direction=="down"){ elems.each(function(i,a) { if ($(a).offset().top >= $(window).scrollTop() && $(a).offset().top < ($(window).scrollTop() + $(window).height())) { //$(this).addClass('fadeInUp'); var animated=$(this).attr('data-animated'); $(this).addClass(animated); } }); } }); var contentElems=$(".details_warp>*"); contentElems.each(function(i,a) { if ($(a).offset().top >= $(window).scrollTop() && $(a).offset().top < ($(window).scrollTop() + $(window).height())) { if(i%2){ $(this).addClass("animated").addClass("fadeIn"); }else{ $(this).addClass("animated").addClass("fadeIn"); }} }); scroll(function(direction) { if(direction=="down"){ contentElems.each(function(i,a) { if ($(a).offset().top >= $(window).scrollTop() && $(a).offset().top < ($(window).scrollTop() + $(window).height())) { if(i%2){ $(this).addClass("animated").addClass("fadeIn"); }else{ $(this).addClass("animated").addClass("fadeIn"); }} }); } }); /*首页平台按钮悬停效果 */ $(".cloud_list li").hover(function(){ console.log('s'); var obj= $(this).find('.btn').first(); $(".cloud_list .btn").removeClass('act'); obj.addClass("act"); },function(){ //$(this).removeClass("act"); }); }); /* const doct = window.document.documentElement; const el = document.querySelectorAll(".animated"); window.addEventListener("scroll", () => { el.forEach((v, i) => { alert(i); if (v.offsetTop > doct.scrollTop && v.offsetTop < doct.clientHeight + doct.scrollTop) { v.addClass('fadeInUp'); // v.style.color = "red";// 给可视区域元素添加红色 } }); });*/