Closed rpitting closed 13 years ago
iCarousel doesn't support this at the moment. There are a few options to solve this:
1) Use the placeholder view functionality to fill in the gaps at the end (this solution was provided to prevent unsightly gaps at the ends of carousels)
2) In the didScroll delegate method, if the user scrolls to an index less than 1 or greater than numberOfItems - 2, automatically scroll the view back so that it snaps to index 1 or numberOfItems - 2. That way there will never be a gap at the ends, except temporarily while the user is dragging the carousel.
3) Modify the library to allow the min/max start/end scrolling index to be specified. This would be similar to option 2, but by modifying the library you could make the stop/bounce effect at each end a bit nicer.
1 - doesn't work if you need to avoid all the empty space (and even give less space to item sequence than it requires) 2 - looks awful because an user may scroll as if nothing is changed and only at the end of touch event the scroll jumps to the correct position 3 - works! but we need to rewrite your library (not inheritance) because you provide the same methods for start/end index for both scrolling and one item actions. If we don't rewrite your library then we will have incorrect distances in the top and bottom of carousel or vice versa we couldn't operate with some indexes (for example remove them)
@gerchicov-bp Hi,can you show me the code how u rewrite the library?thank you very much!
@chx632996066 Hello, sorry but I can't due to my employer's rules. The only hint I can say is iCarousel uses a formula which involves integer index param but you need to pass into this formula a float/double param. So anyways you need to edit this formula in library
Did you find solution? Thanks!
If you configure your carousel to be of the linear type and set wrapping to
NO
, your first and last item also is centered in the view. This results in empty space on the left (first item) and right (last item).Is it possible to configure the carousel so that when you are at item-index 0, the first item will be at the very left of the view, and vice versa that the carousel ends with the last item being on the very right? Or does that just conflict with the
scrollOffset
-property?