Last active
August 29, 2015 13:56
-
-
Save wangwen1220/9067408 to your computer and use it in GitHub Desktop.
jq: 单行滚动文字 | jq scrolltimer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 单行滚动文字 | |
| 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