Fixed calculation of scrolling offset