DCJones
DCJones

Reputation: 3461

Javascript/Jquery - too much recursion

I am working on a script that scrolls table data in a continuous loop. The issue I have is, I keep getting the following error:

"too much recursion".

Does anyone know how I can use the script without this error happening?

$.fn.confScrollUp=function(){

var self=this,conf=self.children()
setInterval(function(){
    conf.slice(30).hide()
    conf.filter(':hidden').eq(0).slideDown()
    conf.eq(0).slideUp(4000, "linear",function(){
        $(this).appendTo(self)
        conf=self.children()
    })
},1)
return this;
}


$(function(){
    $('section').confScrollUp()
})

There is not user interaction, its just for displaying data.

Upvotes: 0

Views: 62

Answers (1)

Andy
Andy

Reputation: 63524

This seems to work error-free if you increase the setInterval interval. Here I've chosen 100 to go along with the increase in the slider value to 4000.

$.fn.infiniteScrollUp=function(){
    var self=this,conf=self.children()
    setInterval(function(){
        conf.slice(10).hide();
      conf.filter(':hidden').eq(0).slideDown()
      conf.eq(0).slideUp(4000, "linear",function(){
        $(this).appendTo(self);
        conf=self.children();
      });
    },100)
    return this;
}

Upvotes: 1

Related Questions