Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PostStreamScrubber work for Posts that have top margin #2369

Merged
merged 5 commits into from
Oct 15, 2020

Conversation

w-4
Copy link
Contributor

@w-4 w-4 commented Oct 7, 2020

Basically the same as #1944. I now know what that PR was fixing. When Posts have a top margin the scrubber will bounce around.

To replicate go to https://nightly.flarum.site, set margin-top: 50px for .Post in the dev console. See scrubber bouncing back and forth when scrolling.

Not a priority, but should still be fixed I think.

Edit: New commit fixes #1897

Confirmed

  • Frontend changes: tested on a local Flarum installation.

@askvortsov1
Copy link
Member

Hmm, I remember I was looking at this back when doing #2160, but didn't include it for some reason, don't remember why though. I'll test it locally

Copy link
Member

@askvortsov1 askvortsov1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, this fixes the issue and doesn't seem to introduce any others. Thanks!

Copy link
Member

@clarkwinkelmann clarkwinkelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good, but would it maybe be prettier to use two number variables and no boolean?

Pseudo-code:

indexFromViewPort = null;
$.each(() => {
    // [...]
    if (!indexFromViewPort) {
        indexFromViewPort = parseFloat(...) + visibleTop/height
    }
    // [...]
})
// [...]
index = indexFromViewPort || $items.first().data() || 0

EDIT: I fixed my pseudo-code, the if statement was missing

@askvortsov1
Copy link
Member

That looks good, but would it maybe be prettier to use two number variables and no boolean?

That looks nice! Could also get us a bit closer to the implementation needed for #1897, so I like it

@w-4
Copy link
Contributor Author

w-4 commented Oct 8, 2020

Will do, we need to check against null though both times, since zero can be a valid index.

Copy link
Member

@askvortsov1 askvortsov1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested locally, confirmed that it still works.

Copy link
Member

@dsevillamartin dsevillamartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it fixes both issues mentioned (only one is an actual issue in the repo). Tested locally 👍

@askvortsov1 askvortsov1 merged commit ac42a59 into flarum:master Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page count incorrect when scrolling to bottom
4 participants