aataraxiaa / ScalingCarousel

A super simple carousel view with scaling transitions written in Swift
MIT License
756 stars 98 forks source link

Sometimes cell too big #15

Closed MartijnSchoemaker closed 6 years ago

MartijnSchoemaker commented 7 years ago

I found a bug that the third visible cell is too big when pushing a new view controller. Pushing a new viewcontroller results in calling 'didScroll' which effects in wrong calculation; percentScaling is 2. (where it should be 0 or 1). When coming back on the viewcontroller with ScalingCarousel on it, the third cell has wrong size.

I'm not familiar enough with the code to find a solid solution but for now I did this change locally in ScalingCarouselCell.swift:

-        let percentageScale = (scaleCalculator/width)
+        var percentageScale = (scaleCalculator/width)
+        percentageScale = percentageScale > 1 ? 0 : percentageScale

Maybe you could fix this with a more solid solution?

aataraxiaa commented 7 years ago

Thanks @MartijnSchoemaker, I'll look in to this as soon as I can

matt-alltrails commented 6 years ago

I ran into this issue as well. I tracked the issue to this line in ScalingCarouselCell:

let originX = superview.convert(frame, to: nil).origin.x

Passing nil causes the value to be based on the window, but the window offset changes during a push. As an experiment I changed it to this and it worked for my particular case:

let originX = superview.convert(frame, to: superview.superview).origin.x

I think the full solution would be to find whatever view is the superview of the ScalingCarouselView and use it as the reference.

matt-alltrails commented 6 years ago

Also, THANK YOU for leaving your classes open.

aataraxiaa commented 6 years ago

Thanks @MartijnSchoemaker and @matheda, I just published v2.0.3. Issue should be resolved. Closing this.