Handle loop in animations.