Animate only when the scroll position changes

The previous test had a few issues:

1. Didn't call animateElements when reaching the top of the page
2. Didn't account for float windowHeight and bodyHeight and thus occasionally didn't call animateElements when reaching the bottom of the page
3. Called animateElements even if the scroll position didn't change