mirror of
https://github.com/flarum/core.git
synced 2025-08-07 17:07:19 +02:00
Handle scroll to end as a special case of scroll to index to ensure that we get completely to the bottom and flash the bottom element
This commit is contained in:
committed by
Franz Liedke
parent
479e5a8cf6
commit
d3fb5ee77c
@@ -279,6 +279,20 @@ export default class PostStream extends Component {
|
||||
return this.$() && $('#header').outerHeight() + parseInt(this.$().css('margin-top'), 10);
|
||||
}
|
||||
|
||||
scrollToLast() {
|
||||
return $('html,body')
|
||||
.stop(true)
|
||||
.animate(
|
||||
{
|
||||
scrollTop: $(document).height() - $(window).height(),
|
||||
},
|
||||
'fast',
|
||||
() => {
|
||||
this.flashItem(this.$('.PostStream-item:last-child'));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll down to a certain post by number and 'flash' it.
|
||||
*
|
||||
@@ -306,7 +320,11 @@ export default class PostStream extends Component {
|
||||
console.log('scrollToIndex');
|
||||
const $item = this.$(`.PostStream-item[data-index=${index}]`);
|
||||
|
||||
return this.scrollToItem($item, noAnimation, true, bottom);
|
||||
return this.scrollToItem($item, noAnimation, true, bottom).done(() => {
|
||||
if (index == this.state.count() - 1) {
|
||||
return this.scrollToLast();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user