Better scroll targets

This commit is contained in:
Chuck Dries 2017-06-13 19:15:00 -07:00
parent 140c9c0b6f
commit b293620bc9

View File

@ -207,11 +207,11 @@
//execute scroll style modifications //execute scroll style modifications
function sc(ypos) { function sc(ypos) {
var wheight = window.innerHeight; var windowHeight = window.innerHeight;
//top thing //top thing
var topDiv = document.getElementById("top"); var topDiv = document.getElementById("top");
var mast = document.getElementById("mast"); var mast = document.getElementById("mast");
var hcalc = wheight - ypos; var hcalc = windowHeight - ypos;
var topHeight = 100; var topHeight = 100;
if (hcalc > 100) { if (hcalc > 100) {
topHeight = hcalc; topHeight = hcalc;
@ -220,17 +220,17 @@
} }
// var mastHeight = mast.clientHeight; // var mastHeight = mast.clientHeight;
// var halfHeight = Math.floor((topHeight / 2) - (mastHeight / 2)); // var halfHeight = Math.floor((topHeight / 2) - (mastHeight / 2));
if (topHeight < 300) { if (topHeight < 315) {
topDiv.className = "small"; topDiv.className = "small";
} else { } else {
topDiv.className = "large"; topDiv.className = "large";
} }
topDiv.style.height = topHeight + "px"; topDiv.style.height = topHeight - 10 + "px"; //subtract 10 to account for padding-top on #top
// console.log("topheight is " + topHeight + " and topDiv.style.height = " + topDiv.style.height); // console.log("topheight is " + topHeight + " and topDiv.style.height = " + topDiv.style.height);
// mast.style.marginTop = halfHeight + "px"; // mast.style.marginTop = halfHeight + "px";
//background thing //background thing
var p = ((wheight - ypos) / wheight); //calulate ratio of scroll var p = ((windowHeight - ypos) / windowHeight); //calulate ratio of scroll
// x.innerHTML = " " + String(parseInt(p * 100)); //display it // x.innerHTML = " " + String(parseInt(p * 100)); //display it
var rgb = Math.floor(Math.abs(1 - p) * 255); //set the color var rgb = Math.floor(Math.abs(1 - p) * 255); //set the color
// var colorString = "rgb(" + rgb + "," + rgb + "," + rgb + ")"; // var colorString = "rgb(" + rgb + "," + rgb + "," + rgb + ")";
@ -239,7 +239,7 @@
} }
function getScrollY() { function getScrollY() {
//internet explorer does not have a window.scrollY property, so we need to make our own //internet explorer does not have a window.scrollY property, it has pageYOffset
return typeof window.scrollY === "undefined" ? window.pageYOffset : window.scrollY; return typeof window.scrollY === "undefined" ? window.pageYOffset : window.scrollY;
} }