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

Try calculating index before redraw to avoid calling redraw immediately after scroll

This commit is contained in:
Alexander Skvortsov
2020-07-07 19:06:12 -04:00
committed by Franz Liedke
parent 2360745237
commit ef206495cd
2 changed files with 7 additions and 8 deletions

View File

@@ -348,15 +348,12 @@ export default class PostStream extends Component {
}
}
return Promise.all([
$container.promise(),
this.state.loadPromise
]).then(() => {
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(() => {
//if (this.state.locationType == 'number') this.updateScrubber();
return this.calculatePosition();
})
.then(() => this.state.unpause());

View File

@@ -20,10 +20,8 @@ class PostStreamState {
this.loadPageTimeouts = {};
this.pagesLoading = 0;
this.show(includedPosts);
this.locationType = null;
this.index = (this.visibleEnd - this.visibleStart) / 2;
this.index = 0;
this.number = 1;
/**
@@ -39,6 +37,8 @@ class PostStreamState {
* @type {String}
*/
this.description = '';
this.show(includedPosts);
}
/**
@@ -125,6 +125,7 @@ class PostStreamState {
show(posts) {
this.visibleStart = posts.length ? this.discussion.postIds().indexOf(posts[0].id()) : 0;
this.visibleEnd = this.sanitizeIndex(this.visibleStart + posts.length);
this.index = (this.visibleEnd - this.visibleStart) / 2;
}
/**
@@ -137,6 +138,7 @@ class PostStreamState {
reset(start, end) {
this.visibleStart = start || 0;
this.visibleEnd = this.sanitizeIndex(end || this.constructor.loadCount);
this.index = (this.visibleEnd - this.visibleStart) / 2;
}
/**