1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 17:07:19 +02:00

When scrolling to first post, scroll all the way to top, simplify scrollToItem promise structure

This commit is contained in:
Alexander Skvortsov
2020-07-07 21:46:34 -04:00
committed by Franz Liedke
parent 228c7b883d
commit 88e6be9d0e

View File

@@ -342,15 +342,15 @@ export default class PostStream extends Component {
}
}
return Promise.all([$container.promise(), this.state.loadPromise])
.then(() => {
m.redraw(true);
return $(window).scrollTop($(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop());
})
.then(() => {
return this.calculatePosition();
})
.then(() => this.state.unpause());
return Promise.all([$container.promise(), this.state.loadPromise]).then(() => {
const index = $item.data('index');
this.updateScrubber();
m.redraw(true);
const scroll = index == 0 ? 0 : $(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop();
$(window).scrollTop(scroll);
this.calculatePosition();
this.state.unpause();
});
}
/**