mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 19:49:29 +08:00
FIX: Scrolling offset was broken when entering some topics
This commit is contained in:
parent
a501f9d4e5
commit
cb8f91ca21
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user