PDA

View Full Version : How to control scrolling speed on gAJAX RSS Pausing Scroller



mdmick
11-23-2008, 04:56 PM
1) Script Title: gAJAX RSS Pausing Scroller

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex18/gajaxpausescroller.htm

3) Describe problem: How can I control the speed of the scroller?

Thanks.

cam815
11-25-2008, 12:41 AM
I had the same question today - found your thread with no answers...

So I did some digging and figured it out. Registered here just to get you the reply ;)

In the file gajaxscroller.php around Line 109, _animateup is defined:


// -------------------------------------------------------------------
// _animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

gfeedpausescroller.prototype._animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance._animateup()}, 40)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this._swapdivs()
setTimeout(function(){scrollerinstance._rotatemessage()}, this.delay)
}
}

The important numbers:

40: Number of milliseconds between movement. The lower the number, the 'smoother' the movement. However be warned, this WILL up the client's CPU usage.

5: Number of pixels to move per movement interval listed above.

So the default setting is to move the text up 5 pixels every 40 milliseconds.

For example, changing 40 to 80 will make the scrolling 'slower', but it will look jittery as it's still moving 5 pixels, just at a slower rate.

Changing 5 to 2 will make the scrolling seem slower as it's only moving 2 pixels every 40ms, but will up the CPU usage.

Finding a happy medium that you like will be up to you.

I'm happy with 40 and 2.

lisag
12-17-2008, 07:01 PM
Thanks for your help cam815! I was looking for this answer, came across this post, and was able to implement it quickly...
Thanks again!