CosmicMind / Motion

A library used to create beautiful animations and transitions for iOS.

Home Page:http://cosmicmind.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Animate back to original state

andrealufino opened this issue · comments

Hello. I'm using Motion to achieve a rotation effect on a button. This is what I'm doing :

if isAdding {
    // Close adding, resetting all stuff
    btnAdd?.animate(MotionAnimation.rotate(45))
    isAdding = false
} else {
    // Open adding
    btnAdd?.animate(MotionAnimation.rotate(-45))
    isAdding = true
}

When I need to rotate back the button, I'm not able to achieve the "back" animation. How can I do? It seems the button starts always from the original position.

Hey! If you want to just revert the rotation to the original state just do:

button.animate(.rotate(0))

Or:

button.animate(.transform(CATransform3DIdentity))

.rotation, .scale, .translate all works through view.layer.transform. Here is nice explanation

Great! Thanks!