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

Post page navigation disappears when scrolling down #378

Open
tzzs opened this issue Mar 3, 2024 · 7 comments
Open

Post page navigation disappears when scrolling down #378

tzzs opened this issue Mar 3, 2024 · 7 comments

Comments

@tzzs
Copy link

tzzs commented Mar 3, 2024

Post-page navigation disappears when scrolling down. And it does not reappear after back to top.
Is there a way to solve this?

@tzzs
Copy link
Author

tzzs commented Mar 3, 2024

I found the following code in the source/js/main.js.

And there is a question:

  1. I print the topDistance in the console.
  2. I scroll down the page and then back to top. That shows the min of topDistance is 83.5. It will never less than 50, so it cannot show again.
$(window).on("scroll", function() {
        var topDistance = menu.offset().top;

        // hide only the navigation links on desktop
        console.log(topDistance)
        if (!nav.is(":visible") && topDistance < 50) {
          nav.show();
        } else if (nav.is(":visible") && topDistance > 100) {
          nav.hide();
        }

        // on tablet, hide the navigation icon as well and show a "scroll to top
        // icon" instead
        if ( ! $( "#menu-icon" ).is(":visible") && topDistance < 50 ) {
          $("#menu-icon-tablet").show();
          $("#top-icon-tablet").hide();
        } else if (! $( "#menu-icon" ).is(":visible") && topDistance > 100) {
          $("#menu-icon-tablet").hide();
          $("#top-icon-tablet").show();
        }
      });

image

@tzzs
Copy link
Author

tzzs commented Mar 3, 2024

I try to change topDistance < 50 to topDistance <= 100.

        if (!nav.is(":visible") && topDistance < 50) {
          nav.show();
        } else if (nav.is(":visible") && topDistance > 100) {
          nav.hide();
        }
        if (!nav.is(":visible") && topDistance <= 100) {
          nav.show();
        } else if (nav.is(":visible") && topDistance > 100) {
          nav.hide();
        }

@cubicYYY
Copy link

Same problem, looking for a solution. I wonder if this issue be introduced recently or it just sit there for a long time?

@deskangel
Copy link

I use the document.documentElement.scrollTop; instead of menu.offset().top, and it works.

        var topDistance = document.documentElement.scrollTop;// menu.offset().top;

        // hide only the navigation links on desktop
        const distanceLimit = 50;
        if (!nav.is(":visible") && topDistance < distanceLimit) {
          nav.show();
        } else if (nav.is(":visible") && topDistance >= distanceLimit) {
          nav.hide();
        }

@tzzs
Copy link
Author

tzzs commented Apr 19, 2024

Same problem, looking for a solution. I wonder if this issue be introduced recently or it just sit there for a long time?

It has been a long time. It looks like the author will not update the project.

@probberechts
Copy link
Owner

My priorities have indeed shifted to other projects. People have suggested fixes for this issue but none of them really resolved it. If you have something that works across all major web browsers, feel free to create a PR and I'll look into it.

@foxB612
Copy link
Contributor

foxB612 commented Apr 30, 2024

People have suggested fixes for this issue but none of them really resolved it.

Did a quick test and found that all the proposed fixes work on my machine with Firefox 125.0.2 and Chromium 124.0.6367.91:

  • Change limit from 50 to 100 (yes, not very neat);
  • Or, alternatives to menu.offset().top:
    • document.documentElement.scrollTop
    • window.pageYOffset
    • window.scrollY
    • $(window).scrollTop()

I saw people saying that for some of these fixes, high resolution or a post full of images may still trigger the issue; but I failed to reproduce (used dev tools to emulate resolution 4096x2160).

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

No branches or pull requests

5 participants