How to write animation code so animations are performant