Difference between revisions of "Template:SJTU-BioX-Shanghai/Alpha/Header"

Line 7: Line 7:
 
}
 
}
 
function toc_loop() {
 
function toc_loop() {
   var TOP = window.pageYOffset;
+
   var TOP = window.pageYOffset + 20;
 
   var headings = $('#toc ~ h2 > span:last-child, #toc ~ h3 > span:last-child');
 
   var headings = $('#toc ~ h2 > span:last-child, #toc ~ h3 > span:last-child');
 +
  if (headings.length == 0) return
 +
 
   for (var i = 0; i < headings.length; i++) {
 
   for (var i = 0; i < headings.length; i++) {
 
     var h = headings[i];
 
     var h = headings[i];
 
     var top = h.offsetTop;
 
     var top = h.offsetTop;
    console.log(TOP, top, h.id)
 
 
     if (top >= TOP) break
 
     if (top >= TOP) break
 
   }
 
   }
 
   //set h as reading part
 
   //set h as reading part
 
   var id = h.id;
 
   var id = h.id;
   console.log('current', id);return;
+
   console.log('current', id);
 +
 
 
   var prev_a = $('#toc a.reading');
 
   var prev_a = $('#toc a.reading');
 
   var a = $('a[herf$="#'+ id +'"]');
 
   var a = $('a[herf$="#'+ id +'"]');

Revision as of 02:48, 17 August 2015