AnimatedCollectionViewLayout
AnimatedCollectionViewLayout copied to clipboard
Blinking parallax on iPhone 8 plus
There is a problem scrolling 1-st and 2-nd pages. Pages are blinking during slow scrolling. For pages number higher than 3 it works fine. Reproduced on iPhone 8 plus so far for example app.
https://monosnap.com/file/nZNyO1yi7bhA7p9peXotsrxKNqKexJ
Seems like replacing
if direction == .horizontal {
let width = collectionView.frame.width
let transitionX = -(width * speed * position)
let transform = CGAffineTransform(translationX: transitionX, y: 0)
let newFrame = attributes.bounds.applying(transform)
contentView.frame = newFrame
}
with
if direction == .horizontal {
let width = collectionView.frame.width
let transitionX = -(width * speed * position)
var newFrame = attributes.bounds
newFrame.origin.x = transitionX
contentView.frame = newFrame
}
solves the problem
Wow, nice finding. Ideally the applying method should work exactly the same as setting the origin ourselves. Feels like a UIKit bug or something.