|
||
| Inside Technique : Auto-Scrolling Viewports : The Code To handle the cross-browser issues, we wrote our script using
our cross-browser DHTMLLib. This library exposes
a compatible subset of Internet Explorer's object model in Netscape. For this reason,
you will notice the script contains no browser detection.
To start an auto-scrolling viewport, you create a repeating timer that calls the doMarquee function.
To run cross-browser, this cannot be called until after the page is loaded:
The doMarquee function has 3 arguments (third is optional). The first argument is the direction, left, right, up, or down, the second argument is the string ID of the DIV to scroll, and the last optional argument is how many pixels to scroll on each tick. You can control the speed and smoothness of the animation by modifying the amount and the interval of the timer (the 100 in the doMarquee call above). The interval is specified in milliseconds. To stop the marquee, you just call clearInterval on the return value of the setInterval call:
If you want to switch directions of the marquee, we recommend first stopping the marquee and then starting it again in the new direction. When
starting the marquee in a new direction, it will continue from the existing offsets. You can also reset the either the top or left offset simply by setting
the top or left of the scrolling contents:
Multiple Scrolling ViewportsThis script is designed to allow multiple simultaneously scrolling viewports. While this is syntactically very simple, we have had problems with Netscape when multiple positioned DIV's are placed on the page. Therefore, be sure to test your pages when defining multiple scrolling regions. Multiple auto-scrolling viewports are created by defining muultiple viepworts. Each of the viewport content DIV must have a unique ID. Next, you just create a timer calling the doMarquee function for each DIV. You should assign each return value to the timer to a unique variable if you wish to later stop the scrolling. Page 1:Auto-Scrolling Viewports © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |