The if statement needs to be put in the function that is called in the a...

...nimate for it to function properly. Another way is to use a setTimeout function on the if statement with milliseconds greater than 1000 (the animate time).