ApplikeySolutions / VegaScroll

↕️ VegaScroll is a lightweight animation flowlayout for UICollectionView completely written in Swift 4, compatible with iOS 11 and Xcode 9.
https://applikeysolutions.com
MIT License
2.94k stars 178 forks source link

Perform strange when changing item width #6

Closed hstdt closed 7 years ago

hstdt commented 7 years ago

iPad Pro, iOS 11.0

vegascroll

LivioGama commented 7 years ago

Funny, I have the same issue with https://github.com/roberthein/BouncyLayout on iPhone X simulator, iOS 11.0 sans titre

altjordao commented 7 years ago

Hi! I think i know the problem. So to do the bounce animation the code is using UIDynamicAnimator if you are using float values to define the width of the cells when the physics engine is calculating the positions for the cells you will have some problem with rounding that values and over time the value rounded will increase.

To fix this try setting cell sizes with round values, like 200 not 200,34782.

Hope this will help!

hstdt commented 7 years ago

@altjordao Thank you. let itemWidth = ( UIScreen.main.bounds.width / 3 - 2 * xInset).rounded(.towardZero) works well.

emgbtg commented 6 years ago

you need to round to the nearest whole even number round(value / 2.0)) * 2