views:

161

answers:

1

Currently I'm trying to make some sort of vertical auto-scrolling. This is my code

$(document).ready(function() {
var reachEnd = false;
var top = 0;
function animateMargin(){
    if(top == -720){
        reachEnd = true;
    }
    if(reachEnd == false){
        $('#bslider').animate({'marginTop' : '-=240px'}, 500);
        top -=240;
    }else{
        $('#bslider').animate({'marginTop' : '0px'}, 1000);
        top = 0;
        reachEnd = false;
    }
};
marginInterval = setInterval('animateMargin()', 5000);
$('#banner').hover(function(){
    clearInterval( marginInterval );
    },
    function(){
        marginInterval = setInterval('animateMargin()', 5000);
    });
});

And it's not working - at all.

Any ideas?

+1  A: 

You seem to be passing the function callback to setInterval incorrectly. Try this instead.

setInterval( animateMargin, 5000 );
bobthabuilda
it worked, thanks!
Warrantica