2 items will not wrap
scrypter - October 22, 2009 - 21:53
| Project: | jCarousel |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
The carousel works fine except when there are two items and scroll by 1. Clicking next when first displayed does nothing, then the next click advances to item 2. No amount of clicking next will get it to wrap back to item 1. If I add a third item all is good. I have no prev button. Have tried wrap set to last and both, no diff. I put an alert in the js and it appears to be calculating the pos incorrectly in the pos method. This is used by animate to set the css left on the ul to give the effect of horizontal scrolling.
Anyone else seen this, or know of a fix?

#1
Fixed by getting the css widths of jcarousel containers exactly right. The left position has to be calculated in multilples of the item width and any discrepancy causes strife.
As an aside, I managed to get jcarousel working inside quicktabs. jcarousel won't calculate widths of hidden divs etc so i made a hack for jcarousel.js to use the css widths instead of offsetWidth so it sets up everything up OK even for the hidden carousels. Happy to provide if anyone is desparate.