ソースを参照

右侧导航点击定位

zhangxc 5 年 前
コミット
af23593eb0
1 ファイル変更4 行追加6 行削除
  1. 4 6
      src/js/information.js

+ 4 - 6
src/js/information.js

@@ -88,9 +88,8 @@ function getInfomation() {
         item.content = item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
         anchors = '<li><i></i><a href="#' + item.title +
           '">' + item.title + '</a></li><li class="anchor-line"></li>';
-        // str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> <span></div> <h2 class="titleH2" id="' + item.title +
-        //   '">'
-        str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> <span></div> <h2 class="titleH2">'
+        str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> <span></div> <h2 class="titleH2" id="' + item.title +
+          '">'
         if (getUrlArgObject('type') == 8) {
           str += '【' + item.title + '】'
         } else {
@@ -114,9 +113,9 @@ function getInfomation() {
       var scrollTop = $('.infos').scrollTop()
       var divHeight = 0;
       for (var i = 0; i < list.length; i++) {
-        divHeight = divHeight + parseInt($('#' + list[i].title).css('height')) + parseInt($('#' + list[i].title).parent().next().css('height')) + 40
+        divHeight = divHeight + parseInt($('#' + list[i].title).css('height')) + parseInt($('#' + list[i].title).parent().next().css('height')) + 30
         if (divHeight > scrollTop) {
-          var anchor = 2 * i;
+          var anchor = 2 * (i);
           $('.anchors ul').children().eq(anchor).addClass('active').siblings().removeClass('active');
           return;
         }
@@ -198,7 +197,6 @@ function downLoadFile() {
 // }
 function adjustWidth() {
   var wt = window.innerWidth || document.documentElement.clientWidth;
-  console.log('wt',wt)
   $(".titleH2").width(wt- 0.2*wt -33 - 200 - 17 - 40 -15 + 'px')
   $("pre").width(wt- 0.2*wt -33 - 200 - 17 - 40 -15 + 'px')
 }