1
0
mirror of https://github.com/flarum/core.git synced 2025-08-10 10:24:46 +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:
Alexander Skvortsov
2020-07-07 01:06:31 -04:00
committed by Franz Liedke
parent 479e5a8cf6
commit d3fb5ee77c

View File

@@ -279,6 +279,20 @@ export default class PostStream extends Component {
return this.$() && $('#header').outerHeight() + parseInt(this.$().css('margin-top'), 10); 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. * Scroll down to a certain post by number and 'flash' it.
* *
@@ -306,7 +320,11 @@ 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); return this.scrollToItem($item, noAnimation, true, bottom).done(() => {
if (index == this.state.count() - 1) {
return this.scrollToLast();
}
});
} }
/** /**