Home arrow HTML arrow Page 2 - Scrolling Functions for HTML Magic Edges
HTML

Scrolling Functions for HTML Magic Edges


Welcome to the third part of a five-part series that explains how to create magic edges -- edges of web pages from which items can be scrolled -- using HTML. In this part, we continue with the basics of scrolling from the left edge. We shall complete the basics in this part, and then we shall begin the project.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
March 23, 2009
TABLE OF CONTENTS:
  1. · Scrolling Functions for HTML Magic Edges
  2. · The shiftRight() Function
  3. · Removing the Pane
  4. · The Project

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Scrolling Functions for HTML Magic Edges - The shiftRight() Function
(Page 2 of 4 )

This function shifts the inner DIV to the right and stops when the CSS left position is greater than or equal to zero. This is the function:  

function shiftRight()

{

document.getElementById('Calc').style.left = x;


//stop scrolling right

if (x >= 0)

{

self.clearInterval(TR);

//adjust position

document.getElementById('Calc').style.left = "0px";

}


x+=3;

}


We have to start shifting from the current left position of the inner DIV element, which is –205px. So the first statement gives the position of x (which at the start is -205) to the CSS left attribute of the inner DIV. The last statement in the function increments this value by 3, so that the next time the first statement is called, the position of the inner DIV will move to the right by 3px.

After the first statement, you have an if-statement. The if-statement tests to see if the left-top position (represented by x) is greater than or equal to zero. If it is, it stops the shifting by calling the DOM’s clearInterval(TR) method. It uses the return ID of the setInterval() method to achieve this.

The position of x = 0 is where the inner DIV just fits into the outer DIV and can be seen by the user. Based on the shifting algorithm (adding 3px), it is possible that when the shifting stops, the x position would not be zero. The second line in the if-statement corrects this.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials