Richard
Richard

Reputation: 1474

jQuery vertical text scroll

I have the following code, and it's behaving differently in CodePen, JSFiddle and in my browser. It only works perfectly in CodePen.

Essentially I would like it to infinitely scroll from top to bottom without stopping.

Here are both examples of the code in action, http://jsfiddle.net/qmFD3/ and http://codepen.io/anon/pen/fiaql

function scroller() {
  $('#honor-roll ul').animate({
    top: '-=' + $('#honor-roll ul li:last').height()
  }, 1000, 'linear', function () {
    var offset = $('#honor-roll ul li:last').offset().top;
    console.log(offset);
    if (offset <= 2000) {
      $('#honor-roll ul').css("top", 0);
      $('#honor-roll ul li:last').after($('#honor-roll ul li:first').detach());
    }
  });
}
$(document).ready(function () {
  setInterval('scroller()', 200)
});

Upvotes: 0

Views: 660

Answers (1)

Chris Bier
Chris Bier

Reputation: 14447

In jsFiddle the console is saying:

Uncaught ReferenceError: scroller is not defined
(anonymous function)

Upvotes: 1

Related Questions