我正在尝试创建一个将不断滚动的“菜单”。我有代码工作,但滚动动画非常波涛汹涌。如何让菜单滚动更流畅?我之前使用过animate(),从来没有遇到过这个问题。连续滚动div菜单动画jumpy
jsFidde:https://jsfiddle.net/pwa0sp75/
JavaScript代码:
$(document).ready(function() {
var currentSpeed = parseInt($("#scrollSpeed").val());
setInterval('scroll()', currentSpeed);
});
function scroll(){
var scrollSpeed = parseInt($("#scrollSpeed").val());
$("#scrollup .divTableBody").animate({ top: '-=' + $('#scrollup .divTableBody .divTableRow:last').height() }, scrollSpeed, 'linear', function() {
var offset = $('#scrollup .divTableBody .divTableRow:last').offset().top;
if (offset <= 1352) {
$('.divTable').css("top", 0);
$('#scrollup .divTableBody .divTableRow:last').after($('#scrollup .divTableBody .divTableRow:first').detach());
}
});
}
我试过了,它仍然表现出它跳到线上到线下,而不是顺畅滚动相同的行为。 – Nate23VT