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

Add Custom Animation #53

Closed
wassimseif opened this issue Dec 14, 2018 · 2 comments
Closed

Add Custom Animation #53

wassimseif opened this issue Dec 14, 2018 · 2 comments

Comments

@wassimseif
Copy link

Is there any way to extend AnimationType to add custom animations using CGAffineTransforms ?
There does not seem any documentation on this

@marcosgriselli
Copy link
Owner

Hey, @wassimseif take a look at the Animation section of the readme. Re-reading this I guess I could've done a better job explaining it and naming the protocol and implementation.

Animation

Animation protocol provides the possibility of expanding the animations supported by ViewAnimator with exception of the animateRandom function.

public protocol Animation {
    var initialTransform: CGAffineTransform { get }
}

You can write your own objects that conform to Animation with simple initialTransform value. Here's a quick flip example:

enum CustomAnimation: Animation {
    case flipHorizontally
    
    var initialTransform: CGAffineTransform {
        switch self {
        case .flipHorizontally:
            return CGAffineTransform(scaleX: -0.5, y: 1)
        }
    }
}

That you can use like this:

UIView.animate(views: tableView.visibleCells, animations: [CustomAnimation.flipHorizontally])

@wassimseif
Copy link
Author

Ahh okay. Thanks for the information. Keep it up 👍

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

No branches or pull requests

2 participants