nicklockwood/iCarousel — Issue #75: Help with custom transform
Author: lexar
Created: 2012-01-08 14:17:56+00:00
State: open

Dear all,

a view months ago I asked for advice on a custom carousel type that should be a mix of rotary and linear carousel.
I came up with a solution that sort of achieved what I wanted, but I knew back then already that it was flawed. Now it has come back to haunt me: There is a brief, but unacceptable twitching/stuttering visible when two imageviews have the same size within the carousel. I am pretty sure my transform below is not the best way to do this, and I am trying to improve it.

Could anyone give me advice how to improve this transform algorithm, or some pseudo code, and/or where I should start reading to get a better understanding of transforms? I googled a lot, but couldn't find some basics on transforms with some practical examples.

To see the way I would like the carousel to look (but with a less stuttering animation), please add the following carousel type to transformForItemView:withOffset:

case iCarouselTypeLinear2:
{
NSInteger count = MIN(numberOfVisibleItems, numberOfItems + (shouldWrap? 0: numberOfPlaceholdersToShow));
CGFloat arc = M_PI * 2.0f;
CGFloat radius = itemWidth / 2.0f / tanf(arc/2.0f/count);
CGFloat angle = offset / count * arc;
CATransform3D newTransform = CATransform3DTranslate(transform, radius * sin(angle), 0.0f, radius * cos(angle) - radius);
return CATransform3DTranslate(newTransform, offset * itemWidth, 10.0f, 10.0f);
}

I added a new reply to the old issue, but don't have permission to reopen it, so I think it remains unnoticed - hence the new issue. Sorry if that was wrong.

Thanks a lot for reading!

l