// 防抖 debounce 代码 function debounce(fn, delay) { var timeout = null; // 创建一个标记用来存放定时器的返回值 return function (e) { // 每当用户输入的时候把前一个 setTimeout clear 掉 clearTimeout(timeout); // 然后又创建一个新的 setTimeout, 这样就能保证interval 间隔内如果时间持续触发,就不会执行 fn 函数 timeout = setTimeout(() => { fn.apply(this, arguments); }, delay); }; } var mobFJ = { mHonor: function (tar) { if (tar && tar.length != 0) { var radialObj = $('#rad-mob-recyle').radialIndicator( { initValue: 10, barWidth: 2, maxValue: $(".honor-mob-item").length * 10, barColor: '#196CCF', radius: 70, displayNumber: false }).data('radialIndicator'); var mySwiper = new Swiper('.honor-mob-swiper', { slidesPerView: 1, // loop: true, direction: 'vertical', on: { init: function () { }, slideChange: function () { radialObj.animate((this.realIndex + 1) * 10); if (this.activeIndex != 0) { } else { } $(".honor-mob-item").hide(); $(".honor-mob-item").eq(this.realIndex).fadeIn(); $(".honor-mob-num").html($(".honor-mob-swiper .swiper-slide").eq(this.activeIndex).find("a").attr("data-num")) } }, }); $(".honor-mob-swiper .swiper-slide a").eq(0).addClass("active"); $(".honor-mob-item").eq(0).show(); } } } let pc = { honor: { honorFun: function (tar) { var yearHeight = $(".about_honour_year_left_list ul li").height() + 20; console.log(yearHeight, "hhhh"); if (tar && tar.length != 0) { var scrllHeight = $(".honorBox")[0].scrollHeight; var realHeight = $(".honorBox").height(); console.log(yearHeight, "hhhh",scrllHeight,realHeight); var arrOffset = [], brrOffset = []; //圆形 var win = document.body.clientWidth; if (win > 1024) { $("body").attr("data-screen", "big"); } else { $("body").attr("data-screen", "small"); } $(".honorBox .list").each(function (index) { brrOffset.push($(".honorBox .list").eq(index)[0].offsetTop + $(".honorBox .list").eq(index).height() - 200); arrOffset.push($(".honorBox .list").eq(index)[0].offsetTop + $(".honorBox .list").eq(index).height() - 200); }); var radialObj = null; radialObj = $('#rad_about_honour_circe').radialIndicator({ initValue: 0, barWidth: 2, maxValue: scrllHeight - realHeight, barColor: '#196CCF', radius: 198, displayNumber: false }).data('radialIndicator'); //圆形 end $(window).resize(function () { var win = document.body.clientWidth; if ($("body").attr("data-screen") == "small") { if (win > 1024) { scrllHeight = $(".honorBox")[0].scrollHeight; realHeight = $(".honorBox").height(); arrOffset = [], brrOffset = []; $(".honorBox .list").each(function (index) { brrOffset.push($(".honorBox .list").eq(index)[0].offsetTop + $(".honorBox .list").eq(index).height() - 200); arrOffset.push($(".honorBox .list").eq(index)[0].offsetTop + $(".honorBox .list").eq(index).height() - 200); }); $("body").attr("data-screen", "big"); radialObj.option('maxValue', scrllHeight - realHeight); } } }); var sec = 0; $(".about_honour_year_left_list li").eq(0).addClass("active"); document.querySelectorAll('.honorBox')[0].addEventListener('mousewheel',debounce(function(event, delta, deltaX, deltaY){ console.log("deltaX",deltaX,deltaY) var dom = $(".honorBox").scrollTop(), tScroll = $(".honorBox_in").height(), viewH = $(".honorBox").height(); if (deltaY == -1) { // console.log("ddd", dom + 680, "===", tScroll, viewH) if ((dom + viewH) >= tScroll) { $(".about_honour_year_left_list ul").css("transform", "translate3d(0," + ((yearHeight + (arrOffset.length - 2) * yearHeight) * -1) + "px , 0)"); radialObj.animate(dom); var timber = setTimeout(function () { $(".about_honour_year_left_list li").removeClass("active"); $(".about_honour_year_left_list li").eq(arrOffset.length - 1).addClass("active"); $(".honorBox .list .hName").removeClass("hr_color"); $(".honorBox .list").eq(arrOffset.length - 1).find(".hName").addClass("hr_color"); $(".leftNum").text($(".about_honour_year_left_list li").eq(arrOffset.length - 1).attr("data-num")); }, 50); } else { for (let i = 0; i < arrOffset.length; i++) { if (dom > sec && dom > arrOffset[i]) { sec = arrOffset[i]; } } $(".about_honour_year_left_list ul").css("transform", "translate3d(0," + ((yearHeight + (arrOffset.indexOf(sec)) * yearHeight) * -1) + "px , 0)"); radialObj.animate(dom); var timber = setTimeout(function () { $(".about_honour_year_left_list li").removeClass("active"); $(".about_honour_year_left_list li").eq(arrOffset.indexOf(sec) + 1).addClass("active"); $(".honorBox .list .hName").removeClass("hr_color"); $(".honorBox .list").eq(arrOffset.indexOf(sec) + 1).find(".hName").addClass("hr_color"); $(".leftNum").text($(".about_honour_year_left_list li").eq(arrOffset.indexOf(sec) + 1).attr("data-num")); }, 50); } } else { for (let i = 0; i < arrOffset.length; i++) { if (dom < arrOffset[i] && dom > arrOffset[i - 1]) { sec = arrOffset[i - 1]; } } if (arrOffset.indexOf(sec) == 0 && dom < 100) { $(".about_honour_year_left_list ul").css("transform", "translate3d(0," + 0 + "px , 0)"); radialObj.animate(0); var timber = setTimeout(function () { $(".about_honour_year_left_list li").removeClass("active"); $(".about_honour_year_left_list li").eq(0).addClass("active"); $(".honorBox .list .hName").removeClass("hr_color"); $(".honorBox .list").eq(0).find(".hName").addClass("hr_color"); $(".leftNum").text($(".about_honour_year_left_list li").eq(0).attr("data-num")); }, 300); } else { $(".about_honour_year_left_list ul").css("transform", "translate3d(0," + ((yearHeight + (arrOffset.indexOf(sec)) * yearHeight) * -1) + "px , 0)"); var timber = setTimeout(function () { $(".about_honour_year_left_list li").removeClass("active"); $(".about_honour_year_left_list li").eq(arrOffset.indexOf(sec) + 1).addClass("active"); $(".honorBox .list .hName").removeClass("hr_color"); $(".honorBox .list").eq(arrOffset.indexOf(sec) + 1).find(".hName").addClass("hr_color"); $(".leftNum").text($(".about_honour_year_left_list li").eq(arrOffset.indexOf(sec) + 1).attr("data-num")); }, 50); radialObj.animate(dom); } } },200)) } }, //honorFun end } } $(function () { pc.honor.honorFun($('.wjHonor')) mobFJ.mHonor($(".honor-mob-swiper")); })