Provide location data to scrubber earlier to avoid unnecessary and confusing scrubber animation on page load.

This commit is contained in:
Alexander Skvortsov 2020-09-25 15:52:18 -04:00
parent 304f05be36
commit 963c27ed60

View File

@ -330,6 +330,7 @@ export default class PostStream extends Component {
*/
scrollToItem($item, animate, force, bottom) {
const $container = $('html, body').stop(true);
const index = $item.data('index');
if ($item.length) {
const itemTop = $item.offset().top - this.getMarginTop();
@ -351,11 +352,16 @@ export default class PostStream extends Component {
}
}
return Promise.all([$container.promise(), this.stream.loadPromise]).then(() => {
// Even before scrolling, we want to provide location information
// to the scrubber as soon as possible. This way, we avoid an unnecessary
// and confusing animation.
this.updateScrubber();
// We manually set the index because we want to display the index of the
// exact post we've scrolled to, not just that of the first post on the page.
this.stream.index = index;
this.stream.forceUpdateScrubber = true;
const index = $item.data('index');
return Promise.all([$container.promise(), this.stream.loadPromise]).then(() => {
m.redraw.sync();
// After post data has been loaded in, we will attempt to scroll back