Difference between revisions of "Template:NYMU-Taipei/newtemplate1"

Line 491: Line 491:
 
$("#dot-side-bar").html(dots.join().replace(/,/g,''));
 
$("#dot-side-bar").html(dots.join().replace(/,/g,''));
 
});
 
});
 +
 +
 +
$(document).ready(function(){
 +
var dotslist = document.getElementsByClassName("sidebar-switch");
 +
var sidebar = document.getElementsByClassName("sidebar-content");
 +
var subtitles = document.getElementsByClassName("subtitle");
 +
var items = document.getElementsByClassName("sidebar-item");
 +
    $(window).scroll(function(){
 +
    var borders = [0];
 +
    for (var i = 0; i <= subtitles.length - 1; i++) {
 +
    borders.push(subtitles[i].scrollHeight+borders[i]-100);
 +
    }
 +
        for (var i = 0; i < subtitles.length; i++) {
 +
        if (window.pageYOffset >=borders[i] && window.pageYOffset <=borders[i+1]) {
 +
        sidebar[i].style.display = "inline-block";
 +
        }
 +
        else{
 +
        sidebar[i].style.display = "none";
 +
        console.log(sidebar[i]);
 +
        }
 +
      $(".sidebar-item").mouseenter(function(){
 +
      console.log(this.lastChild);
 +
        this.lastChild.style.display = "inline-block";
 +
});
 +
$(".sidebar-item").mouseleave(function(){
 +
      console.log(this.lastChild);
 +
        this.lastChild.style.display = "none";
 +
});
 +
        }
 +
    });
 +
});
 +
 
</script>
 
</script>
  

Revision as of 04:28, 12 July 2018