Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Error when set start position #22

Closed
pracj3am opened this Issue Aug 15, 2010 · 5 comments

Comments

Projects
None yet
2 participants

I'm gettig error "Error: jCarousel: No width/height set for items...", when I set start index > 1 (no problem for start = 1) in this example:
http:doubleslash albion.dev.intya dot cz/jcarousel-bug.html
(i.e. when it is impossible to scroll start item to the left margin of the carousel).

I expect that in this case carousel should scroll to the left as much as possible even if the start item would not be on the outermost left.

I also found out, that error magically disappears if i set margin to items. But for start=4, the item "Two" is on the start position and the item "Four" stays partially hidden.

Tested in FF 3.5.11

Owner

jsor commented Aug 15, 2010

This is a common problem. The point is, that there is no width defined for the items and because of that, jcarousel isn't able to get the actual widths to do required calculations. The only solution right now is to explicitly define a width for the items.

But it is strange, that it works if start = 1 or if a margin of items is set to non-zero value.
Problems is that the width of a item depends on its content. It would be useful if the width could be measured it in itemFallbackDimension using jQuery's width(), but the fallback would have to have the item as a parameter.

I have explicitly defined width of the items using
$('.jcarousel').children().width(function(){
return $(this).children().width();
});
(before jcarousel is initialized) but nothing changed at all. The problem is still same as I described in original report.

Owner

jsor commented Aug 16, 2010

Try to add the following css:

.jcarousel-skin-intya .jcarousel-item-placeholder {
    width: 100px;
}

I expect that in this case carousel should scroll to the left as much as possible even if the start item would not be on the outermost left.

You can consider this as a "bug". jCarousel sees an item as visible also if its only partially visible. I will add a patch to force an item being completely visible if its defined as the start item.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment