Start and stop animating when entering/leaveing foreground