FIX: Use `offset` to calculate eyeline, which is safer than `position`
This commit is contained in:
parent
e527294904
commit
1fb409e521
|
@ -4,13 +4,13 @@ import { cloak, uncloak } from 'discourse/widgets/post-stream';
|
|||
import { isWorkaroundActive } from 'discourse/lib/safari-hacks';
|
||||
import offsetCalculator from 'discourse/lib/offset-calculator';
|
||||
|
||||
function findTopView($posts, viewportTop, min, max) {
|
||||
function findTopView($posts, viewportTop, postsWrapperTop, min, max) {
|
||||
if (max < min) { return min; }
|
||||
|
||||
while (max > min) {
|
||||
const mid = Math.floor((min + max) / 2);
|
||||
const $post = $($posts[mid]);
|
||||
const viewBottom = $post.position().top + $post.height();
|
||||
const viewBottom = ($post.offset().top - postsWrapperTop) + $post.height();
|
||||
|
||||
if (viewBottom > viewportTop) {
|
||||
max = mid-1;
|
||||
|
@ -71,9 +71,10 @@ export default MountWidget.extend({
|
|||
|
||||
const windowTop = $w.scrollTop();
|
||||
|
||||
const postsWrapperTop = $('.posts-wrapper').offset().top;
|
||||
const $posts = this.$('.onscreen-post, .cloaked-post');
|
||||
const viewportTop = windowTop - slack;
|
||||
const topView = findTopView($posts, viewportTop, 0, $posts.length-1);
|
||||
const topView = findTopView($posts, viewportTop, postsWrapperTop, 0, $posts.length-1);
|
||||
|
||||
let windowBottom = windowTop + windowHeight;
|
||||
let viewportBottom = windowBottom + slack;
|
||||
|
|
Loading…
Reference in New Issue