1
0
mirror of https://github.com/flarum/core.git synced 2025-08-10 18:35:56 +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]) return Promise.all([$container.promise(), this.state.loadPromise]).then(() => {
.then(() => { const index = $item.data('index');
m.redraw(true); this.updateScrubber();
return $(window).scrollTop($(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop()); m.redraw(true);
}) const scroll = index == 0 ? 0 : $(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop();
.then(() => { $(window).scrollTop(scroll);
return this.calculatePosition(); this.calculatePosition();
}) this.state.unpause();
.then(() => this.state.unpause()); });
} }
/** /**