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

Strange card deletion animation #66

Closed
achirkof opened this issue Oct 26, 2017 · 2 comments
Closed

Strange card deletion animation #66

achirkof opened this issue Oct 26, 2017 · 2 comments
Labels

Comments

@achirkof
Copy link

Hi!
Thanks for this amazing extension!

My question is how I can override card deletion animation which behaviour is strange.

remove_animation

As you can see on GIF when I tap green button it executes collectionView.deleteItems(at: indexPath) and animation is very strange.
First card climb to very top and then go down and disappearing.

I would like to card starting go down to the bottom from current position without rising up. How I can override CollectionViewFlowLayout attributes?

@achirkof
Copy link
Author

I made an extension to override deletion animation. But it didn't solve problem when card jumps top before deletion.

extension PageCollectionLayout {
    
    override func prepare(forCollectionViewUpdates updateItems: [UICollectionViewUpdateItem]) {
        super.prepare(forCollectionViewUpdates: updateItems)
        removingIndexPaths.removeAll()
        
        for update in updateItems {
            if let indexPath = update.indexPathBeforeUpdate, update.updateAction == .delete {
                removingIndexPaths.append(indexPath)
            }
        }
    }
    
    override func finalizeCollectionViewUpdates() {
        super.finalizeCollectionViewUpdates()
        removingIndexPaths.removeAll()
    }
    
    override func finalLayoutAttributesForDisappearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
        let attributes = super.finalLayoutAttributesForDisappearingItem(at: itemIndexPath)
        
        if removingIndexPaths.contains(itemIndexPath) {
            attributes?.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
        }
        print(attributes)
        return attributes
    }
}

@aleksei1000000 could you please help me to understand why it happening?
Thanks

@0ber 0ber added the bug label Jan 25, 2018
@0ber 0ber closed this as completed in fc70562 Jan 29, 2018
@achirkof
Copy link
Author

@ober01 great! Thank you very much! 🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants