aataraxiaa/ScalingCarousel

Custom scaling of items?

Closed this issue · 6 comments

Is there currently a way to change the minimum scale of the items. To match the designs I was given I need the middle item to either be larger or the outer items to be smaller. I noticed that the scaleMinimum is set to 0.9 by default but I don't see any way of changing it. Is there something I'm not seeing to do this or Should I try and open a PR to add that functionality. Other than this one small issue the library has been working great for what I've needed. Cheers!

Forgot to mention I have to consume via cocoa pods so I can't just include the three classes and change the scale minimum just for this project :(

Tried subclassing and overriding scale() with a smaller value and realized it affected all the items in the collection view. I believe ScaleDivisor may be the value that I need to find a way to change?

Hi @JulianHunt, glad you like the library. The best way to do this would be to subclass ScalingCarouselCell, and override the scale function, changing the default parameter which is currently defined for this function to whatever value you want, e.g

override open func scale(withCarouselInset carouselInset: CGFloat,
                    scaleMinimum: CGFloat = YOUR_VALUE) {
// HERE, JUST CALL SUPER, PASSING IN YOUR SCALE VALUE
...
}

Right I had actually tried this however that just shrank all the items in the carousel, is there a way to change the size difference/scale between the selected item and the non selected items? Cheers!

Apologies, I didn't correctly read your previous comment, never realised you tried it already! I don't have time to look at this today, but I think you will need to override the scale function and add your own custom calculations. Maybe just grab the code from the original scaling function, and play around with them in your overriding method.

Hi @JulianHunt. I just published version 2.2 of ScalingCarousel, which exposes the properties you wish to alter. When overriding ScalingCarouselCell, you will be able to override the properties and alter the values.