Animate back to original state
andrealufino opened this issue · comments
Andrea Mario Lufino commented
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.
Orkhan Alikhanov commented
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
Andrea Mario Lufino commented
Great! Thanks!