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

Navbar collapse on iOS not working correctly #100

Open
user-1138 opened this issue Jan 3, 2019 · 1 comment
Open

Navbar collapse on iOS not working correctly #100

user-1138 opened this issue Jan 3, 2019 · 1 comment
Assignees
Labels

Comments

@user-1138
Copy link

I did see Issue #32 marked as closed a few years back, but I've just come across your theme and I'm experiencing the same problems on iOS - basically you need to scroll all the way to the top/bottom of the page and then scroll up/down again (kind of like a double-scroll) for the "navbar-shrink" class to be added/removed.

FYI - In my brief testing I've found that by removing this js -

  // Collapse Navbar
  var navbarCollapse = function() {
    if ($("#mainNav").offset().top > 100) {
      $("#mainNav").addClass("navbar-shrink");
    } else {
      $("#mainNav").removeClass("navbar-shrink");
    }
  };
  // Collapse now if page is not at top
  navbarCollapse();
  // Collapse the navbar when page is scrolled
  $(window).scroll(navbarCollapse);

and replacing it with something like this, works much better -

  $(document).scroll(function() {
   if($(window).scrollTop() !== 0) {
       $("#mainNav").addClass("navbar-shrink");
   } else {
       $("#mainNav").removeClass("navbar-shrink");
   }
  });

It's far from perfect (i.e. it does 'shrink' earlier than previously and if you scroll up when at the top of the page, it will (briefly) apply the class and the navbar shrinks/changes color until the page falls back down to the top again), and I'm not sure exactly what Crapple's problem is, but this is much better on iOS and still works as you'd expect on Desktop/Android.

I hope that helps - anyways, use it as you please!

Tested On -
iOS - v9.3.5 Safari, Firefox v8.3, Chrome v63.3239.73
Grayscale v5.0.2 & 5.0.3

PS: Great looking theme BTW! :-)

@scottjr101
Copy link

I moved this whole theme over into my React app and this was the only issue I had. Thank you so much for this little bit of code, saved me hours of debugging!

@davidtmiller davidtmiller self-assigned this May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants