mirror of
https://github.com/flarum/framework.git
synced 2024-12-01 14:20:47 +08:00
Fix jumpy downward post loading
This commit is contained in:
parent
199bbcf5d4
commit
d053b5760e
|
@ -77,13 +77,16 @@ export default Ember.Component.extend({
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If new posts are being loaded in an upwards direction, then when they
|
// If new posts are being loaded in an upwards direction, then when
|
||||||
// are rendered, the rest of the posts will be pushed down the page.
|
// they are rendered, the rest of the posts will be pushed down the
|
||||||
// However, we want to maintain the current scroll position relative to
|
// page. If loaded in a downwards direction from the end of a
|
||||||
// the content after the gap. To do this, we need to find item directly
|
// discussion, the terminal gap will disappear and the page will
|
||||||
// after the gap and use it as an anchor.
|
// scroll up a bit before the new posts are rendered. In order to
|
||||||
if (this.get('direction') === 'up') {
|
// maintain the current scroll position relative to the content
|
||||||
var anchor = this.$().nextAll('.item:first');
|
// before/after the gap, we need to find item directly after the gap
|
||||||
|
// and use it as an anchor.
|
||||||
|
var siblingFunc = this.get('direction') === 'up' ? 'nextAll' : 'prevAll';
|
||||||
|
var anchor = this.$()[siblingFunc]('.item:first');
|
||||||
|
|
||||||
// Immediately after the posts have been loaded (but before they
|
// Immediately after the posts have been loaded (but before they
|
||||||
// have been rendered,) we want to grab the distance from the top of
|
// have been rendered,) we want to grab the distance from the top of
|
||||||
|
@ -102,7 +105,6 @@ export default Ember.Component.extend({
|
||||||
$('body').scrollTop(anchor.length ? anchor.offset().top - scrollOffset : $('body').height());
|
$('body').scrollTop(anchor.length ? anchor.offset().top - scrollOffset : $('body').height());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Tell the controller that we want to load the range of posts that this
|
// Tell the controller that we want to load the range of posts that this
|
||||||
// gap represents. We also specify which direction we want to load the
|
// gap represents. We also specify which direction we want to load the
|
||||||
|
|
Loading…
Reference in New Issue
Block a user