Added pageYOffset to top position calculation to allow for page scroll before flips