Skip to content

Instantly share code, notes, and snippets.

@davidgtonge
Created November 30, 2011 12:26
Show Gist options
  • Save davidgtonge/1408899 to your computer and use it in GitHub Desktop.
Save davidgtonge/1408899 to your computer and use it in GitHub Desktop.
simple infinite scroller
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