From d3fb5ee77c9baeac417c09a4f21cda790ed1ab52 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Tue, 7 Jul 2020 01:06:31 -0400 Subject: [PATCH] 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 --- js/src/forum/components/PostStream.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/js/src/forum/components/PostStream.js b/js/src/forum/components/PostStream.js index 0d2148dd7..4c8be9c07 100644 --- a/js/src/forum/components/PostStream.js +++ b/js/src/forum/components/PostStream.js @@ -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(); + } + }); } /**