How to chain functions

If it’s jQuery that you’re dealing with, you can use the animate complete function that gets triggered when the animation has finished.