Skip to content

Instantly share code, notes, and snippets.

@wangwen1220
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save wangwen1220/9067408 to your computer and use it in GitHub Desktop.

Select an option

Save wangwen1220/9067408 to your computer and use it in GitHub Desktop.
jq: 单行滚动文字 | jq scrolltimer
// 单行滚动文字
var scrollTimer;
$('#js-scroller').hover(function() {
clearInterval(scrollTimer);
}, function() {
var $ths = $(this);
scrollTimer = setInterval(function() {
scroller($ths);
}, 2800);
}).trigger('mouseleave');
function scroller($obj) {
var height = $obj.find('li').height(); // 滚动高度
$obj.find('li').first().animate({marginTop: -height}, 500, function() {
$(this).appendTo($obj).css('margin-top', 0);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment