FIX: Scrolling offset was broken when entering some topics

This commit is contained in:
Robin Ward 2017-04-27 16:21:54 -04:00
parent a501f9d4e5
commit cb8f91ca21
2 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@ export default class LockOn {
const selected = $(this.selector); const selected = $(this.selector);
if (selected && selected.offset && selected.offset()) { if (selected && selected.offset && selected.offset()) {
const result = selected.offset().top; const result = selected.offset().top;
return result - Math.round(scrollTopFor(result)); return result - (Math.round(scrollTopFor(result)) * 0.9);
} }
} }

View File

@ -25,7 +25,7 @@ export default function offsetCalculator(y) {
const scrollTop = y || $(window).scrollTop(); const scrollTop = y || $(window).scrollTop();
const docHeight = $(document).height(); const docHeight = $(document).height();
const scrollPercent = (scrollTop / (docHeight-rawWinHeight)); let scrollPercent = Math.min((scrollTop / (docHeight-rawWinHeight)), 1.0);
let inter = topPos - scrollTop + ($container.height() * scrollPercent); let inter = topPos - scrollTop + ($container.height() * scrollPercent);
if (inter < headerHeight + eyeTarget) { if (inter < headerHeight + eyeTarget) {
@ -35,7 +35,7 @@ export default function offsetCalculator(y) {
if (inter > ideal) { if (inter > ideal) {
const bottom = $('#topic-bottom').offset().top; const bottom = $('#topic-bottom').offset().top;
const switchPos = bottom - rawWinHeight; const switchPos = bottom - rawWinHeight - ideal;
if (scrollTop > switchPos) { if (scrollTop > switchPos) {
const p = Math.max(Math.min((scrollTop + inter - switchPos) / rawWinHeight, 1.0), 0.0); const p = Math.max(Math.min((scrollTop + inter - switchPos) / rawWinHeight, 1.0), 0.0);