Difference between revisions of "Team:Cambridge-JIC/TestHome"
(21 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
width: 256px; | width: 256px; | ||
height:256px; | height:256px; | ||
− | background: url(//2015.igem.org/wiki/images/b/be/CamJIC-Downarrow.png) | + | background: url(//2015.igem.org/wiki/images/b/be/CamJIC-Downarrow.png); |
z-index:1; | z-index:1; | ||
position:relative; | position:relative; | ||
+ | } | ||
+ | #sidebar { | ||
+ | position:fixed; | ||
+ | top:130px; | ||
+ | right:20px; | ||
+ | width: 23px; | ||
+ | z-index:1; | ||
+ | } | ||
+ | |||
+ | .sidebar-item { | ||
+ | width: 20px; | ||
+ | height:20px; | ||
+ | float: left; | ||
+ | border-radius: 50%; | ||
+ | border: #555 solid; | ||
+ | margin-bottom: 5px; | ||
+ | cursor:pointer; | ||
} | } | ||
</style> | </style> | ||
Line 23: | Line 40: | ||
$(this).css("cursor", "pointer") | $(this).css("cursor", "pointer") | ||
} | } | ||
+ | }) | ||
+ | |||
+ | $(window).on("resize", function(){ | ||
+ | |||
+ | $("#sidebar").offset({right: $(".cam-container section:first-of-type div").offset().right - 30}) | ||
+ | |||
+ | if($(".navbar-collapse").is(":visible")) { | ||
+ | $(".downarrow").show() | ||
+ | $("#sidebar").show() | ||
+ | } else { | ||
+ | $(".downarrow").hide() | ||
+ | $("#sidebar").hide() | ||
+ | } | ||
+ | |||
+ | }).resize(); | ||
+ | |||
+ | var ix = 0; | ||
+ | $("section").each(function(){ | ||
+ | if($(this).attr("id") != "footer-sec") { | ||
+ | $("#sidebar").append("<div onclick=\"scrollsection("+ix+")\" class=\"sidebar-item\""+(ix==0?" style=\"background: #555\"":"")+"></div>") | ||
+ | } | ||
+ | ix++ | ||
+ | }) | ||
+ | |||
+ | |||
+ | |||
+ | $(window).on("scroll", function(){ | ||
+ | var i=0; | ||
+ | $("section").each(function(){ | ||
+ | if($(this).offset().top <= $(window).scrollTop()) { | ||
+ | $(".sidebar-item").css("background", "none") | ||
+ | $($(".sidebar-item").get(i)).css("background", "#555") | ||
+ | } | ||
+ | i++; | ||
+ | }) | ||
}) | }) | ||
Line 33: | Line 85: | ||
}) | }) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
}); | }); | ||
− | }); | + | function scrollsection(id) { |
+ | $("html, body").animate({ scrollTop: $($("section").get(id)).offset().top }, 1000); | ||
+ | } | ||
</script> | </script> | ||
+ | <div id="sidebar"></div> | ||
<div class="downarrow" id="overlay" style="background:url(//2015.igem.org/wiki/images/6/60/CamJIC-Overlay_guide.png); background-size: 100% 100%;width:100%;height:27%;position:absolute;z-index:0"></div> | <div class="downarrow" id="overlay" style="background:url(//2015.igem.org/wiki/images/6/60/CamJIC-Overlay_guide.png); background-size: 100% 100%;width:100%;height:27%;position:absolute;z-index:0"></div> |
Latest revision as of 02:18, 4 August 2015