mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Provide location data to scrubber earlier to avoid unnecessary and confusing scrubber animation on page load.
This commit is contained in:
parent
304f05be36
commit
963c27ed60
|
@ -330,6 +330,7 @@ export default class PostStream extends Component {
|
||||||
*/
|
*/
|
||||||
scrollToItem($item, animate, force, bottom) {
|
scrollToItem($item, animate, force, bottom) {
|
||||||
const $container = $('html, body').stop(true);
|
const $container = $('html, body').stop(true);
|
||||||
|
const index = $item.data('index');
|
||||||
|
|
||||||
if ($item.length) {
|
if ($item.length) {
|
||||||
const itemTop = $item.offset().top - this.getMarginTop();
|
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
|
||||||
this.updateScrubber();
|
// to the scrubber as soon as possible. This way, we avoid an unnecessary
|
||||||
this.stream.forceUpdateScrubber = true;
|
// 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();
|
m.redraw.sync();
|
||||||
|
|
||||||
// After post data has been loaded in, we will attempt to scroll back
|
// After post data has been loaded in, we will attempt to scroll back
|
||||||
|
|
Loading…
Reference in New Issue
Block a user