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

Support resetting the animation for reuse #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pinglamb
Copy link

@pinglamb pinglamb commented Dec 8, 2016

I am using RazzleDazzle to animate items in a collection view. The problem I came across is that the cell views are reused and animations configured before need to be cleared. I added #removeAllKeyframes so that I can reuse the same animation object attached to the cell.

The code while preparing cell for collection view:

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! Cell
        var animation: ScaleAnimation // ScaleAnimation as example
        if cell.animation == nil {
            animation = ScaleAnimation(view: cell)
            animator.addAnimation(animation)
            cell.animation = animation
        } else {
            animation = cell.animation!
        }

        animation.removeAllKeyframes()
        // Set up the animation here

        return cell
}

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

Successfully merging this pull request may close these issues.

1 participant