FIX: Make scrolling to bottom post in topic more consistent (#8671)

* Make scrolling to bottom post in topic more consistent

* when using the slider to scroll past the bottom post,
  we now scroll to the bottom of the post/page IF the
  post height is > the window height (e.g. really long
  posts). if the post height is smaller, then we lock
  onto and jump to the top of the post
* this also removes the mobile hack that would always jump
  to the top of the last post on mobile

* Prettier lint
This commit is contained in:
Martin Brennan 2020-01-08 15:37:13 +10:00 committed by Sam
parent 710eafdd35
commit bdff4561d4
2 changed files with 13 additions and 4 deletions

View File

@ -99,9 +99,18 @@ const DiscourseURL = EmberObject.extend({
let holder;
if (opts.jumpEnd) {
$(window).scrollTop($(document).height() - $(window).height());
_transitioning = false;
return;
let $holder = $(holderId);
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
if (holderHeight > windowHeight) {
$(window).scrollTop($holder.offset().top + holderHeight);
_transitioning = false;
return;
}
}
if (postNumber === 1 && !opts.anchor) {

View File

@ -263,7 +263,7 @@ createWidget("timeline-scrollarea", {
const position = this.position();
this.state.scrolledPost = position.current;
if (position.current === position.scrollPosition || this.site.mobileView) {
if (position.current === position.scrollPosition) {
this.sendWidgetAction("jumpToIndex", position.current);
} else {
this.sendWidgetAction("jumpEnd");