Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems appearing cells before the animation starts. #12

Closed
alexanderkhitev opened this issue Nov 2, 2017 · 4 comments
Closed

Problems appearing cells before the animation starts. #12

alexanderkhitev opened this issue Nov 2, 2017 · 4 comments
Assignees
Labels

Comments

@alexanderkhitev
Copy link

Hello! Thanks for the wonderful framework! I ran into the problem that UICollectionView cells appear before the animation starts, at this point the cells are loading photos and the user names are already visible. Please tell me how can this be avoided?

                self?.collectionView.refreshControl?.endRefreshing()
                let offset = UIScreen.main.bounds.width
                let fromAnimation = AnimationType.from(direction: .left, offset: offset)
                let animationInterval = 0.1
                self?.collectionView.animateViews(animations: [fromAnimation], initialAlpha: 1, finalAlpha: 1, delay: 0, duration: 0.4, animationInterval: animationInterval, completion: {
                    
                })
                self?.collectionView.reloadData()

https://monosnap.com/file/MgYyNwEbBqeMdyI4jedYBPMf0uIKOQ

1

@marcosgriselli
Copy link
Owner

If you're animating from outside the view I recommend you hide the views then reload the data and then apply the animation.

self?.collectionView.refreshControl?.endRefreshing()
let offset = UIScreen.main.bounds.width
self?.collectionView.prepareViews()
self?.collectionView.reloadData()
let fromAnimation = AnimationType.from(direction: .left, offset: offset)
let animationInterval = 0.1
self?.collectionView.animateViews(animations: [fromAnimation], initialAlpha: 1, finalAlpha: 1, delay: 0, duration: 0.4, animationInterval: animationInterval, completion: {
                    
})

@alexanderkhitev
Copy link
Author

alexanderkhitev commented Nov 7, 2017

Hello @marcosgriselli ! Sorry for late response. I tried to do so it did not help me. This happens only during the first loading screen, in the future it works.

Also I did so, but it did not help me

self?.collectionView.prepareViews(initialAlpha: 0)
self?.collectionView.reloadData()

@marcosgriselli
Copy link
Owner

@alexanderkhitev prepareViews will not work if there are no cells to prepare 😕. You'll have to do some workaround. The shortest path to get it could be

self?.collectionView.alpha = 0
self?.collectionView.reloadData()
self?.collectionView.prepareViews(initialAlpha: 0)
self?.collectionView.alpha = 1

Or setting te cell alpha to 0 on cellForItem() only for the first load.

@alexanderkhitev
Copy link
Author

@marcosgriselli Yes I tried doing the same method only with isHidden and it also works, thanks!

Repository owner locked and limited conversation to collaborators Nov 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants