Creating a Javascript Animation from Scratch