Fix mobile topic-timeline not closing on scrolling past last post (#8730)

* when we dragged the topic-timeline handle past the last post
  in a topic we were not closing the timeline as we would if
  scrolling to a specific post
* this also fixes the issue where when scrolling past the end of
  the topic with a massive last post, none of the post could be
  seen
This commit is contained in:
Martin Brennan 2020-01-16 16:23:44 +10:00 committed by Sam
parent 7c32411881
commit 18bba860b5
2 changed files with 11 additions and 4 deletions

View File

@ -727,6 +727,10 @@ export default Controller.extend(bufferedProperty("model"), {
},
jumpEnd() {
this.appEvents.trigger(
"topic:jump-to-post",
this.get("model.highest_post_number")
);
DiscourseURL.routeTo(this.get("model.lastPostUrl"), {
jumpEnd: true
});

View File

@ -103,11 +103,14 @@ const DiscourseURL = EmberObject.extend({
let holderHeight = $holder.height();
let windowHeight = $(window).height() - offsetCalculator();
// scroll to the bottom of the post and stop any further action if the
// post is yuge, otherwise just jump to the top of the post
// using the lock & holder method
// scroll to the bottom of the post and if the post is yuge we go back up the
// timeline by a small % of the post height so we can see the bottom of the text.
//
// otherwise just jump to the top of the post using the lock & holder method.
if (holderHeight > windowHeight) {
$(window).scrollTop($holder.offset().top + holderHeight);
$(window).scrollTop(
$holder.offset().top + (holderHeight - holderHeight / 10)
);
_transitioning = false;
return;
}