var Isneed = true; $(function() { var navBarTop = $(".lib-detail-btn").offset().top; // var navserverTop = $(".lib-server-box").offset().top; var headH = 88; var headServer = 90; var navScrollH = $(document).scrollTop(); var boxTop = 0; var titH = $('.lib-detail-tit').outerHeight(true); var afterTop = navScrollH; var beforeTop = 0; var boxH = $('.lib-server-box').height(); var flag = 0; var menuTop = 0; var navBarH = $(".lib-detail-btn").outerHeight(); var Isopen = 0; $('.view_collapse').click(function (){ if(Isopen == 0){ $('.publist-list').css({"height":"auto","overflow":""}); $('.view_more').hide(); $('.collapse').show(); Isopen = 1; } else{ $('.publist-list').css({"height":"123","overflow":"hidden"}); $('.view_more').show(); $('.collapse').hide(); Isopen = 0; } navBarTop = $(".lib-detail-btn").offset().top; navScrollH = $(document).scrollTop(); }) function navBar() { let footerH = $('#Footer').outerHeight(); let footerTop = $('#Footer').offset().top; let navScrollH = $(document).scrollTop(); if (Isneed) { if (navBarTop <= navScrollH + headH) { $(".lib-detail-btn").addClass('fixed').css({"top": headH, "marginTop": "0px"}); if (footerH > footerTop - navScrollH) { $('.lib-server-box').removeClass('fixed').css({"position": "sticky","top": footerTop - boxH,"z-index": "9"}); $(".lib-server-tit").css({"border-top": " "}); } else { $('.lib-server-box').addClass('fixed').css({'top': headServer, "position": ''}); $(".lib-server-tit").css({"border": "0"}); } } else { $(".lib-detail-btn").removeClass('fixed').css({"top": "", "marginTop": "0px"}); $('.lib-server-box').removeClass('fixed').css({'top': 'auto'}); } $(".lib-server-tit").css({"border-top": ""}); } $.each($("[data-page]"),function(index){ // console.log($("[data-page]").eq(index).offset().top) if(navScrollH > $("[data-page]").eq(index).offset().top - headH - navBarH - 1) { // console.log(navScrollH,$("[data-page]").eq(index).offset().top - headH - navBarH - 1) $(".lib-detail-btn").find("li").eq(index).addClass("active").siblings().removeClass("active"); } }); } $(window).scroll(function(){ navBar(); }); function rollBottom(thisIndex) { $(window).scroll(function(){ let scrollTop = $(this).scrollTop(); let scrollHeight = $(document).height(); let windowHeight = $(this).height(); if(scrollTop + windowHeight === scrollHeight){ $(".lib-detail-btn").find("li").eq(thisIndex).addClass("active").siblings().removeClass("active"); // console.log(scrollTop + windowHeight,scrollHeight) } }) } $(".lib-detail-btn").find("li").on("click",function(){ boxTop = $("[data-page]").eq($(this).index()).offset().top; let rollTop = boxTop - headH - navBarH; let thisIndex = $(this).index(); // console.log(rollTop,thisIndex); $("html,body").animate({ scrollTop: rollTop },200); // rollBottom(thisIndex); }); }) function hiddenH() { var lH = $('.lft-H').height(); // var rH = $('.rgt-H').height(); var rommulH = lH - 143; var rommH = 0; $('.rgt-recommend-box li').each(function (){ var liH = $(this).outerHeight() + 4; rommH += liH; if(rommH <= rommulH){ $('.rgt-recommend-box').css({"height":rommH,"overflow":"hidden"}); } // console.log(rommH,rommulH) }) } // lib img slide // (function () { // if ($('.img-list').length > 1) { // $(function () { // function ContainerImg(slideId, imgW) { // this.imgWidth = imgW; // this.slideId = document.querySelector(slideId); // this.ul = this.slideId.querySelector('.img-list'); // this.li = this.slideId.querySelectorAll('.img-list>li'); // this.btnPrev = this.slideId.querySelector('.btn-prev'); // this.btnNext = this.slideId.querySelector('.btn-next'); // this.navList = this.slideId.querySelector('.nav-list'); // this.navListItem = this.slideId.querySelectorAll('.nav-list>li'); // this.len = this.li.length - 1; // this.index = 0; // this.pictureMask = document.querySelector('#libPictureMask'); // } // // ContainerImg.prototype = { // init: function () { // this.fnUlWidth(); // this.btnPrev.onclick = this.fnPrev.bind(this); // this.btnNext.onclick = this.fnNext.bind(this); // this.slideId.onclick = this.fnStopBuddle.bind(this); // for (var i = 0; i < this.navListItem.length; i++) { // this.navListItem[i].onclick = this.fnNav.bind(this, i); // } // }, // // ul total width // fnUlWidth: function () { // this.ul.style.width = this.imgWidth * this.li.length + 'px'; // this.navList.style.marginLeft = -(this.navList.offsetWidth)/2 + 'px'; // this.fnUpdateStyle(); // }, // // update style // fnUpdateStyle: function () { // // console.log('this.index=' +this.index); // // console.log('this.len=' +this.len); // var toLeft = -(this.imgWidth * this.index) + 'px'; // this.ul.style.left = toLeft; // this.btnPrev.setAttribute('class', 'btn-prev'); // this.btnNext.setAttribute('class', 'btn-next'); // if (this.index === 0) { // this.btnPrev.setAttribute('class', 'btn-prev first'); // } else if (this.index === this.len) { // this.btnNext.setAttribute('class', 'btn-next last'); // } // for (var i = 0; i < this.navListItem.length; i++) { // if (this.index === i) { // this.navListItem[i].setAttribute('class', 'active'); // } else { // this.navListItem[i].setAttribute('class', ''); // } // } // }, // // to left // fnPrev: function () { // this.index--; // this.index = this.index < 0 ? 0 : this.index; // this.fnUpdateStyle(); // }, // // to right // fnNext: function () { // this.index++; // this.index = this.index > this.len ? this.len : this.index; // this.fnUpdateStyle(); // }, // fnNav: function (currIndex) { // this.index = currIndex; // this.fnUpdateStyle(); // }, // fnShowMask: function (currIndex, e) { // this.index = currIndex; // this.fnUpdateStyle(); // this.pictureMask.style.display = 'table'; // e = e || window.event; // e.stopPropagation(); // }, // fnHideMask: function (e) { // this.pictureMask.style.display = 'none'; // e = e || window.event; // e.stopPropagation(); // }, // fnStopBuddle: function (e) { // e = e || window.event; // e.stopPropagation(); // } // }; // // // // picture // function ContainerPicture(slideId, imgW) { // ContainerImg.call(this, slideId, imgW); // this.pictureContent = this.pictureMask.querySelector('.picture-content'); // this.btnClosed = document.getElementById('btnClosePictureMask'); // this.init(); // this.fnPictureMask(); // } // // ContainerPicture.prototype = new ContainerImg('#libPicture', 600); // ContainerPicture.prototype.constructor = ContainerPicture; // ContainerPicture.prototype.fnPictureMask = function () { // this.pictureMask.onclick = this.fnHideMask.bind(this); // this.btnClosed.onclick = this.fnHideMask.bind(this); // }; // var libPicture = new ContainerPicture('#libPicture', 600); // // // // thumb // function ContainerThumb(slideId, imgW) { // ContainerImg.call(this, slideId, imgW); // this.init(); // this.fnThumbImg(); // } // // ContainerThumb.prototype = new ContainerImg('#libThumb', 240); // ContainerThumb.prototype.constructor = ContainerThumb; // ContainerThumb.prototype.fnThumbImg = function () { // for (var i = 0; i < this.li.length; i++) { // this.li[i].onclick = this.fnShowMask.bind(libPicture, i); // } // }; // var libThumb = new ContainerThumb('#libThumb', 240); // }) // } // })();