What I want to do is when a user hovers over it, to pause the interval, and when they mouse out resume where it left off
If you want it to pause the interval and resume in the middle of the interval (say it is a large interval, maybe a second or more), then you could use code from this other question, showing how to interrupt and resume an interval exactly where it was left off.
All I want to do is have a div that shows new posts from users, one at a time
Using the code from the other question, here is some code to trigger a chain on a list, setting current
on each item and fading it in, until all are shown:
var currentTimer;
var timeBetween = 500;
function hideCurrentAndSetUpNext()
{
var current = $('ul li.current:last');
current.fadeIn();
var next = current.next();
if(next != null)
{
next.addClass('current');
currentTimer = new Timer(hideCurrentAndSetUpNext, timeBetween);
}
}
currentTimer = new Timer(hideCurrentAndSetUpNext, timeBetween);
$('ul li').hover(
function() {
currentTimer.pause();
},
function() {
currentTimer.resume();
}
);
Here is a fiddle demonstrating this code: