Created
November 30, 2011 12:26
-
-
Save davidgtonge/1408899 to your computer and use it in GitHub Desktop.
simple infinite scroller
This file contains 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
scroller = (elem, width, initialised = false) -> | |
multiple = 1 | |
unless initialised | |
if width < 960 | |
mutiple += Math.floor(960 / width) | |
cloned = (elem.text() for i in [1...multiple]).join('...') | |
elem.text cloned | |
animateBy = multiple * width | |
elem.animate | |
marginLeft: "-=#{animateBy}" | |
, (width * 30), 'linear', -> | |
elem.css | |
marginLeft:0 | |
scroller(elem, width, true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment