mirror of
https://github.com/flarum/core.git
synced 2025-08-08 17:36:38 +02:00
Fix jumping around on page reload
This commit is contained in:
committed by
Franz Liedke
parent
cc10eaadd2
commit
2360745237
@@ -290,7 +290,7 @@ export default class PostStream extends Component {
|
|||||||
console.log('scrollToNumber');
|
console.log('scrollToNumber');
|
||||||
const $item = this.$(`.PostStream-item[data-number=${number}]`);
|
const $item = this.$(`.PostStream-item[data-number=${number}]`);
|
||||||
|
|
||||||
return this.scrollToItem($item, noAnimation).done(this.flashItem.bind(this, $item));
|
return this.scrollToItem($item, noAnimation).then(this.flashItem.bind(this, $item));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,7 +306,7 @@ export default class PostStream extends Component {
|
|||||||
console.log('scrollToIndex');
|
console.log('scrollToIndex');
|
||||||
const $item = this.$(`.PostStream-item[data-index=${index}]`);
|
const $item = this.$(`.PostStream-item[data-index=${index}]`);
|
||||||
|
|
||||||
return this.scrollToItem($item, noAnimation, true, bottom).done(() => {
|
return this.scrollToItem($item, noAnimation, true, bottom).then(() => {
|
||||||
if (index == this.state.count() - 1) {
|
if (index == this.state.count() - 1) {
|
||||||
this.flashItem(this.$('.PostStream-item:last-child'));
|
this.flashItem(this.$('.PostStream-item:last-child'));
|
||||||
}
|
}
|
||||||
@@ -348,18 +348,18 @@ export default class PostStream extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $container.promise().then(() => {
|
return Promise.all([
|
||||||
|
$container.promise(),
|
||||||
this.state.loadPromise
|
this.state.loadPromise
|
||||||
.then(() => {
|
]).then(() => {
|
||||||
m.redraw(true);
|
m.redraw(true);
|
||||||
$(window).scrollTop($(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop());
|
return $(window).scrollTop($(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop());
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.calculatePosition();
|
//if (this.state.locationType == 'number') this.updateScrubber();
|
||||||
if (this.state.locationType == 'number') this.updateScrubber();
|
return this.calculatePosition();
|
||||||
})
|
})
|
||||||
.then(() => this.state.unpause());
|
.then(() => this.state.unpause());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -20,8 +20,10 @@ class PostStreamState {
|
|||||||
this.loadPageTimeouts = {};
|
this.loadPageTimeouts = {};
|
||||||
this.pagesLoading = 0;
|
this.pagesLoading = 0;
|
||||||
|
|
||||||
|
this.show(includedPosts);
|
||||||
|
|
||||||
this.locationType = null;
|
this.locationType = null;
|
||||||
this.index = 0;
|
this.index = (this.visibleEnd - this.visibleStart) / 2;
|
||||||
this.number = 1;
|
this.number = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,8 +39,6 @@ class PostStreamState {
|
|||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
this.description = '';
|
this.description = '';
|
||||||
|
|
||||||
this.show(includedPosts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -270,6 +270,7 @@ class PostStreamState {
|
|||||||
() => {
|
() => {
|
||||||
this.loadRange(start, end).then(() => {
|
this.loadRange(start, end).then(() => {
|
||||||
if (start >= this.visibleStart && end <= this.visibleEnd) {
|
if (start >= this.visibleStart && end <= this.visibleEnd) {
|
||||||
|
console.log('anchoring!');
|
||||||
const anchorIndex = backwards ? this.visibleEnd - 1 : this.visibleStart;
|
const anchorIndex = backwards ? this.visibleEnd - 1 : this.visibleStart;
|
||||||
anchorScroll(`.PostStream-item[data-index="${anchorIndex}"]`, () => m.redraw(true));
|
anchorScroll(`.PostStream-item[data-index="${anchorIndex}"]`, () => m.redraw(true));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user