Fixed calculating scroll offset