In this second part of a five-part series, we will see how the inner DIV element (pane) can scroll from the top of the outer DIV element, downward. We shall also see how to make the left edge of your web page respond to events, and how the pane can scroll out of it.
In this section we see how the inner DIV element can be made to scroll from the top downward. Here, instead of changing the CSS left value, we shall be changing the CSS top value. The height of the inner DIV element is 196px. So the initial top value of the inner DIV element is –196px. This value should be written as a CSS attribute to the inner DIV element and not in the style sheet. I gave the reason in the previous part of the series.
The default left value is zero pixels. So you can omit the left attribute (style). With these factors, the inner DIV element will start scrolling from the top. This is the script which will accomplish that:
var y = document.getElementById('Calc').style.top;
y = parseInt(y);
var TT = self.setInterval("shiftDown()",10);
document.getElementById('Calc').style.top = y;
if (y >= 0)
document.getElementById('Calc').style.top = "0px"
Replace the former script with this one. Put the script below the DIV elements. The operation of this and the former scripts are the same. However, the variables and the left attribute value have changed. Instead of x, for horizontal distance, we have y. The choice of y is just to make things consistent with the Cartesian coordinate system, where horizontal distance is identified by the x variable and vertical distance is identified by the y variable.
The ID returned by the setInterval() function is now TT instead of TL. The shiftRight() function is now shiftDown(). The CSS left attribute for the inner DIV object is now "top" instead of "left." Everything else stays the same. The script is then self-explanatory.