Move out the code for the animation from the directive