I cannot the get javascript to detect which direction you are scrolling. when I scroll down it outputs "up" to inner HTML Logo, But it never outputs "down". it just keeps outputting up no matter which way you scroll. The code seems fine to me and I havent a clue why this is a problem. Thank you in advance for any fixes.
var ContentSection = document.getElementById("ContentSection");
var Logo = document.getElementById("Logo");
var NavBar = document.getElementById("NavBar");
var CS_Scroll;
var opac = 1;
var lastScrollTop = 0;
ContentSection.onscroll = function() {
//opac = ShowScrollPosition(ContentSection, Logo, CS_Scroll, NavBar, opac);
var st = window.pageYOffset || document.documentElement.scrollTop;
if (st > lastScrollTop) {
document.getElementById("Logo").innerHTML = "down";
} else {
document.getElementById("Logo").innerHTML = "up";
}
lastScrollTop = st;
};
html {
height: 100%;
margin: 0;
padding: 0;
overflow: auto;
}
body {
background: white;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(white, #ffcc66);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(white, #ffcc66);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(white, #ffcc66);
/* For Firefox 3.6 to 15 */
background: linear-gradient(white, #ffcc66);
/* Standard syntax */
height: 100%;
margin: 0;
padding: 0;
background-repeat: no-repeat;
background-attachment: fixed;
}
#Logo {
/*border: 1px solid black;*/
height: 150px;
width: calc(100% - 305px);
float: left;
margin-left: 303px;
}
#LogoPic {
margin-left: 50px;
margin-top: 15px;
}
#NavBar {
position: fixed;
/* border: 1px solid black;*/
height: 47px;
top: 151px;
left: 303px;
width: calc(100% - 305px);
float: left;
}
#LinkBox {
/* border: 1px solid black;*/
margin-left: 55px;
color: DodgerBlue;
}
a {
padding-right: 50px;
font: 400 33px/0.8 'Great Vibes', Helvetica, sans-serif;
/*font: 400 37px/0.8 'Cookie', Helvetica, sans-serif;*/
text-shadow: 0.5px 0.5px black;
}
#ContentSection {
/*border: 1px solid black;*/
height: calc(100% - 229px);
margin-top: 47px;
margin-left: 303px;
width: calc(100% - 305px);
float: left;
overflow-x: hidden;
overflow-y: auto;
}
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
border-radius: 5px;
}
::-webkit-scrollbar-thumb {
background-color: gray;
border-radius: 5px;
}
#LeftBar {
position: fixed;
/*border: 1px solid black;*/
height: calc(100% - 2px);
width: 302px;
}
#SidePanel {
position: fixed;
height: 250px;
width: 285px;
padding: 0;
margin: 0;
top: 200px;
background-color: black;
color: white;
opacity: 0.35;
text-align: center;
border-radius: 5px;
border: 2px solid darkgray;
}
#SidePanelHome {
border-top: 1px solid white;
margin-top: 40px;
width: 235px;
margin-left: 23px;
padding-top: 15px;
padding-bottom: 15px;
}
#SidePanelAboutUs {
border-top: 1px solid white;
margin-top: 0px;
width: 235px;
margin-left: 23px;
padding-top: 15px;
padding-bottom: 15px;
}
#SidePanelProducts {
border-top: 1px solid white;
border-bottom: 1px solid white;
margin-top: 0px;
width: 235px;
margin-left: 23px;
padding-top: 15px;
padding-bottom: 15px;
}
#footer {
/* border: 1px solid black;*/
position: fixed;
bottom: 0;
height: 27px;
width: calc(100% - 305px);
left: 303px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Great+Vibes' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Cookie' rel='stylesheet' type='text/css'>
<div id="Logo"><img id="LogoPic" src="images/image002.gif" /></div>
<div id="NavBar">
<div id="LinkBox">
<a id="HomeLink">Home</a><a id="AboutUsLink">About Us</a><a id="ProductsLink">Products</a>
</div>
</div>
<div id="ContentSection">
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
a</br>
</div>
<div id="LeftBar">
<div id="SidePanel">
<div id="SidePanelHome"><a id="SideHLink">Home</a></div>
<div id="SidePanelAboutUs"><a id="SideHLink">About Us</a></div>
<div id="SidePanelProducts"><a id="SideHLink">Products</a></div>
</div>
<div id="footer"></div>