mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-14 00:50:14 -04:00
FIX: On small heights jumping to posts was iffy
This commit is contained in:
parent
5fc47e6942
commit
d2ebf0436c
1 changed files with 10 additions and 3 deletions
|
@ -13,8 +13,10 @@ export default function offsetCalculator(y) {
|
|||
const $title = $('#topic-title');
|
||||
const rawWinHeight = $(window).height();
|
||||
const windowHeight = rawWinHeight - $title.height();
|
||||
const expectedOffset = $title.height() - $header.find('.contents').height() + (windowHeight / 5);
|
||||
const ideal = $header.outerHeight(true) + ((expectedOffset < 0) ? 0 : expectedOffset);
|
||||
const eyeTarget = (windowHeight / 10);
|
||||
const headerHeight = $header.outerHeight(true);
|
||||
const expectedOffset = $title.height() - $header.find('.contents').height() + (eyeTarget * 2);
|
||||
const ideal = headerHeight + ((expectedOffset < 0) ? 0 : expectedOffset);
|
||||
|
||||
const $container = $('.posts-wrapper');
|
||||
const topPos = $container.offset().top;
|
||||
|
@ -23,7 +25,12 @@ export default function offsetCalculator(y) {
|
|||
const docHeight = $(document).height();
|
||||
const scrollPercent = (scrollTop / (docHeight-rawWinHeight));
|
||||
|
||||
const inter = topPos - scrollTop + ($container.height() * scrollPercent);
|
||||
let inter = topPos - scrollTop + ($container.height() * scrollPercent);
|
||||
if (inter < headerHeight + eyeTarget) {
|
||||
inter = headerHeight + eyeTarget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (inter > ideal) {
|
||||
const bottom = $('#topic-bottom').offset().top;
|
||||
|
|
Loading…
Reference in a new issue