PDA

View Full Version : How to pause gAjax RSS Pausing scroller on mouse over?



crogers32
02-06-2009, 04:26 PM
1) Script Title: gAjax RSS Pausing scroller

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

3) Describe problem: Does anyone know how to alter the javascript for this scroller so that when the user mouses over it the scrolling will pause?

ddadmin
02-07-2009, 12:59 AM
The script does that already actually. Or am I misunderstanding your question?

Snookerman
02-07-2009, 01:04 AM
I think they want to be able to stop it while it's running. If it starts moving there's nothing you can do to stop it.

crogers32
02-08-2009, 12:26 AM
That's right Snookerman. I wanted to know if it was possible to stop the scroller from moving up while it was moving by holding the mouse over it.

jscheuer1
02-08-2009, 04:04 AM
There's not much point in stopping it in mid transition, unless you haven't allowed enough room for each item. But I suppose it could be done.

In the gajaxscroller.js file, use this _animateup() function:


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

gfeedpausescroller.prototype._animateup=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance._animateup()}, 100)
else{
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)
}
}
}

and this _rotatemessage() function:


// -------------------------------------------------------------------
// _rotatemessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

gfeedpausescroller.prototype._rotatemessage=function(){
var scrollerinstance=this
var i=this.hiddendivpointer
var ceiling=this.feeds.length
this.hiddendivpointer=(i+this.itemsperpage>ceiling-1)? 0 : i+this.itemsperpage
var feedslice=this.feeds.slice(this.hiddendivpointer, this.hiddendivpointer+this.itemsperpage)
this.hiddendiv.innerHTML=formatrssmessage(feedslice, this.showoptions, this.itemcontainer, this.linktarget)
this._animateup()
}

Replace the existing functions of the same name with the above ones.

crogers32
02-15-2009, 01:53 PM
That worked perfectly! Thanks John.