Calculate where to scroll to based off the position in the div

Also, only scroll if not currently visible.
Merge pull request #871 from simonwelsh/3.1-scroll

Calculate where to scroll to based off the position in the div