I have a list item which scrolls up and appends the first item on the list to the bottom every 5 seconds but my the problem is that, i would like the entire list to scroll for better syn. The demo of the code is here. If you watch closely, only the 2nd, 3rd and 4th item scroll up...What can i do to improve this please?
Asked
Active
Viewed 208 times
0
-
working fine in chrome & FF. in which browser are u having problems? – sv_in Mar 30 '11 at 15:12
1 Answers
0
What happens on the "the 2nd, 3rd and 4th item scroll up"?
Anyway, this is what I believe is a better version:
function test() {
var a= $("ul li:first-child");
a.slideUp("slow", function(){
a.appendTo("ul").slideDown();
});
};
window.setInterval(test, 1000);
EDIT:
function test() {
var a= $("ul li:first-child");
a.slideUp("slow", function(){
$(this).remove();
});
var b = a.clone();
b.appendTo("ul").hide().slideDown();
};
window.setInterval(test, 1000);
Example: http://jsfiddle.net/2DNV3/20/
EDIT 2:
Example: http://jsfiddle.net/qsem9/
var scroll = function(){
var first = $("#scroll > li:eq(0)");
var last = first.clone().appendTo("#scroll");
$("#scroll").animate({ "scrollTop": first.outerHeight() }, 500, function(){
first.remove();
});
window.setTimeout(scroll, 1000);
};
$("#scroll").css({ height: $("#scroll").outerHeight() });
scroll();
This way, you have seamless scrolling no matter what - because it is actually scrolling. ;)

mattsven
- 22,305
- 11
- 68
- 104
-
The the 2nd, 3rd and 4th are fine but is it possible to make the first item slide up just the way the 2nd, 3rd and 4th are...? – gables20 Mar 30 '11 at 15:32
-
brilliant...but as soon as i add a height of 30px to the css...it looks like the previous code? – gables20 Mar 30 '11 at 16:17
-
sorry i meant if you add li { height: 30px; }, you would notice that the first item is not sliding up, instead it is replaced by the 2nd item..can't the entire list slide up in one syc? – gables20 Mar 31 '11 at 09:59
-
Nice example, but is there a reason you can't use the ticker used there? – mattsven Mar 31 '11 at 14:01
-
Not neccessarily, would just like to know how to extend my code to accomodate this.. – gables20 Mar 31 '11 at 14:04