Created
November 23, 2011 22:30
-
-
Save todoubled/1390120 to your computer and use it in GitHub Desktop.
Infinitely scroll through an array of items in any direction.
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
| # Shuffle items front and back to flow infinitely | |
| infiniteFlow: () => | |
| last = $("#{@config.id} section.item:last-child") | |
| first = $("#{@config.id} section.item:first-child") | |
| outer = $('.items') | |
| if last.hasClass('right') or last.hasClass('current') | |
| oldLeft = outer.position().left | |
| width = first.width() | |
| newLeft = oldLeft + width | |
| outer.append first | |
| outer.css 'left', newLeft | |
| if first.hasClass('left') or first.hasClass('current') | |
| oldLeft = outer.position().left | |
| width = last.width() | |
| newLeft = oldLeft - width | |
| outer.prepend last | |
| outer.css 'left', newLeft |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment