Fix issue with calculation of scroll movement