Calculating scroll amount only once