nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
11.99k stars 2.58k forks source link

is there anyway to make it looks like infinite when there is only 2 items #873

Closed coderxdotwang closed 5 years ago

coderxdotwang commented 5 years ago

with wrap on, and iCarouselOptionVisibleItems/iCarouselOptionCount set to 3, but when there is only 2 items, eg. view0 view1, only 2 views are visible all the way, the expected effect is 'view1, view0, view1' are visible by default, and when scroll to index 1, then 'view0, view1, view0' are visible, is there any way to achieve this? thanks in advance

nicklockwood commented 5 years ago

@coderwangxx iCarousel won’t display the same item more than once in a single carousel, but you can achieve this by adding duplicate items to the carousel data source.

So in your case, if items.count is < 3 return items.count * 2 to iCarousel and return a view for items[index % items.count] in your viewForItem dataSource method.

coderxdotwang commented 5 years ago

@nicklockwood thanks for the response :)tried the exactly method as your suggestion, works fine.🍻